diff --git a/app b/app deleted file mode 100755 index e92ef0a..0000000 Binary files a/app and /dev/null differ diff --git a/src/app/core_logic/responsable.c b/src/app/core_logic/responsable.c index ffec50b..888777b 100644 --- a/src/app/core_logic/responsable.c +++ b/src/app/core_logic/responsable.c @@ -169,7 +169,7 @@ void supprimerArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], i tVol[i] = tVol[i+1]; tPrix[i] = tPrix[i+1]; } - *tLogique -= 1; + (*tLogique)--; } /** @@ -245,7 +245,6 @@ int decodageMDP(char *mdpEnter) } fscanf(fe, "%s %d", mdpRead, &decalage); - printf("%s", mdpRead); fclose(fe); dechiffrerCesar(mdpEnter, decalage); @@ -258,4 +257,4 @@ int decodageMDP(char *mdpEnter) { return -2; } -} \ No newline at end of file +} diff --git a/src/app/interface/interface_resp.c b/src/app/interface/interface_resp.c index 01d4e10..adb00f2 100644 --- a/src/app/interface/interface_resp.c +++ b/src/app/interface/interface_resp.c @@ -31,7 +31,8 @@ void affiche_resp(void) { printf("||\t6 : Supprimer un article\t\t\t\t||\n"); printf("||\t7 : Modifier un article\t\t\t\t\t||\n"); printf("||\t8 : Ajouter un client\t\t\t\t\t||\n"); - printf("||\t9 : Quittez.\t\t\t\t\t\t||\n"); + printf("||\t9 : Modifier le statu du client\t\t\t\t||\n"); + printf("||\t10 : Quittez.\t\t\t\t\t\t||\n"); printf("+-----------------------------------------------------------------+\n"); } @@ -251,6 +252,99 @@ int affichageConnexion(void) return -2; } +void affichModifClient(int tNumClient[], int tSus[], int tLogique) +{ + int choix, numC; + printf("\tEntrez le numéro du client : "); + scanf("%d", &numC); + + for ( int i = 0; i < tLogique; ++i) + { + if ( numC == tNumClient[i] ) + { + if ( tSus[i] == 0 ) + { + printf("\t La cagnotte du client n'est pas suspendu, voulez-vous le suspendre ?\n ( Oui = 0 / Non = 1 )\n "); + while(scanf("%d", &choix) != 1 || choix < 0 || choix > 1) + { + printf("\t Veuillez entrer un choix valide ! \n"); + } + if ( choix == 0 ) + { + tSus[i] = 1; + printf("\t La cagnotte est maintenant suspendu\n"); + return; + } + else + { + printf("\t La cagnotte n'a pas été changé. Au revoir ! \n"); + return; + } + } + else + { + printf("\t La cagnotte du client %d est suspendue, voulez-vous l'activer à nouveau ?\n ( Oui = 0 / Non = 1 )\n", tNumClient[i]); + while(scanf("%d", &choix) != 1 || choix < 0 || choix > 1) + { + printf("\t Veuillez entrer un choix valide ! \n"); + } + if ( choix == 0 ) + { + tSus[i] = 0; + printf("\t La cagnotte n'est plus suspendu\n"); + return; + } + else + { + printf("\t La cagnotte n'a pas été changé. Au revoir ! \n"); + return; + } + } + } + printf("\t Le client %d n'a pas été trouvé. \n", numC); + return; + } +} + + +void suppressionClient(int tNumClient[], float tCagnotte[], int tSus[], int *tLogique) +{ + int choix, numC; + printf("\tEntrez le numéro du client : "); + scanf("%d", &numC); + + for ( int i = 0; i < *tLogique; ++i) + { + if ( numC == tNumClient[i] ) + { + printf("\tÊtes-vous sur de vouloir supprimer ce client ? ( Oui = 0 / Non = 1 )\n"); + while(scanf("%d", &choix) != 1 || choix < 0 || choix > 1) + { + printf("\t Veuillez entrer un choix valide ! \n"); + } + if ( choix == 0 ) + { + for ( int j = i; j < *tLogique-1; j++) + { + tNumClient[j] = tNumClient[j+1]; + tCagnotte[j] = tCagnotte[j+1]; + tSus[j] = tSus[j+1]; + } + printf("Le client %d a été supprimé.\n", tNumClient[i]); + (*tLogique)--; + return; + } + else + { + printf("\t Le client %d n'a pas été supprimé.\n", tNumClient[i]); + return; + } + } + } + printf("\t Le client %d n'a pas été trouvé. \n", numC); + return; +} + /** * @brief Fonction de menu pour le responsable. * @@ -259,7 +353,7 @@ int affichageConnexion(void) void menu_resp(int *choix) { affiche_resp(); printf("Vous choisissez: "); - while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 9) { + while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 11) { while (getchar() != '\n'); affiche_resp(); printf("Veuillez entrer un choix valide : "); @@ -311,6 +405,12 @@ void global_resp() { ajouterClient(tNumClient, tCagnotte, tSus, &tLogClient, MAX_CLIENTS); break; case 9: + affichModifClient(tNumClient, tSus, tLogClient); + break; + case 10: + suppressionClient(tNumClient, tCagnotte ,tSus , &tLogClient); + break; + case 11: sauvegardArticles(tRef, tPoids, tVol, tPrix, tLogArticle); printf("Sauvegarde des articles effectuée.\n"); printf("Au revoir !\n"); @@ -319,6 +419,6 @@ void global_resp() { printf("Veuillez entrer un choix valide ! \n"); break; } - } while (choix != 9); + } while (choix != 11); } \ No newline at end of file diff --git a/src/app/interface/interface_resp.h b/src/app/interface/interface_resp.h index 2d3f23f..ae0199c 100644 --- a/src/app/interface/interface_resp.h +++ b/src/app/interface/interface_resp.h @@ -101,6 +101,8 @@ void menu_resp(int *choix); */ int affichageConnexion(void); +void affichModifClient(int tNumClient[], int tSus[], int tLogique); + /** * @brief Fonction principale de l'interface du responsable. *