diff --git a/Commun.c b/Commun.c index 044e57b..0549d38 100644 --- a/Commun.c +++ b/Commun.c @@ -179,6 +179,27 @@ void afficherPlace(Departement d) /* Permet d'afficher le nombre de place dispon printf("\nPour ce département il y a %d places en 1ère année \n\n",d.nbP); } +void afficheDeptDesIUT(VilleIUT *tiut[], int tLog) +{ + char dept[31]; + int i,trouve; + system("clear"); + printf("######################################################################################################################\n"); + printf("Quel département cherchez-vous dans les IUT ?\t"); + scanf("%s%*c",dept); + printf("\n\n\t\tCe département est présent dans ces IUT :\n"); + printf("----------------------------------------------------------------------------------------------------\n"); + for(i=0;ilDept,dept,&trouve); + if (trouve==1) + { + printf("|%s",tiut[i]->nom); + } + } + printf("|\n"); + clearpage(); +} diff --git a/Commun.h b/Commun.h index 73f7664..db27d37 100644 --- a/Commun.h +++ b/Commun.h @@ -36,6 +36,7 @@ void afficherDep(Departement d); void afficherVille(VilleIUT v); void afficherTIUT(VilleIUT *tiut[], int tLog); void afficherVilleDep(VilleIUT v); +void afficheDeptDesIUT(VilleIUT *tiut[], int tLog); /* Fonctions de Listes */ diff --git a/Msae.c b/Msae.c index 6e66e77..9f14bc8 100644 --- a/Msae.c +++ b/Msae.c @@ -218,6 +218,30 @@ void afficherDep(Departement d) printf("|----------------------------------------------------------------------------|\n"); } + +void afficheDeptDesIUT(VilleIUT *tiut[], int tLog) +{ + char dept[31]; + int i,trouve; + system("clear"); + printf("######################################################################################################################\n"); + printf("Quel département cherchez-vous dans les IUT ?\t"); + scanf("%s%*c",dept); + printf("\n\n\t\tCe département est présent dans ces IUT :\n"); + printf("----------------------------------------------------------------------------------------------------\n"); + for(i=0;ilDept,dept,&trouve); + if (trouve==1) + { + printf("|%s",tiut[i]->nom); + } + } + printf("|\n"); + clearpage(); +} + + //################# fonctions recherche ######################### @@ -415,3 +439,155 @@ void miseAJourGlobale(VilleIUT *tiut[], int tLog) clearpage(); afficherDep(d); } + + +// ######################## fonction menus ############################## + +// void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax) /* Affiche un menu de choix adaptés pour un administrateur et appelle les fonctions en conséquence */ +// { +// int select, pos; +// int trouve; +// char ville[31], choix; +// 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 Effectuer une mise à jour d'un département d'un IUT |\n"); +// printf("| 6 Insérer un nouvel IUT |\n"); +// printf("| 7 Supprimer un IUT de la liste |\n"); +// printf("| 8 Lancer/Arrêter la phase de candidature |\n"); +// printf("| 9 Quitter |\n"); +// printf("|--------------------------------------------------------|\n\n"); +// printf("Saisie : "); /* Choix de l'administrateur */ +// scanf("%d%*c",&select); +// while(select != 9) /* Tant que l'utilisateur ne saisie pas 9, le menu réapparait après que la fonction appelée est terminée */ +// { +// system("clear"); +// if(select == 1) +// { +// afficherTIUT(tiut, *tLog); +// } +// if(select == 2) +// { +// printf("Pour quelle ville souhaitez-vous afficher les départements ?\nSaisie : "); /* Demande une ville à afficher */ +// scanf("%s%*c", ville); +// printf("\n"); +// pos = rechercheIUT(tiut, *tLog, ville, &trouve); /* Vérifie que la ville existe */ +// while(trouve == 0) /* Si elle n'existe pas, on effectue une saisie contrôlée */ +// { +// printf("Cette ville n'existe pas, veuillez re-sasisir : "); +// scanf("%s%*c", ville); +// pos = rechercheIUT(tiut, *tLog, ville , &trouve); +// printf("\n"); +// } +// afficherVilleDep(*tiut[pos]); /* Affiche ensuite la ville */ +// } +// if(select == 3) +// { +// creerDept(tiut, *tLog); +// } +// if(select == 4) +// { +// retirerDept(tiut, *tLog); +// } +// if(select == 5) +// { +// miseAJourGlobale(tiut, tLog); +// } +// if(select == 6) +// { +// printf("Quel est le nom de la ville à insérer ?\nSaisie : "); /* Demande le nom de la ville à insérer */ +// scanf("%s%*c", ville); +// printf("\n"); +// pos = rechercheIUT(tiut, *tLog, ville, &trouve); /* Vérifie que la ville existe */ +// if(trouve == 1) /* Si elle existe, affiche un message d'erreur */ +// { +// printf("Erreur, cette ville existe déjà !\n"); +// } +// else /* Sinon, appelle la fonction d'insertion */ +// { +// insererVille(tiut, ville, tLog, tMax, pos); +// } +// } +// if(select == 7) +// { +// printf("Quel est le nom de la ville à supprimer ?\nSaisie : "); /* Demande le nom de la ville à supprimer */ +// scanf("%s%*c", ville); +// printf("\n"); +// pos = rechercheIUT(tiut, *tLog, ville, &trouve); /* Vérifie qu'elle existe */ +// if(trouve == 0) /* Si elle n'existe pas, affiche un message d'erreur */ +// { +// printf("Erreur, cette ville n'existe pas !\n"); +// } +// else /* Sinon, demande confirmation, si confirmé, supprime la ville, sinon annule la suppression */ +// { +// printf("Êtes-vous sur de vouloir supprimer cette ville ? (O/n)\nSaisie : "); /* Demande confirmation de la suppression */ +// scanf("%c%*c", &choix); +// printf("\n"); +// if(choix == 'N' || choix == 'n') /* Si le choix et non, annule la supression */ +// { +// printf("Suppression annulée\n"); +// } +// else +// { +// supprimerVille(tiut, ville, tLog, pos); +// } +// } +// } +// 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 Effectuer une mise à jour d'un département d'un IUT |\n"); +// printf("| 6 Insérer un nouvel IUT |\n"); +// printf("| 7 Supprimer un IUT de la liste |\n"); +// printf("| 8 Lancer/Arrêter la phase de candidature |\n"); +// printf("| 9 Quitter |\n"); +// printf("|--------------------------------------------------------|\n\n"); +// printf("Saisie : "); +// scanf("%d%*c",&select); +// } +// } + + + + + +// ###################################################################### Globale ################################################################################################################## + +// void globale(void) +// { +// int tLog, retour; +// VilleIUT *tiut[100]; +// if(tiut == NULL) +// { +// printf("Problème d'allocation mémoire du tableau tiut\n"); +// exit(1); +// } +// tLog = chargement(tiut,100); +// if(tLog < 0) +// { +// printf("Le programme ne peut pas fonctionner\n"); +// exit(1); +// } +// retour = login(); +// while(retour != -1) +// { +// if(retour == 1) +// { +// menuAdmin(tiut, &tLog, 100); +// } +// if(retour == 0) +// { +// menuCandidat(tiut, &tLog, 100); +// } +// retour = login(); +// } +// } \ No newline at end of file diff --git a/Msae.h b/Msae.h index 5c69588..17925ea 100644 --- a/Msae.h +++ b/Msae.h @@ -40,6 +40,7 @@ void afficherDep(Departement d); void afficherVilleDep(VilleIUT v); void afficherTIUT(VilleIUT *tiut[], int tLog); void afficherVille(VilleIUT v); +void afficheDeptDesIUT(VilleIUT *tiut[], int tLog); //########## fonction de mise à jour ########### void miseAJourGlobale(VilleIUT *tiut[], int tLog); diff --git a/Mtest.c b/Mtest.c index c7152d2..8fe3552 100644 --- a/Mtest.c +++ b/Mtest.c @@ -2,10 +2,14 @@ int main(void) { + VilleIUT *tiut[100]; int tLog; - VilleIUT *tiut[50]; - tLog=chargement(tiut,50); - afficherTIUT(tiut,tLog); - miseAJourGlobale(tiut,tLog); + tLog = chargement(tiut,100); + if(tLog < 0) + { + printf("Le programme ne peut pas fonctionner\n"); + exit(1); + } + afficheDeptDesIUT(tiut,tLog); return 0; }