diff --git a/src/display.c b/src/display.c index 2db73e8..1dcf30c 100644 --- a/src/display.c +++ b/src/display.c @@ -30,6 +30,7 @@ void displayItem(int tabReference[], float weight[], float volume[], float unitP printf("La référence cherchée n'existe pas"); exit(1); } + printf("reference\tpoids\tvolume\tprix à l'unité"); printf("%d\t%f\t%f\t%f", tabReference[index], weight[index], volume[index], unitPrice[index]); } @@ -49,14 +50,14 @@ void displayItemList(int reference[], float weight[], float volume[], float unit +var i: compteur servant à parcourir les données des tableaux jusqu'à leur taille logique */ int i; - printf("reference\tpoids\tvolume\tprix"); + printf("reference\tpoids\tvolume\tprix à l'unité"); for (i=0; iindex; i--) + { + tabReference[i-1] = tabReference[i]; + tabWeight[i-1] = tabWeight[i]; + tabVolume[i-1] = tabVolume[i]; + unitPrice[i-1] = unitPrice[i]; + } + *tlog--; + } +} + +void deleteClient(int clientID[], float cagnotte[], int suspended[], int isAdmin[], int *tlog) +{ + int numClient = -1, index, i; + while (numClient != 0) + { + printf("Entrez l'identifiant du client à supprimer ou 0 si vous souhaitez arrêter la saisie: "); + scanf("%d", &numClient); + while (numClient < 0) + { + printf("Erreur, le numéro du client doit être positif, entrez le numéro du client ou 0 si vous souhaitez arrêter la saisie: "); + scanf("%d", &numClient); + } + index = recherche(numClient, clientID, *tlog); + while (index == -1) + { + printf("Cet identifiant client n'existe pas, réessayer ou tapez 0 si vous souhaitez arrêter la saisie: "); + scanf("%d", &numClient); + index = recherche(numClient, clientID, *tlog); + } + for (i=*tlog; i>index; i--) + { + clientID[i-1] = clientID[i]; + cagnotte[i-1] = cagnotte[i]; + suspended[i-1] = suspended[i]; + isAdmin[i-1] = isAdmin[i]; + } + *tlog--; + } } \ No newline at end of file diff --git a/src/traitement.c b/src/traitement.c index 69eb8b7..0bd4815 100644 --- a/src/traitement.c +++ b/src/traitement.c @@ -28,7 +28,7 @@ int recherche(int val, int tab[], int tlog) // Recherche de l'index d'un id (de return -1; } -void chargeDonnees(int *tLogArticle, int *tLogClient,int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) +void chargeDonnees(int *tLogArticle, int *tLogClient,int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[], int isAdmin[]) { /* Chargement des données des articles et clients de fichiers vers des tableaux @@ -44,7 +44,7 @@ void chargeDonnees(int *tLogArticle, int *tLogClient,int reference[], float weig +param suspended: tableau de l'état du compte des clients */ *tLogArticle = chargeArticles(reference, weight, volume, unitPrice); - *tLogClient = chargeClients(clientID, cagnotte, suspended); + *tLogClient = chargeClients(clientID, cagnotte, suspended, isAdmin); } int chargeArticles(int reference[], float weight[], float volume[], float unitPrice[]) @@ -100,7 +100,7 @@ int chargeArticles(int reference[], float weight[], float volume[], float unitPr return tL; } -int chargeClients(int clientID[], float cagnotte[], int suspended[]) +int chargeClients(int clientID[], float cagnotte[], int suspended[], int isAdmin[]) { /* Chargement des données des clients d'un fichier vers des tableaux @@ -125,10 +125,10 @@ int chargeClients(int clientID[], float cagnotte[], int suspended[]) exit(1); } - int id, sus, tL=0; + int id, sus, tL=0, adm; float cag; - fscanf(client, "%d %f %d", &id, &cag, &sus); + fscanf(client, "%d %f %d %d", &id, &cag, &sus, &adm); while(!feof(client)) { if(tL < tmaxArticles) @@ -140,17 +140,18 @@ int chargeClients(int clientID[], float cagnotte[], int suspended[]) clientID[tL] = id; cagnotte[tL] = cag; suspended[tL] = sus; + isAdmin[tL] = adm; tL++; - fscanf(client, "%d %f %d", &id, &cag, &sus); + fscanf(client, "%d %f %d", &id, &cag, &sus, &adm); } fclose(client); return tL; } -void sauvegardeDonnees(int tLogArticle, int tLogClient, int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[]) +void sauvegardeDonnees(int tLogArticle, int tLogClient, int reference[], float weight[], float volume[], float unitPrice[], int clientID[], float cagnotte[], int suspended[], int isAdmin[]) { /* Sauvegarde des données des articles et clients de tableaux vers des fichiers @@ -166,7 +167,7 @@ void sauvegardeDonnees(int tLogArticle, int tLogClient, int reference[], float w +param suspended: tableau de l'état du compte des clients */ sauvegardeArticles(reference, weight, volume, unitPrice, tLogArticle); - sauvegardeClients(clientID, cagnotte, suspended, tLogClient); + sauvegardeClients(clientID, cagnotte, suspended, isAdmin, tLogClient); } void sauvegardeArticles(int reference[], float weight[], float volume[], float unitPrice[], int tLogArticle) @@ -200,7 +201,7 @@ void sauvegardeArticles(int reference[], float weight[], float volume[], float u fclose(article); } -void sauvegardeClients(int clientID[], float cagnotte[], int suspended[], int tLogClient) +void sauvegardeClients(int clientID[], float cagnotte[], int suspended[], int isAdmin[], int tLogClient) { /* Sauvegarde des données des articles de tableaux vers le fichier des articles @@ -224,7 +225,7 @@ void sauvegardeClients(int clientID[], float cagnotte[], int suspended[], int tL int i; for(i=0; i