diff --git a/SAE.c b/SAE.c index eb01f34..2d12b61 100644 --- a/SAE.c +++ b/SAE.c @@ -1,4 +1,174 @@ #include "SAE.h" +bool motdepasseVerif(void) +{ + char mdp[10]; + int i=4; + while(i > 0) + { + printf("entrer le mot de passe administrateur : "); + system("stty -echo"); + scanf("%s",mdp); + system("stty echo"); + if (strcmp(mdp,"123456") == 0) + { + system("clear"); + return true; + } + system("clear"); + printf("\n! mots de passe faux !\n"); + i = i - 1; + printf("\n! il vous reste %d tentative/s !\n",i); + } + printf("Vous avez effectuer trop de tentative retour au menu Utilisateur !\n"); + return false; +} +bool verifQuit(void) +{ + char choix[4]; + while(1) + { + system("clear"); + printf("Êtes-vous sûr de vouloir quitter ? (oui|non) : "); + scanf("%s",choix); + if (strcmp(choix,"oui")==0) + return true; + if (strcmp(choix,"non")==0) + return false; + } +} +int menuUtilisateurAffiche(void) +{ + int choix; + printf("####################################################\n"); + printf("\t\t|Menu Utilisateur|\n"); + printf("\t\t------------------\n\n"); + printf("1 - Consultation des IUT par ville\n"); + printf("2 - Consultation des département global par IUT\n"); + printf("3 - Consultation du nombre de places pour un Département par IUT\n"); + printf("4 - Consultation du nombre de places pour un Département dans un IUT\n"); + printf("5 - Consultation des départements dans un IUT\n"); + printf("6 - Consultation de tout les IUT ayant un département choisi\n"); + printf("\n\n9 - Connexion mode Administrateur\n"); + printf("\n\n10 - Quitter\n"); + printf("####################################################\n"); + printf("\nSelection : "); + scanf("%d",&choix); + return choix; +} + +int menuAdminAffiche(void) +{ + int choix; + printf("####################################################\n"); + printf("\t\tMenu Administrateur\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'u département dans un IUT\n"); + printf("4 - Gestion des phases de candidature\n"); + printf("5 - Changement d'un responsable de département\n"); + printf("\n\n9 - Repasser en mode Utilisateur"); + printf("\n\n10 - Quitter\n"); + printf("####################################################\n"); + printf("\nSelection : "); + scanf("%d",&choix); + return choix; +} + +void gestionMenu(void) +{ + int choix; + while(1) + { + choix = menuUtilisateurAffiche(); + system("clear"); + switch(choix) { + case 1: + //mettre a jour le nombre de places d'un département d'un iut + clearpage(); + break; + case 2: + //créer un département dans un iut + clearpage(); + break; + case 3: + //supprimer un département dans un iut + clearpage(); + break; + case 4: + //gérer les phases de candidature + clearpage(); + break; + case 5: + //affichage de tout les département d'un iut + clearpage(); + break; + case 9: + choix = gestionMenuAdmin(); + if (choix == -1) + return; + break; + case 10: + if (verifQuit()) return; + break; + } + + } +} + +int gestionMenuAdmin(void) +{ + int choix; + if (!motdepasseVerif()) + return 0; + while(1) + { + choix = menuAdminAffiche(); + system("clear"); + switch(choix){ + case 1: + //fonction recherche et affichage iut dans une ville donnée + clearpage(); + break; + case 2: + //affichage de tout les département par iut + clearpage(); + break; + case 3: + //affichage du nombres de places par département des iut + clearpage(); + break; + case 4: + //affichage du nombres de places par département d'un iut + clearpage(); + break; + case 5: + //affichage de tout les département d'un iut + clearpage(); + break; + case 6: + //affichage de tout les iut ayant un département choisi + clearpage(); + break; + case 9: + return 0; + case 10: + return -1; + } + } +} + +void global(void) +{ + gestionMenu(); +} + +void clearpage(void) +{ + char entre; + printf("\nappuyé sur la touche [ENTREE] pour continuer"); + scanf("%*c%c", &entre); + system("clear"); +} \ No newline at end of file diff --git a/SAE.h b/SAE.h index 9b9159b..ea04897 100644 --- a/SAE.h +++ b/SAE.h @@ -1,20 +1,35 @@ #include #include #include -#include +#include -typedef struct -{ - char ville[30]; - MaillonDept *idDept; -}VilleIUT; typedef struct maillon { char departement[30]; int nbPers; char responsable[30]; - maillon *suiv; + struct maillon *suiv; }MaillonDept; +typedef MaillonDept* Liste; + +typedef struct +{ + char ville[30]; + MaillonDept *idDept; +}VilleIUT; + +bool motdepasseVerif(void); + +bool verifQuit(void); + +int menuUtilisateurAffiche(void); + +int menuAdminAffiche(void); + +void gestionMenu(void); + +int gestionMenuAdmin(void); +void clearpage(void);