diff --git a/Msae.c b/Msae.c index 610356b..08814cd 100644 --- a/Msae.c +++ b/Msae.c @@ -142,69 +142,65 @@ ListeDept rechercherDept(ListeDept lDept, char dept[], int *trouve) //#################### fonction mise à jour ############################ -/*void miseAJourPlaces(VilleIUT *tiut[], int tLog) -{ - int places; - char ville[31], dept[31], choix; - ListeDept l; - printf("Dans quelle ville se situe le département concerné ?\nSaisie : "); - scanf("%s%*c", ville); - printf("\n"); - pos = rechercheIUT(tiut, tLog, ville, &trouve); - while(trouve == 0) - { - printf("Cette ville n'existe pas, veuillez re-saisir : "); - scanf("%s%*c", ville); - printf("\n"); - pos = rechercheIUT(tiut, tLog, ville, &trouve); - } - l = tiut[pos]->lDept; - printf("Quel département souhaitez-vous mettre à jour ?\nSaisie : "); - scanf("%s%*c", dept); - printf("\n"); - l = rechercherDept(l, dept, &trouve); - while(trouve == 0) - { - printf("Ce département n'existe pas, veuillez-resaisir : "); - scanf("%s%*c", dept); - printf("\n"); - l = rechercherDept(l, dept, &trouve); - } - printf("Vous avez sélectionné le département %s dans la ville de %s.\nSouhaitez-vous continuez ? (O/N)\nSaisie : ", dept, ville); - scanf("%c%*c", &choix); - printf("\n"); - if(choix == 'N') - { - return; - } - printf("Il y a actuellement %d places.\nQuel est le nouveau nombre de places ?\nSaisie : ", l->d.nbP); - scanf("%d%*c", &places); - printf("\nVous avez saisie %d places, veuillez confirmez (O/N)\nSaisie : ", places); - scanf("%c%*c", &choix); - printf("\n"); - if(choix == 'O') - { - l->d.nbP = places; - printf("La mise à jour a bien été effectuée.\n"); - } - return; -}*/ - void miseAJourNomDept(Departement d,ListeDept l) { int trouve; char nomDept[31],choix='n'; system("clear"); afficherDep(d); - while(choix!='o') + while(choix!='o' || choix!='O') { - printf("\n\nQuel est le nouveau nom du département?\n"); + printf("\nQuel est le nouveau nom du département?\n"); fgets(nomDept,31,stdin); nomDept[strlen(nomDept)-1]='\0'; rechercherDept(l,nomDept,&trouve); if(trouve==1) + { + printf("Nom de département déjà.\n"); + return; + } + printf("Êtes-vous sûr de remplacer le nom du département par %s?(o/n)\t",nomDept); + scanf("%c%*c",&choix); } + strcpy(d.dept,nomDept); + afficherDep(d); + clearpage(); +} +void miseAJourResp(Departement d) +{ + char resp[31],choix='n'; + system("clear"); + afficherDep(d); + while(choix!='o' || choix!='O') + { + printf("\nQuel est le nouveau nom du responsable ?\t"); + fgets(resp,31,stdin); + resp[strlen(resp)-1]='\0'; + printf("Êtes-vous sûr de remplacer le nom du responsable par %s?(o/n)\t",resp); + scanf("%c%*c",&choix); + } + strcpy(d.respAd,resp); + afficherDep(d); + clearpage(); +} + +void miseAJourPlaces(Departement d) +{ + int places; + char choix='n'; + system("clear"); + afficherDep(d); + while(choix!='o' || choix!='O') + { + printf("Quel est le nouveau nombre de place ?\t"); + scanf("%d%*c",&places); + printf("Êtes-vous sûr de passer les places en première année de %d à %d ?(o/n)\t",d.nbP,places); + scanf("%c",&choix); + } + d.nbP=places; + afficherDep(d); + clearpage(); } void miseAJourGlobale(VilleIUT *tiut[], int tLog) @@ -214,7 +210,7 @@ void miseAJourGlobale(VilleIUT *tiut[], int tLog) MaillonDept *m; Departement d; printf("Dans quelle ville voulez-vous faire des mises à jour?\t"); - scanf("%s",ville); + scanf("%s%*c",ville); pos=rechercheIUT(tiut,tLog,ville,&trouve); if(trouve!=1) { @@ -224,7 +220,7 @@ void miseAJourGlobale(VilleIUT *tiut[], int tLog) } afficherVilleDep(*tiut[pos]); printf("Quel département de %s voulez-vous modifier?\t",ville); - scanf("%s",dept); + scanf("%s%*c",dept); m=rechercherDept(tiut[pos]->lDept,dept,&trouve); d=m->d; if(trouve!=1) @@ -240,7 +236,7 @@ void miseAJourGlobale(VilleIUT *tiut[], int tLog) printf("################### Menu des mises à jour ###################\n"); printf("\n\t1.Mise à jour du nom du département\n\t2.Mise à jour des places du département\n\t3.Mise à jour du responsable du département\n\t9.Quitter\n\n"); printf("\tSaisie:\t"); - scanf("%d",&choix); + scanf("%d%*c",&choix); if(choix==1) { miseAJourNomDept(d,tiut[pos]->lDept);