This commit is contained in:
Adrien VAN DAMME 2017-04-03 10:57:10 +02:00
parent 3c0ea942f5
commit e90e7b5511
1 changed files with 29 additions and 4 deletions

View File

@ -282,7 +282,6 @@ void sauvegarderClientTXT(Client *client, FILE * file, Bool ageAff, ...) //Ecrir
}
else
fprintf(file,"\n");
//fprintf(file, "Client : %s %s (%d)\n", client->nom, client->prenom, ageClient(client, date));
fprintf(file, "rue : %s\n",client->adresse.rue);
fprintf(file, "numero : %s\n",client->adresse.numero);
fprintf(file, "localité : %s\n",client->adresse.localite);
@ -290,8 +289,14 @@ void sauvegarderClientTXT(Client *client, FILE * file, Bool ageAff, ...) //Ecrir
fprintf(file, "numéro de tél. : %s\n",client->contact.telephone);
fprintf(file, "adresse email : %s\n",client->contact.email);
if(ageAff)
{
fprintf(file, "\nPoints de fidelite aqui : %d\n", client->fidelite);
}
else
{
fprintf(file, "\n===========================================================================\n");
}
}
void encoderFacture(Panier * panier)
{
char continuer = 'y';
@ -664,6 +669,13 @@ void localiserFichiersClients(char fichierClientDat[__STRLEN_FILE__], FILE ** cl
int sauvegarderClientFile(FILE ** clientF, Client * client)
{
int posi;
unsigned long int nbrClient;
fseek(clientF[__TAB_CLIENTDAT_FILE__], 0, SEEK_SET);
fread(&nbrClient,sizeof(nbrClient),1,clientF[__TAB_CLIENTDAT_FILE__]);
nbrClient++;
fseek(clientF[__TAB_CLIENTDAT_FILE__], 0, SEEK_SET);
fwrite(&nbrClient,sizeof(nbrClient),1,clientF[__TAB_CLIENTDAT_FILE__]);
fseek(clientF[__TAB_CLIENTDAT_FILE__], 0, SEEK_END);
fseek(clientF[__TAB_CLIENTTXT_FILE__], 0, SEEK_END);
posi = ftell(clientF[__TAB_CLIENTDAT_FILE__]);
@ -674,10 +686,16 @@ int sauvegarderClientFile(FILE ** clientF, Client * client)
return posi;
}
int compNP(char nom1[__STRLEN__], char prenom1[__STRLEN__],char nom2[__STRLEN__], char prenom2[__STRLEN__])
int compNP(char *nom1, char *prenom1,char *nom2, char *prenom2)
{
char np1[__STRLEN__*2];
char np2[__STRLEN__*2];
unsigned int strLen1, strLen2;
char * tmp;
for(strLen1 = 0, tmp = nom1;*tmp++;strLen1++);
for(tmp = prenom1;*tmp++;strLen1++);
for(strLen1 = 0, tmp = nom2;*tmp++;strLen2++);
for(tmp = prenom2;*tmp++;strLen2++);
char * np1 = malloc(strLen1+1);
char * np2 = malloc(strLen2+1);
int renvois;
sprintf(np1,"%s%s", nom1, prenom1);
sprintf(np2,"%s%s", nom2, prenom2);
@ -691,8 +709,15 @@ int compNP(char nom1[__STRLEN__], char prenom1[__STRLEN__],char nom2[__STRLEN__]
void clientBinToTXT(FILE * bin, FILE* txt)
{
Client client;
fseek(bin, 0, SEEK_SET);fseek(txt, 0, SEEK_SET);
clearerr(bin);clearerr(txt);
fseek(bin, sizeof(unsigned long int), SEEK_CUR);
fseek(bin, sizeof(Bool), SEEK_CUR);
while(!feof(bin))
{
fread(&client, sizeof(Client), 1,bin);
sauvegarderClientTXT(&client, txt, 0);
}
// fread()
}