From 8d53b985248dbd1404fc65eccab9abbbbd0df896 Mon Sep 17 00:00:00 2001 From: allaurent13 Date: Thu, 12 Jan 2023 18:36:44 +0000 Subject: [PATCH] =?UTF-8?q?j'ai=20continu=C3=A9=20de=20dev=20la=20fonction?= =?UTF-8?q?=20modif=20et=20j'ai=20juste=20changer=20un=20truc=20dans=20ton?= =?UTF-8?q?=20menu=20pour=20que=20=C3=A7a=20aille=20avec=20le=20reste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SAE.c | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- SAE.h | 6 +- SAEl.c | 3 +- 3 files changed, 224 insertions(+), 8 deletions(-) diff --git a/SAE.c b/SAE.c index 0567f72..062adb3 100644 --- a/SAE.c +++ b/SAE.c @@ -97,7 +97,8 @@ int menuAdminAffiche(void) { int choix; printf("####################################################\n"); - printf("\t\tMenu Administrateur\n\n"); + printf("\t\t|Menu Administrateur|\n\n"); + printf("\t\t---------------------\n\n"); printf("1 - Mise à jour nombre de Places d'un Département d'un IUT\n"); printf("2 - Création d'un département dans un IUT\n"); printf("3 - Suppression d'un département dans un IUT\n"); @@ -810,7 +811,7 @@ ListeCandid traiterCandidIUT(ListeCandid l, FILE *flot) fscanf(flot,"%s",ville); fscanf(flot, "%d", &nbDept); printf("%s |%d|\n", ville, nbDept); - tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*(nbDept + 5)); + tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*(nbDept + 10)); if(tDept == NULL) { printf("Pb malloc candidIUt\n"); @@ -1008,9 +1009,219 @@ void creationCandid(Candidat **tab, int *nbEle, int *tailleP) return; } -void modifCandid(Candidat **tab, int nbEle) +int menuCandid(void) { - Candidat c; - printf("en construction"); - return; + int choix; + printf("####################################################\n"); + printf("\t\t|Menu Candidature|\n"); + printf("\t\t------------------\n\n"); + printf("1 - Créer une Candidature\n"); + printf("2 - Supprimer une Candidature\n"); + printf("3 - Modifier une Candidature\n"); + printf("4 - Afficher une Candidature\n"); + printf("5 - Afficher toute les Candidatures\n"); + printf("\n\n9 - Connexion mode Administrateur\n"); + printf("\n\n10 - Quitter\n"); + printf("####################################################\n"); + printf("\nSelection : "); + scanf("%d",&choix); + return choix; +} + +void gestionCandid(VilleIUT **tiut, int nbIUT, Candidat **tcandid, int *nbCandid, int *taillePCandid) +{ + int choix; + while(1) + { + choix = menuCandid(); + system("clear"); + switch(choix) { + case 1: + creationCandid(tcandid, nbCandid, taillePCandid); + system("clear"); + break; + case 2: + suppressionCandid(tab, nbCandid); + system("clear"); + break; + case 3: + modifCandid(tiut, nbEle); + system("clear"); + break; + case 4: + AffichageNbplaceDeptVille(tiut, nbEle); + clearpage(); + break; + case 5: + //modif candid; + clearpage(); + break; + case 9: + choix = gestionMenuAdmin(tiut, nbEle); + if (choix == -1) + if (verifQuit()) return; + break; + case 10: + if (verifQuit()) return; + break; + } + + } +} + +int menuGestionCandid(void) +{ + int choix; + printf("####################################################\n"); + printf("\t\t|Gestion Candidature|\n"); + printf("\t\t---------------------\n\n"); + printf("1 - Ajouter un voeux\n"); + printf("2 - Supprimer un voeux\n"); + printf("\n\n9 - Retour Menu Candidature\n"); + printf("####################################################\n"); + printf("\nSelection : "); + scanf("%d",&choix); + return choix; +} + +ListeCandid recherchecandidIUT(ListeCandid l, char code[]) +{ + if (l == NULL) + return NULL; + if ((strcmp(code,l->iutCandid)) < 0) + return NULL; + if (strcmp(code,l->iutCandid)==0) + return l; + return recherchecandidIUT(l->suiv, code); +} + +int recherchecandidDept(ChoixDept **tab,int nbEle, char code[],int *trouve) +{ + int i=0; + while(i < nbEle) + { + if ((strcmp(code,tab[i]->departement)) < 0) + { + *trouve = 0; + return -1; + } + if (strcmp(code,tab[i]->departement)==0) + { + *trouve = 1; + return i; + } + } + *trouve = 0; + return -1; + +} + +ChoixDept RempTabCandid(char dept[],int deciCandid ,int deciDept) +{ + ChoixDept d; + strcpy(d.departement, dept); + d.decisionDept = deciDept; + d.decisionCandid = deciCandid; + return d; + +} + +void ajouterDept(Candidat **tcandid, int nbCandid, VilleIUT **tiut, int nbIUT, int iCandid) +{ + char ville[30], departement[30]; + int pos,irech, trouve; + MaillonCandid *aux; + ChoixDept **tDept; + while(1) + { + printf("Dans quel IUT voulez vous candidater : "); + scanf("%s%*c", ville); + pos = rechVille(tiut, nbIUT, ville, &trouve); + if (trouve == 0) + printf("Erreur ! IUT non référencé\n"); + if(trouve == 1) + { + while(1) + { + printf("Dans quel Département voulez-vous candidater : "); + scanf("%s%*c", departement); + pos = recherchecandidDept(tiut[pos]->idDept, departement) + if (trouve == 0) + printf("Erreur ! Département non référencé\n"); + if (trouve == 1) + { + aux = recherchecandidIUT(tcandid[iCandid]->idCandIUT, ville) == NULL) + { + tDept = (ChoixDept **)malloc(sizeof(ChoixDept *)*(nbDept + 5)); + if(tDept == NULL) + { + printf("Pb malloc candidIUt\n"); + exit(1); + } + *(tDept[0]) = RempTabCandid(departement, 0, 0); + tcandid[iCandid]->idCandIUT = insererCandid(tcandid[iCandid]->idCandIUT, ville, tDept, 1); + } + else + { + irech = recherchecandidDept(tcandid[iCandid]->idCandIUT->tabDept, tcandid[iCandid]->nbChoix, departement, &trouve); + if (trouve == 0) + { + *(tcandid[iCandid]->idCandIUT->tabDept[tcandid[iCandid]->idCandIUT->nbChoix]) = RempTabCandid(departement, 0, 0); + tcandid[iCandid]->idCandIUT->nbChoix = tcandid[iCandid]->idCandIUT->nbChoix + 1; + printf("Candidature validée !\n"); + } + else + printf("vous avez déjà postuler au département %s de cette %s", departement, ville); + } + } + printf("saisie Département\n") + if(verifSelection()) + break + } + } + printf("Saisie IUT\n") + if(!verifSelection()) + break; + } +} + +void supprimerCandidDept(Candidat **tcandid, int nbCandid, VilleIUT **tiut, int nbIUT, int iCandid) +{ + char ville[30], departement[30]; + int pos, trouve; + MaillonCandid *aux; + while(1) + { + printf("Dans quel IUT voulez-vous supprimer votre candidature : "); + scanf("%s%*c", ville); + aux = rechCandidIUT(tcandid[iCandid]->idCandIUT, ville); + if(aux== NULL) + printf("Aucun voeux formuler dans cette IUT\n"); + else + while(1) + { + printf("Dans quel Département voulez-vous supprimer votre candidature\n"); + scanf("%s%*c", departement); + pos = recherchecandidDept(aux->tabDept, aux->nbChoix, departement, &trouve); + } + } + +} + +void modifCandid(Candidat **tcandid, int nbCandid, VilleIUT **tiut, int nbIUT, int iCandid) +{ + int choix, iCandid; + while(1) + { + choix = menuGestionCandid(); + system("clear"); + switch(choix){ + case 1: + ajouterDept(tcandid, nbCandid, tiut, nbIUT, iCandid); + case 2: + supprimerCandidDept(tcandid, nbCandid, tiut, nbIUT, iCandid); + case 9: + return; + } + } } \ No newline at end of file diff --git a/SAE.h b/SAE.h index dbedf48..e2800d4 100644 --- a/SAE.h +++ b/SAE.h @@ -182,4 +182,8 @@ Candidat **reallocTCandid(Candidat **tab, int *tailleP); void creationCandid(Candidat **tab, int *nbEle, int *tailleP); -void modifCandid(Candidat **tab, int nbEle); \ No newline at end of file +int menuCandid(void); + +void gestionCandid(VilleIUT **tiut, int nbIUT, Candidat **tcandid, int *nbCandid, int *taillePCandid); + +int menuGestionCandid(void); \ No newline at end of file diff --git a/SAEl.c b/SAEl.c index 2acc0c6..6ce8ce0 100644 --- a/SAEl.c +++ b/SAEl.c @@ -166,7 +166,8 @@ int verifChefDepart(VilleIUT** tiut, int nbEle, char* dept, char* ville, char* n int menuResponsableAffiche(void) { int choix; printf("####################################################\n"); - printf("\t\tMenu Responsable\n\n"); + printf("\t\t|Menu Responsable|\n\n"); + printf("\t\t------------------\n\n"); printf("1 - Traiter les candidatures (output dans des fichiers)\n"); printf("\n\n9 - Repasser en mode Utilisateur"); printf("\n\n10 - Quitter\n");