bug recherche client (ok) & svgarde modif client ds txt
This commit is contained in:
parent
b3e76c6e93
commit
aa9900460a
20
VANDAMME28.c
20
VANDAMME28.c
|
@ -149,14 +149,13 @@ int main()
|
|||
printf("\nPrenom du client (sensible a la casse) : ");
|
||||
clean_keyboard();scanf("%s", prenomClient);
|
||||
ofsetFileCurClient = rechercheClient(nomClient,prenomClient, clientDatF, client, &date);
|
||||
if(client != NULL)
|
||||
if(ofsetFileCurClient)
|
||||
{
|
||||
w = gestionClient(client, &date, clientDatF, clientTXTF);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("\nClient non trouvé !\n");
|
||||
printf("%d",(int)sizeof(Client));
|
||||
}
|
||||
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 ofsetFileCurClient;
|
||||
int t;
|
||||
fseek(clientDatF, sizeof(unsigned long int)+sizeof(Bool), SEEK_SET);
|
||||
clearerr(clientDatF); //Clear EOF
|
||||
do
|
||||
{
|
||||
ofsetFileCurClient = ftell(clientDatF);
|
||||
fread(client, sizeof(Client), 1, clientDatF);
|
||||
afficherClient(client, date);
|
||||
}while(!feof(clientDatF) && compNP(client->nom, client->prenom, nom, prenom));
|
||||
t = compNP(client->nom, client->prenom, nom, prenom);
|
||||
}while(!feof(clientDatF) && t);
|
||||
if(feof(clientDatF))
|
||||
return 0;
|
||||
{
|
||||
client = NULL;
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
return ofsetFileCurClient;
|
||||
}
|
||||
|
@ -618,7 +621,7 @@ int compNP(char *nom1, char *prenom1,char *nom2, char *prenom2)
|
|||
for(tmp = prenom2;*tmp++;strLen2++);
|
||||
char * np1 = malloc(strLen1+1);
|
||||
char * np2 = malloc(strLen2+1);
|
||||
int renvois;
|
||||
int renvois=0;
|
||||
sprintf(np1,"%s%s", nom1, prenom1);
|
||||
sprintf(np2,"%s%s", nom2, prenom2);
|
||||
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);
|
||||
while(!feof(bin))
|
||||
{
|
||||
fread(&client, sizeof(Client), 1,bin);
|
||||
if(fread(&client, sizeof(Client), 1,bin))
|
||||
sauvegarderClientTXT(&client, txt, 0);
|
||||
fprintf(txt, "========================================================================");
|
||||
}
|
||||
fflush(txt);
|
||||
// fread()
|
||||
}
|
||||
|
||||
|
@ -685,4 +688,5 @@ void modificationClient(Client * client, FILE * clientDatF, FILE * clientTXTF)
|
|||
clean_keyboard();scanf("%c", &choix);
|
||||
}while((choix|0b00100000) == 'y');
|
||||
sauvegarderClientFile(clientTXTF, clientDatF, client);
|
||||
clientBinToTXT(clientDatF, clientTXTF);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue