diff --git a/Commun.c b/Commun.c index 133b57c..54b7902 100644 --- a/Commun.c +++ b/Commun.c @@ -87,15 +87,111 @@ bool vide(ListeDept lDept) return l->v; }*/ -bool rechercherDept(ListeDept lDept, Departement d) +ListeDept rechercherDept(ListeDept lDept, char dept[], int *trouve) { if(vide(lDept)) - return false; - if(strcmp(d.dept, lDept->d.dept) < 0) - return false; - if(strcmp(d.dept,lDept->d.dept) == 0) - return true; - return rechercherDept(lDept->suiv, d); + { + *trouve = 0; + return lDept; + } + if(strcmp(dept, lDept->d.dept) < 0) + { + trouve = 0; + return lDept; + } + if(strcmp(dept,lDept->d.dept) == 0) + { + *trouve = 1; + return lDept; + } + return rechercherDept(lDept->suiv, dept, trouve); +} + +void miseAJourPlaces(VilleIUT *tiut[], int tLog) +{ + int trouve, pos, 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 afficherPlace(Departement d) +{ + printf("\nPour ce département il y a %d places en 1ère année \n\n",d.nbP); +} + +void creerDept(VilleIUT *tiut[],int tLog) +{ + Departement d; + int pos, trouve; + char ville[31]; + printf("Dans quelle ville souhaitez-vous créer un nouveau département ?\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); + } + printf("Quel est le nom du département à insérer ?\nSaisie : "); + scanf("%s%*c", d.dept); + rechercherDept(tiut[pos]->lDept, d.dept, &trouve); + if(trouve == 1) + { + printf("Erreur, le département %s existe déjà dans cet IUT\n", d.dept); + return; + } + printf("Combien de place y a-t-il pour dans ce département ?\nSaisie : "); + scanf("%d%*c", &d.nbP); + printf("\n\n"); + printf("Quel est le nom du responsable du département ?\nSaisie : "); + fgets(d.respAd, 31, stdin); + afficherDep(d); + tiut[pos]->lDept = insérerDept(tiut[pos]->lDept, d); + return; } @@ -104,29 +200,35 @@ int login(void) int i = 3; char id, mdp[31] = "mettez20svp", mdpatrouve[31]; system("clear"); - printf("################################################################\n\tBienvenue!\n\n\n\tSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\t"); + printf("\t################################ Bienvenue! ################################\nSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur ? (U/A)\nSaisie : "); scanf("%c%*c",&id); if(id == 'q') + { return -1; + } while(id != 'A' && id != 'a' && id != 'U' && id != 'u') { system("clear"); - printf("################################################################\n\tMauvaise saisie (q pour quitter)\n\n\n\tSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\t"); + printf("\t#################### Mauvaise saisie ('q' pour quitter) ####################\nSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur? (U/A)\nSaisie : "); scanf("%c%*c",&id); if(id == 'q') + { return -1; + } } if(id == 'A' || id == 'a') { while(i != 0) { - printf("\n\n\n\tMot de passe :\t"); + printf("\n\nMot de passe : "); system("stty -echo"); fgets(mdpatrouve, 31, stdin); mdpatrouve[strlen(mdpatrouve) - 1] = '\0'; + printf("\n"); if(strcmp(mdpatrouve, mdp) == 0 ) { system("stty echo"); + system("clear"); return 1; } else @@ -138,23 +240,91 @@ int login(void) } return -1; } - else return 0; - system("clear"); + else + { + system("clear"); + return 0; + } } void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax) { - int select = 0; + int select = 0, pos; + int trouve; + char ville[31]; + ListeDept l; + printf("_______________________________________________________\n"); + printf("| MENU ADMIN |\n"); + printf("|-----------------------------------------------------|\n"); + printf("| 1 Afficher les villes possédant un IUT |\n"); + printf("| 2 Afficher les départements d'un IUT |\n"); + printf("| 3 Créer un nouveau département |\n"); + printf("| 4 Supprimer un département |\n"); + printf("| 5 Modifier le nombre de places dans un département |\n"); + printf("| 6 Modifier l'intitulé d'un département |\n"); + printf("| 7 Modifer le nom du responsable d'un département |\n"); + printf("| 8 Lancer/Arrêter la phase de candidature |\n"); + printf("| 9 Quitter |\n"); + printf("|-----------------------------------------------------|\n\n"); + printf("Saisie : "); + scanf("%d",&select); while(select != 9) { system("clear"); - printf("\t AFFICHAGE ADMIN\n\n"); - printf("1\tModifier le nombre de places dans un département\n"); - printf("2\tCréer un nouveau département\n"); - printf("3\tSupprimer un département\n"); - printf("4\tLancer/Arrêter la phase de candidature\n"); - printf("5\tModifer le nom du responsable d'un département\n"); + if(select == 1) + { + afficherTIUT(tiut, *tLog); + } + if(select == 2) + { + printf("Pour quelle ville souhaitez-vous afficher les départements ?\nSaisie : "); + scanf("%s%*c", ville); + printf("\n"); + pos = rechercheIUT(tiut, *tLog, ville, &trouve); + while(trouve == 0) + { + printf("Cette ville n'existe pas, veuillez re-sasisir : "); + scanf("%s%*c", ville); + pos = rechercheIUT(tiut, *tLog, ville , &trouve); + printf("\n"); + } + afficherVilleDep(*tiut[pos]); + } + if(select == 3) + { + creerDept(tiut, *tLog); + } + /*if(select == 4) + { + retirerDept(tiut, tLog); + }*/ + if(select == 5) + { + miseAJourPlaces(tiut, *tLog); + } + /*if(select == 6) + { + miseAJourNomDept(tiut, *tLog); + } + if(select == 7) + { + miseAJourResp(tiut, *tLog); + }*/ + printf("_______________________________________________________\n"); + printf("| MENU ADMIN |\n"); + printf("|-----------------------------------------------------|\n"); + printf("| 1 Afficher les villes possédant un IUT |\n"); + printf("| 2 Afficher les départements d'un IUT |\n"); + printf("| 3 Créer un nouveau département |\n"); + printf("| 4 Supprimer un département |\n"); + printf("| 5 Modifier le nombre de places dans un département |\n"); + printf("| 6 Modifier l'intitulé d'un département |\n"); + printf("| 7 Modifer le nom du responsable d'un département |\n"); + printf("| 8 Lancer/Arrêter la phase de candidature |\n"); + printf("| 9 Quitter |\n"); + printf("|-----------------------------------------------------|\n\n"); + printf("Saisie : "); scanf("%d",&select); } } @@ -165,11 +335,15 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax) while(select != 9) { system("clear"); - printf("\t AFFICHAGE CANDIDAT \n\n"); - printf("1\tRechercher les villes où il y a un IUT\n"); - printf("2\tRechercher chaque département dans les IUT\n"); - printf("3\tNombres de places en 1A\n"); - printf("4\tRechercher un département dans les IUT\n"); + printf("_____________________________________________________\n"); + printf("| AFFICHAGE CANDIDAT |\n\n"); + printf("|---------------------------------------------------|"); + printf("| 1 Afficher les villes où il y a un IUT |\n"); + printf("| 2 Afficher tous les départements dans chaque IUT |\n"); + printf("| 3 Nombres de places en première année |\n"); + printf("| 4 Rechercher un département dans les IUT |\n"); + printf("| 9 Quitter |\n"); + printf("|---------------------------------------------------|"); scanf("%d",&select); } } @@ -183,9 +357,3 @@ void clearpage(void) scanf("%*c%c", &entre); system("clear"); } - - -void afficherPlace(Departement m) -{ - printf("\nPour ce département il y a %d places en 1ère année \n\n",m.nbP); -} \ No newline at end of file diff --git a/Jsae.c b/Jsae.c index faccdf5..f6ca1e3 100644 --- a/Jsae.c +++ b/Jsae.c @@ -72,7 +72,11 @@ int insérerVille(VilleIUT *tiut[], char nomV[], Departement d, int *tLog, int t void afficherDep(Departement d) { - printf("| %-32s\t%3d\t%-32s |\n", d.dept, d.nbP, d.respAd); + printf("_____________________________________________________________________________\n"); + printf("| Département |\n"); + printf("|----------------------------------------------------------------------------|\n"); + printf("| %-32s | %3d | %-32s |\n", d.dept, d.nbP, d.respAd); + printf("|----------------------------------------------------------------------------|\n"); } void afficherVille(VilleIUT v) @@ -85,6 +89,8 @@ void afficherVille(VilleIUT v) void afficherTIUT(VilleIUT *tiut[], int tLog) { int i = 0; + printf("____________________________________\n"); + printf("| Ville |\n"); for(i = 0; i < tLog; i++) { afficherVille(*tiut[i]); @@ -92,21 +98,19 @@ void afficherTIUT(VilleIUT *tiut[], int tLog) printf("\n"); } -void afficherVilleDep(VilleIUT *tiut[], int tLog) +void afficherVilleDep(VilleIUT v) { - MaillonDept *m; - int i = 0; - for(i = 0; i < tLog; i++) + ListeDept l; + printf("_________________________________________________________________________________________________________________\n"); + printf("| Ville | Département |\n"); + printf("|----------------------------------|----------------------------------------------------------------------------|\n"); + l = v.lDept; + while(l != NULL) { - afficherVille(*tiut[i]); - m = tiut[i]->lDept; - while(m != NULL) - { - afficherDep(m->d); - m = m->suiv; - } + printf("| %-32s | %-32s | %3d | %-32s |\n", v.nom, l->d.dept, l->d.nbP, l->d.respAd); + printf("|----------------------------------|----------------------------------------------------------------------------|\n"); + l = l->suiv; } - printf("\n"); } int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve) diff --git a/Jsae.h b/Jsae.h index 0c04747..e8449d2 100644 --- a/Jsae.h +++ b/Jsae.h @@ -31,16 +31,22 @@ ListeDept insérerEntete(ListeDept lDept,Departement d); ListeDept insérerDept(ListeDept lDept, Departement d); ListeDept supprimerEntete(ListeDept lDept); ListeDept supprimerDept(ListeDept lDept, Departement d); +void creerDept(VilleIUT *tiut[],int tLog); +void retirerDept(VilleIUT *tiut[], int *tLog); +void miseAJourNomDept(VilleIUT *tiut[], int tLog); +void miseAJourResp(VilleIUT *tiut[], int tLog); int longueur(ListeDept lDept); bool vide(ListeDept lDept); -bool rechercherDept(ListeDept lDept, Departement d); +ListeDept rechercherDept(ListeDept lDept, char dept[], int *trouve); +void miseAJourPlaces(VilleIUT *tiut[], int tLog); int login(void); void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax); void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax); void clearpage(void); -void afficherPlace(Departement m); +void afficherPlace(Departement d); void afficherDep(Departement d); void afficherVille(VilleIUT v); void afficherTIUT(VilleIUT *tiut[], int tLog); +void afficherVilleDep(VilleIUT v); int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve); void globale(void); \ No newline at end of file