From 04697876ff88a429ac9fa3ee02beff696db08ee4 Mon Sep 17 00:00:00 2001 From: Alexis LAURENT Date: Fri, 23 Dec 2022 11:37:45 +0100 Subject: [PATCH] =?UTF-8?q?cr=C3=A9ation=20des=20fonction=20d'admin=20et?= =?UTF-8?q?=20modification=20du=20fichier=20SAEl.c=20fonction=20recherche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SAE.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++------- SAEl.c | 18 +++++----- 2 files changed, 108 insertions(+), 21 deletions(-) diff --git a/SAE.c b/SAE.c index 0d45676..9392128 100644 --- a/SAE.c +++ b/SAE.c @@ -35,7 +35,8 @@ bool verifQuit(void) if (strcmp(choix,"oui")==0) return true; if (strcmp(choix,"non")==0) - return false; + return false; + printf("Erreur de sélection ! Veillez réessayer \n") } } @@ -49,10 +50,25 @@ bool verifSelection(void) if (strcmp(choix,"oui")==0) return true; if (strcmp(choix,"non")==0) - return false; + return false; + printf("Erreur de sélection ! Veillez réessayer \n") } } +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) + return true; + if (strcmp(choix,"non")==0) + return false; + printf("Erreur de sélection ! Veillez réessayer \n") + +} + int menuUtilisateurAffiche(void) { int choix; @@ -267,7 +283,7 @@ void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle) } } - else printf("Cette Ville n'as pas d'IUT (exit -> pour quitter)\n"); + else printf("Cette Ville n'as pas d'IUT\n"); } free(aux); } @@ -300,19 +316,24 @@ void AffichageDeptVille(VilleIUT **tiut, int nbEle) ListeDept *aux; aux =(ListeDept *)malloc(sizeof(ListeDept)); char code[30]; - int pos, nbocc = 0; + int pos = 0, nbocc = 0; while(1) { - printf("IUT : "); + printf("département : "); scanf("%s",code); - aux = tiut[pos]->idDept; printf("\nIUT ayant un département %s : \n",code); for(pos = 0; pos < nbEle; pos++) { - if(strcmp(aux->departement, code)==0) + aux = tiut[pos]->idDept; + while(aux != NULL) { - affichageListeDept(aux) - nbocc = nbocc + 1; + if(strcmp(aux->departement, code)==0) + { + affichageListeDept(aux) + nbocc = nbocc + 1; + break; + } + aux = aux->suiv; } } if (nbocc == 0) @@ -333,10 +354,9 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle) printf("IUT : "); scanf("%s",code); pos = rechVille(tiut, nbEle, code,&trouve); - aux = tiut[pos]->idDept; if (trouve == 1) - { + aux = tiut[pos]->idDept; while(1) { printf("Département : "); @@ -347,8 +367,8 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle) { printf("Ancien nombre de places : %d",tiut[pos]->idDept->nbPers); printf("Nouveau nombre de places : ", nouvNbPlace); - scanf("%d", &nouvNbPlace) - tiut[pos]->idDept->nbPers = nouvNbPlace + scanf("%d", &nouvNbPlace); + tiut[pos]->idDept->nbPers = nouvNbPlace; printf("Mise à jour effectuer avec succès !"); break; } @@ -363,6 +383,71 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle) } } + free(aux); +} + +void creationDept(VilleIUT **tiut, int nbEle) +{ + char code[30], nom[30]; + int trouve, pos, nbP; + while(1) + { + printf("Dans quel IUT voulez-vous créer un département : "); + scanf("%s", code); + pos = rechVille(tiut, nbEle, code, &trouve); + if (trouve == 1) + { + while(1) + { + printf("Nom du Département : "); + scanf("%s", code); + if (recherche(tiut[pos]->idDept, code)) + printf("Département déjà existant"); + if (!recherche(tiut[pos]->idDept, code)) + printf("Nom du Responsable du Département de %s : ",code); + fgets(nom,30,stdin); + nom[strlen(nom)-1] = "\0"; + printf("Nombre de place du Département %s : ",code); + scanf("%d", nbP); + tiut[pos]->idDept = inserer(tiut[pos]->idDept,code,nom,nbP) + printf("insertion du département %s effectuer \n", code); + if (!verifSelection()) + break; + } + } + if (trouve == 0) + printf("Cet ville n'a pas d'IUT\n"); + if(!verifSelection()) + break; + + } + +} + +void suppressionDept(VilleIUT **tiut, int nbEle) +{ + char code[30]; + int trouve, pos, nbP; + while(1) + { + printf("Dans quel IUT voulez-vous supprimer un département : "); + scanf("%s", code); + pos = rechVille(tiut, nbEle, code, &trouve); + if (trouve == 1) + { + printf("Nom du Département : "); + scanf("%s", code); + if (recherche(tiut[pos]->idDept, code)) + if (confirmationSup()) + tiut->idDept = supprimer(tiut->idDept, code); + if (!recherche(tiut[pos]->idDept, code)) + printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville); + if (!verifSelection()) + break; + + } + + } } void clearpage(void) diff --git a/SAEl.c b/SAEl.c index 2d9dd9f..bb1ebca 100644 --- a/SAEl.c +++ b/SAEl.c @@ -181,14 +181,16 @@ ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP) // return cpt; // } -// bool recherche(ListeDept l, char code[], int *pos) -// { -// if (l == NULL) -// return false; -// if (strcmp(l->departement, code)==0) -// return true; -// return recherche(l->suiv, x); -// } +bool recherche(ListeDept l, char code[]) +{ + if (l == NULL) + return false; + if ((strcmp(code,l->departement)) < 0) + return false; + if (strcmp(code,l->departement)==0) + return true; + return recherche(l->suiv, x); +} // ListeDept ajouterEnQueue(ListeDept l, int x) // {