From 5ca807fb35109875dbd102831ed5a7ea2203b31a Mon Sep 17 00:00:00 2001 From: allaurent13 Date: Sat, 7 Jan 2023 13:27:05 +0000 Subject: [PATCH] 07/01 - Correction de tout les bug de SAE.c tout fonctionne normalement il manque juste la sauvegarde --- SAE.c | 108 +++++++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 51 deletions(-) diff --git a/SAE.c b/SAE.c index ef22f06..3ae55e1 100644 --- a/SAE.c +++ b/SAE.c @@ -59,6 +59,7 @@ bool confirmationSup(void) { char choix[4]; while(1) + { printf("Êtes-vous sûr de vouloir supprimer/moddifié : "); scanf("%s", choix); if (strcmp(choix,"oui")==0) @@ -66,6 +67,7 @@ bool confirmationSup(void) if (strcmp(choix,"non")==0) return false; printf("Erreur de sélection ! Veuillez réessayer \n"); + } } @@ -117,29 +119,37 @@ void gestionMenu(VilleIUT **tiut, int nbEle) system("clear"); switch(choix) { case 1: - //mettre a jour le nombre de places d'un département d'un iut + AffichageVille(tiut,nbEle); clearpage(); break; case 2: - //créer un département dans un iut + AffichageGlobalDepVille(tiut, nbEle); clearpage(); break; case 3: - //supprimer un département dans un iut + AffichageNbplaceDept(tiut, nbEle); clearpage(); break; case 4: - //gérer les phases de candidature + AffichageNbplaceDeptVille(tiut, nbEle); clearpage(); break; case 5: - //affichage de tout les département d'un iut + AffichageDepVille(tiut, nbEle); + clearpage(); + break; + case 6: + AffichageDeptVille(tiut, nbEle); + clearpage(); + break; + case 7: + AffichageGlobalIUT(tiut, nbEle); clearpage(); break; case 9: choix = gestionMenuAdmin(tiut, nbEle); if (choix == -1) - return; + if (verifQuit()) return; break; case 10: if (verifQuit()) return; @@ -160,30 +170,24 @@ int gestionMenuAdmin(VilleIUT **tiut, int nbEle) system("clear"); switch(choix){ case 1: - clearpage(); + MiseAJourNbPlace(tiut, nbEle); + system("clear"); break; case 2: - clearpage(); + creationDept(tiut, nbEle); + system("clear"); break; case 3: - //affichage du nombres de places par département des iut - clearpage(); + suppressionDept(tiut, nbEle); + system("clear"); break; case 4: //affichage du nombres de places par département d'un iut clearpage(); break; case 5: - //affichage de tout les département d'un iut - clearpage(); - break; - case 6: - //affichage de tout les iut ayant un département choisi - clearpage(); - break; - case 7: - //affichage de tout les iut ayant un département choisi - clearpage(); + modifChefDept(tiut, nbEle); + system("clear"); break; case 9: return 0; @@ -202,10 +206,7 @@ void global(void) printf("charg\n"); tab = chargementVille(nomFich,30,&tailleL); printf("\n"); - triEchange(tab, tailleL); - creationDept(tab, tailleL); - AffichageGlobalDepVille(tab, tailleL); - SauvegarderIUT(tab, tailleL); + gestionMenu(tab, tailleL); } void AffichageVille(VilleIUT **tiut, int nbEle) @@ -221,14 +222,16 @@ void AffichageVille(VilleIUT **tiut, int nbEle) void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle) { int i; + MaillonDept *aux; printf("\tDépartement par IUT :\n"); for(i=0;iville); - while(tiut[i]->idDept != NULL) + aux = tiut[i]->idDept; + while(aux != NULL) { - printf("|%s|\n",tiut[i]->idDept->departement); - tiut[i]->idDept = tiut[i]->idDept->suiv; + printf("|%s|\n",aux->departement); + aux = aux->suiv; } } } @@ -236,13 +239,15 @@ void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle) void AffichageNbplaceDept(VilleIUT **tiut, int nbEle) { int pos; + MaillonDept *aux; for (pos = 0; pos < nbEle; pos++) { printf("%s -> \t", tiut[pos]->ville); - while(tiut[pos]->idDept->suiv != NULL && pos < nbEle) + aux = tiut[pos]->idDept; + while(aux->suiv != NULL && pos < nbEle) { - printf("|%s, %d places|\n\t",tiut[pos]->idDept->departement, tiut[pos]->idDept->nbPers); - tiut[pos]->idDept = tiut[pos]->idDept->suiv; + printf("|%s, %d places|\n\t",aux->departement, aux->nbPers); + aux = aux->suiv; } printf("\n"); } @@ -263,6 +268,8 @@ int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve) sup = m - 1; else inf = m + 1; } + *trouve = 0; + return inf; } void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle) @@ -382,7 +389,7 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle) aux = rechercheDept(tiut[pos]->idDept, code); if (aux != NULL) { - printf("Ancien nombre de places : %d",aux->nbPers); + printf("Ancien nombre de places : %d\n",aux->nbPers); printf("Nouveau nombre de places : ", nouvNbPlace); scanf("%d", &nouvNbPlace); aux->nbPers = nouvNbPlace; @@ -420,10 +427,10 @@ void creationDept(VilleIUT **tiut, int nbEle) while(1) { printf("Nom du Département : "); - scanf("%s%*c", code); + scanf("%s", code); aux = rechercheDept(tiut[pos]->idDept, code); if (aux != NULL) - printf("Département déjà existant"); + printf("Département déjà existant\n"); if (aux == NULL) { printf("Nom du Responsable du Département de %s : ",code); @@ -494,24 +501,23 @@ void modifChefDept(VilleIUT **tiut, int nbEle) pos = rechVille(tiut, nbEle, code, &trouve); if (trouve == 1) { - while(1) - printf("Nom du Département : "); - scanf("%s", code); - aux = rechercheDept(tiut[pos]->idDept, code); - if (aux != NULL) - { - printf("Nom de l'ancien chef de département %s de %s : %s\n",aux->departement, tiut[pos]->ville,aux->responsable); - printf("Nom du nouveau chef de département %s de %s :",aux->departement, tiut[pos]->ville); - fgets(code,30,stdin); - code[strlen(code)-1] = '\0'; - strcpy(code, aux->responsable); - printf("Chef de département : %s\n",tiut[pos]->idDept->responsable); - } - if (aux == NULL) - printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville); - printf("Saisi Département :\n"); - if (!verifSelection()) - break; + printf("Nom du Département : "); + scanf("%s%*c", code); + aux = rechercheDept(tiut[pos]->idDept, code); + if (aux != NULL) + { + printf("Nom de l'ancien chef de département %s de %s : %s\n",aux->departement, tiut[pos]->ville,aux->responsable); + printf("Nom du nouveau chef de département %s de %s :",aux->departement, tiut[pos]->ville); + fgets(code,30,stdin); + code[strlen(code)-1] = '\0'; + strcpy(aux->responsable, code); + printf("Chef de département : %s\n",aux->responsable); + } + if (aux == NULL) + printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville); + printf("Saisi Département :\n"); + if (!verifSelection()) + break; } if (trouve == 0) printf("Cet ville n'a pas d'IUT\n");