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.
360 lines
9.1 KiB
360 lines
9.1 KiB
#include "Jsae.h"
|
|
|
|
ListeDept listeDeptNouv(void)
|
|
{
|
|
ListeDept lDept;
|
|
lDept = NULL;
|
|
return lDept;
|
|
}
|
|
|
|
ListeDept insérerEntete(ListeDept lDept,Departement d)
|
|
{
|
|
MaillonDept *m;
|
|
m = (MaillonDept *)malloc(sizeof(MaillonDept));
|
|
if(m == NULL)
|
|
{
|
|
printf("Problème d'allocation mémoire lors de l'insertion\n");
|
|
exit(1);
|
|
}
|
|
m->d = d;
|
|
m->suiv = lDept;
|
|
return m;
|
|
}
|
|
|
|
ListeDept insérerDept(ListeDept lDept, Departement d)
|
|
{
|
|
if(lDept == NULL)
|
|
return insérerEntete(lDept,d);
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
return insérerEntete(lDept,d);
|
|
if(strcmp(d.dept,lDept->d.dept) == 0)
|
|
printf("Département déjà présent dans cet IUT\n");
|
|
return lDept;
|
|
lDept->suiv = insérerDept(lDept->suiv,d);
|
|
return lDept;
|
|
}
|
|
|
|
ListeDept supprimerEntete(ListeDept lDept)
|
|
{
|
|
ListeDept aux;
|
|
if(lDept == NULL)
|
|
{
|
|
printf("Opération interdite\n");
|
|
exit(1);
|
|
}
|
|
aux = lDept;
|
|
lDept = lDept->suiv;
|
|
free(aux);
|
|
return lDept;
|
|
}
|
|
|
|
ListeDept supprimerDept(ListeDept lDept, Departement d)
|
|
{
|
|
if(lDept == NULL)
|
|
return lDept;
|
|
if(strcmp(d.dept, lDept->d.dept) < 0)
|
|
return lDept;
|
|
if(strcmp(d.dept,lDept->d.dept) == 0)
|
|
return supprimerEntete(lDept);
|
|
lDept->suiv = supprimerDept(lDept->suiv,d);
|
|
return lDept;
|
|
}
|
|
|
|
int longueur(ListeDept lDept)
|
|
{
|
|
int compt = 0;
|
|
while(lDept != NULL)
|
|
{
|
|
compt = compt + 1;
|
|
lDept = lDept->suiv;
|
|
}
|
|
return compt;
|
|
}
|
|
|
|
bool vide(ListeDept lDept)
|
|
{
|
|
if(lDept == NULL)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
|
|
/*int tete(Liste l){
|
|
if(l==NULL){
|
|
printf("Opération interdite\n");
|
|
exit(1)
|
|
}
|
|
return l->v;
|
|
}*/
|
|
|
|
ListeDept rechercherDept(ListeDept lDept, char dept[], int *trouve)
|
|
{
|
|
if(vide(lDept))
|
|
{
|
|
*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;
|
|
}
|
|
|
|
|
|
int login(void)
|
|
{
|
|
int i = 3;
|
|
char id, mdp[31] = "mettez20svp", mdpatrouve[31];
|
|
system("clear");
|
|
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("\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\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
|
|
{
|
|
i--;
|
|
printf("Mot de passe incorrect, il vous reste %d chances\n",i);
|
|
}
|
|
system("stty echo");
|
|
}
|
|
return -1;
|
|
}
|
|
else
|
|
{
|
|
system("clear");
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax)
|
|
{
|
|
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");
|
|
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);
|
|
}
|
|
}
|
|
|
|
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax)
|
|
{
|
|
int select = 0;
|
|
while(select != 9)
|
|
{
|
|
system("clear");
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void clearpage(void)
|
|
{
|
|
char entre;
|
|
printf("\nappuyé sur la touche [ENTREE] pour continuer");
|
|
scanf("%*c%c", &entre);
|
|
system("clear");
|
|
}
|