You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
460 lines
13 KiB
460 lines
13 KiB
#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;
|
|
printf("Erreur de sélection ! Veillez réessayer \n")
|
|
}
|
|
}
|
|
|
|
bool verifSelection(void)
|
|
{
|
|
char choix[4];
|
|
while(1)
|
|
{
|
|
printf("Voulez-vous continué la sélection (oui|non) : ");
|
|
scanf("%s",choix);
|
|
if (strcmp(choix,"oui")==0)
|
|
return true;
|
|
if (strcmp(choix,"non")==0)
|
|
return false;
|
|
printf("Erreur de sélection ! Veillez réessayer \n")
|
|
}
|
|
}
|
|
|
|
bool confirmationSup(void)
|
|
{
|
|
char choix[4];
|
|
while(1)
|
|
printf("Êtes-vous sûr de vouloir supprimer/moddifié : ");
|
|
scanf("%s", choix);
|
|
if (strcmp(choix,"oui")==0)
|
|
return true;
|
|
if (strcmp(choix,"non")==0)
|
|
return false;
|
|
printf("Erreur de sélection ! Veillez réessayer \n")
|
|
|
|
}
|
|
|
|
int menuUtilisateurAffiche(void)
|
|
{
|
|
int choix;
|
|
printf("####################################################\n");
|
|
printf("\t\t|Menu Utilisateur|\n");
|
|
printf("\t\t------------------\n\n");
|
|
printf("1 - Consultation des IUT\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'un 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 AffichageVille(VilleIUT **tiut, int nbEle)
|
|
{
|
|
int i;
|
|
printf("\tIUT par ville :");
|
|
for(i=0,i<nbEle;i = i + 1)
|
|
{
|
|
printf("- %s\n",tab[i]->ville);
|
|
}
|
|
}
|
|
|
|
void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle)
|
|
{
|
|
int i;
|
|
printf("\tDépartement par IUT :\n");
|
|
for(i=0,i<nbEle;i = i + 1)
|
|
{
|
|
printf("- %s :\n\t",tiut[i]->ville);
|
|
while(tiut->idDept != NULL)
|
|
{
|
|
printf("|%s|\n",tiut->idDept->departement);
|
|
tiut->idDept = tiut->idDept->suiv;
|
|
}
|
|
}
|
|
}
|
|
|
|
void AffichageNbplaceDept(VilleIUT **tiut, int nbEle)
|
|
{
|
|
int pos;
|
|
for (pos = 0; pos < nbEle; pos++)
|
|
{
|
|
while(tiut[pos]->idDept->suiv != NULL && pos < nbEle)
|
|
{
|
|
printf("%s -> |%s, %d places|\n",tiut[pos]->ville,tiut[pos]->idDept->departement, tiut[pos]->idDept->nbPers);
|
|
tiut[pos]->idDept = tiut[pos]->idDept->suiv;
|
|
}
|
|
}
|
|
}
|
|
|
|
int rechVille(VilleIUT **tiut, int nbEle, char code[], int *trouve)
|
|
{
|
|
int i;
|
|
while(i<nbEle)
|
|
{
|
|
if (strcmp(code,tiut[i]->ville)==0)
|
|
*trouve = 1;
|
|
i = i + 1;
|
|
}
|
|
return i;
|
|
}
|
|
|
|
void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle)
|
|
{
|
|
ListeDept *aux;
|
|
aux =(ListeDept *)malloc(sizeof(ListeDept));
|
|
char code[30];
|
|
int pos,trouve = 0;
|
|
while(1)
|
|
{
|
|
printf("IUT : ");
|
|
scanf("%s",code);
|
|
pos = rechVille(tiut, nbEle, code,&trouve);
|
|
aux = tiut[pos]->idDept;
|
|
if (trouve == 1)
|
|
|
|
{
|
|
while(1)
|
|
{
|
|
printf("Département : ");
|
|
scanf("%s",code);
|
|
trouve = 0;
|
|
while(aux->suiv != NULL)
|
|
{
|
|
if (strcmp(tiut[pos]->idDept->departement, code)==0)
|
|
{
|
|
printf("%s -> |%s, %d places|\n",tiut[pos]->ville,aux->departement, aux->nbPers);
|
|
trouve = 1;
|
|
break;
|
|
}
|
|
aux = aux->suiv;
|
|
}
|
|
if (trouve == 0)
|
|
printf("Département non présent à l'iut de %s",tiut[pos]->ville);
|
|
if(!verifSelection())
|
|
break;
|
|
aux = tiut[pos]->idDept;
|
|
|
|
}
|
|
}
|
|
else printf("Cette Ville n'as pas d'IUT\n");
|
|
}
|
|
free(aux);
|
|
}
|
|
|
|
void AffichageGlobalDepVille(VilleIUT **tiut, int nbEle)
|
|
{
|
|
char code[30];
|
|
int pos,trouve = 0;
|
|
while(1)
|
|
{
|
|
printf("IUT : ");
|
|
scanf("%s",code);
|
|
pos = rechVille(tiut, nbEle, code,&trouve);
|
|
aux = tiut[pos]->idDept;
|
|
if (trouve == 1)
|
|
{
|
|
printf("%s :\n\t",tiut[pos]->ville);
|
|
affichageListeDept(tiut[pos]->idDept);
|
|
}
|
|
if (trouve == 0)
|
|
printf("Département non présent à l'iut de %s",tiut[pos]->ville);
|
|
if(!verifSelection())
|
|
break;
|
|
}
|
|
free(aux)
|
|
}
|
|
|
|
void AffichageDeptVille(VilleIUT **tiut, int nbEle)
|
|
{
|
|
ListeDept *aux;
|
|
aux =(ListeDept *)malloc(sizeof(ListeDept));
|
|
char code[30];
|
|
int pos = 0, nbocc = 0;
|
|
while(1)
|
|
{
|
|
printf("département : ");
|
|
scanf("%s",code);
|
|
printf("\nIUT ayant un département %s : \n",code);
|
|
for(pos = 0; pos < nbEle; pos++)
|
|
{
|
|
aux = tiut[pos]->idDept;
|
|
while(aux != NULL)
|
|
{
|
|
if(strcmp(aux->departement, code)==0)
|
|
{
|
|
affichageListeDept(aux)
|
|
nbocc = nbocc + 1;
|
|
break;
|
|
}
|
|
aux = aux->suiv;
|
|
}
|
|
}
|
|
if (nbocc == 0)
|
|
printf("aucun département %s est présent en France\n", code);
|
|
if(!verifSelection())
|
|
break;
|
|
}
|
|
}
|
|
|
|
void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
|
|
{
|
|
ListeDept *aux;
|
|
aux =(ListeDept *)malloc(sizeof(ListeDept));
|
|
int nouvNbPlace, pos, trouve;
|
|
char code[30];
|
|
while(1)
|
|
{
|
|
printf("IUT : ");
|
|
scanf("%s",code);
|
|
pos = rechVille(tiut, nbEle, code,&trouve);
|
|
if (trouve == 1)
|
|
{
|
|
aux = tiut[pos]->idDept;
|
|
while(1)
|
|
{
|
|
printf("Département : ");
|
|
scanf("%s",code);
|
|
while(tiut[pos]->idDept->suiv != NULL)
|
|
{
|
|
if (strcmp(tiut[pos]->idDept->departement, code)==0)
|
|
{
|
|
printf("Ancien nombre de places : %d",tiut[pos]->idDept->nbPers);
|
|
printf("Nouveau nombre de places : ", nouvNbPlace);
|
|
scanf("%d", &nouvNbPlace);
|
|
tiut[pos]->idDept->nbPers = nouvNbPlace;
|
|
printf("Mise à jour effectuer avec succès !");
|
|
break;
|
|
}
|
|
tiut[pos]->idDept = tiut[pos]->idDept->suiv;
|
|
}
|
|
if (trouve == 0)
|
|
printf("Département non présent à l'iut de %s",tiut[pos]->ville);
|
|
if(!verifSelection())
|
|
break;
|
|
tiut[pos]->idDept = aux;
|
|
}
|
|
}
|
|
|
|
}
|
|
free(aux);
|
|
}
|
|
|
|
void creationDept(VilleIUT **tiut, int nbEle)
|
|
{
|
|
char code[30], nom[30];
|
|
int trouve, pos, nbP;
|
|
while(1)
|
|
{
|
|
printf("Dans quel IUT voulez-vous créer un département : ");
|
|
scanf("%s", code);
|
|
pos = rechVille(tiut, nbEle, code, &trouve);
|
|
if (trouve == 1)
|
|
{
|
|
while(1)
|
|
{
|
|
printf("Nom du Département : ");
|
|
scanf("%s", code);
|
|
if (recherche(tiut[pos]->idDept, code))
|
|
printf("Département déjà existant");
|
|
if (!recherche(tiut[pos]->idDept, code))
|
|
printf("Nom du Responsable du Département de %s : ",code);
|
|
fgets(nom,30,stdin);
|
|
nom[strlen(nom)-1] = "\0";
|
|
printf("Nombre de place du Département %s : ",code);
|
|
scanf("%d", nbP);
|
|
tiut[pos]->idDept = inserer(tiut[pos]->idDept,code,nom,nbP)
|
|
printf("insertion du département %s effectuer \n", code);
|
|
if (!verifSelection())
|
|
break;
|
|
}
|
|
}
|
|
if (trouve == 0)
|
|
printf("Cet ville n'a pas d'IUT\n");
|
|
if(!verifSelection())
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void suppressionDept(VilleIUT **tiut, int nbEle)
|
|
{
|
|
char code[30];
|
|
int trouve, pos, nbP;
|
|
while(1)
|
|
{
|
|
printf("Dans quel IUT voulez-vous supprimer un département : ");
|
|
scanf("%s", code);
|
|
pos = rechVille(tiut, nbEle, code, &trouve);
|
|
if (trouve == 1)
|
|
{
|
|
printf("Nom du Département : ");
|
|
scanf("%s", code);
|
|
if (recherche(tiut[pos]->idDept, code))
|
|
if (confirmationSup())
|
|
tiut->idDept = supprimer(tiut->idDept, code);
|
|
if (!recherche(tiut[pos]->idDept, code))
|
|
printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville);
|
|
if (!verifSelection())
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
void clearpage(void)
|
|
{
|
|
char entre;
|
|
printf("\nappuyé sur la touche [ENTREE] pour continuer");
|
|
scanf("%*c%c", &entre);
|
|
system("clear");
|
|
}
|