bug recherche client (ok) & svgarde modif client ds txt

This commit is contained in:
adriy 2017-04-20 19:39:08 +00:00
parent b3e76c6e93
commit aa9900460a
1 changed files with 692 additions and 688 deletions

View File

@ -149,14 +149,13 @@ int main()
printf("\nPrenom du client (sensible a la casse) : "); printf("\nPrenom du client (sensible a la casse) : ");
clean_keyboard();scanf("%s", prenomClient); clean_keyboard();scanf("%s", prenomClient);
ofsetFileCurClient = rechercheClient(nomClient,prenomClient, clientDatF, client, &date); ofsetFileCurClient = rechercheClient(nomClient,prenomClient, clientDatF, client, &date);
if(client != NULL) if(ofsetFileCurClient)
{ {
w = gestionClient(client, &date, clientDatF, clientTXTF); w = gestionClient(client, &date, clientDatF, clientTXTF);
} }
else else
{ {
printf("\nClient non trouvé !\n"); printf("\nClient non trouvé !\n");
printf("%d",(int)sizeof(Client));
} }
break; break;
} }
@ -478,16 +477,20 @@ void gestionFacture(Client * client, Date * date)
long int rechercheClient(char *nom, char *prenom, FILE * clientDatF, Client * client, Date * date) long int rechercheClient(char *nom, char *prenom, FILE * clientDatF, Client * client, Date * date)
{ {
long int ofsetFileCurClient; long int ofsetFileCurClient;
int t;
fseek(clientDatF, sizeof(unsigned long int)+sizeof(Bool), SEEK_SET); fseek(clientDatF, sizeof(unsigned long int)+sizeof(Bool), SEEK_SET);
clearerr(clientDatF); //Clear EOF clearerr(clientDatF); //Clear EOF
do do
{ {
ofsetFileCurClient = ftell(clientDatF); ofsetFileCurClient = ftell(clientDatF);
fread(client, sizeof(Client), 1, clientDatF); fread(client, sizeof(Client), 1, clientDatF);
afficherClient(client, date); t = compNP(client->nom, client->prenom, nom, prenom);
}while(!feof(clientDatF) && compNP(client->nom, client->prenom, nom, prenom)); }while(!feof(clientDatF) && t);
if(feof(clientDatF)) if(feof(clientDatF))
return 0; {
client = NULL;
return NULL;
}
else else
return ofsetFileCurClient; return ofsetFileCurClient;
} }
@ -618,7 +621,7 @@ int compNP(char *nom1, char *prenom1,char *nom2, char *prenom2)
for(tmp = prenom2;*tmp++;strLen2++); for(tmp = prenom2;*tmp++;strLen2++);
char * np1 = malloc(strLen1+1); char * np1 = malloc(strLen1+1);
char * np2 = malloc(strLen2+1); char * np2 = malloc(strLen2+1);
int renvois; int renvois=0;
sprintf(np1,"%s%s", nom1, prenom1); sprintf(np1,"%s%s", nom1, prenom1);
sprintf(np2,"%s%s", nom2, prenom2); sprintf(np2,"%s%s", nom2, prenom2);
renvois = strcmp(np1,np2); renvois = strcmp(np1,np2);
@ -640,10 +643,10 @@ le standard c n'autorise que l'ajout et la modif EN COURS*/
fseek(bin, sizeof(Bool), SEEK_CUR); fseek(bin, sizeof(Bool), SEEK_CUR);
while(!feof(bin)) while(!feof(bin))
{ {
fread(&client, sizeof(Client), 1,bin); if(fread(&client, sizeof(Client), 1,bin))
sauvegarderClientTXT(&client, txt, 0); sauvegarderClientTXT(&client, txt, 0);
fprintf(txt, "========================================================================");
} }
fflush(txt);
// fread() // fread()
} }
@ -685,4 +688,5 @@ void modificationClient(Client * client, FILE * clientDatF, FILE * clientTXTF)
clean_keyboard();scanf("%c", &choix); clean_keyboard();scanf("%c", &choix);
}while((choix|0b00100000) == 'y'); }while((choix|0b00100000) == 'y');
sauvegarderClientFile(clientTXTF, clientDatF, client); sauvegarderClientFile(clientTXTF, clientDatF, client);
clientBinToTXT(clientDatF, clientTXTF);
} }