Ajustements au niveau de l'insertion, de l'affichage et ajout des login et menu à la fonction globale via le fichier commun

master
Johnny.Ratton 2 years ago
parent ad68a43e68
commit 4c576e5b58

@ -25,9 +25,9 @@ ListeDept insérerDept(ListeDept lDept, Departement d)
{ {
if(lDept == NULL) if(lDept == NULL)
return insérerEntete(lDept,d); return insérerEntete(lDept,d);
if(d.dept < lDept->d.dept) if(strcmp(d.dept, lDept->d.dept) < 0)
return insérerEntete(lDept,d); return insérerEntete(lDept,d);
if(d.dept == lDept->d.dept) if(strcmp(d.dept,lDept->d.dept) == 0)
printf("Département déjà présent dans cet IUT\n"); printf("Département déjà présent dans cet IUT\n");
return lDept; return lDept;
lDept->suiv = insérerDept(lDept->suiv,d); lDept->suiv = insérerDept(lDept->suiv,d);
@ -52,9 +52,9 @@ ListeDept supprimerDept(ListeDept lDept, Departement d)
{ {
if(lDept == NULL) if(lDept == NULL)
return lDept; return lDept;
if(d.dept < lDept->d.dept) if(strcmp(d.dept, lDept->d.dept) < 0)
return lDept; return lDept;
if(d.dept == lDept->d.dept) if(strcmp(d.dept,lDept->d.dept) == 0)
return supprimerEntete(lDept); return supprimerEntete(lDept);
lDept->suiv = supprimerDept(lDept->suiv,d); lDept->suiv = supprimerDept(lDept->suiv,d);
return lDept; return lDept;
@ -91,11 +91,101 @@ bool rechercherDept(ListeDept lDept, Departement d)
{ {
if(vide(lDept)) if(vide(lDept))
return false; return false;
if(d.dept < lDept->d.dept) if(strcmp(d.dept, lDept->d.dept) < 0)
return false; return false;
if(d.dept == lDept->d.dept) if(strcmp(d.dept,lDept->d.dept) == 0)
return true; return true;
return rechercherDept(lDept->suiv, d); return rechercherDept(lDept->suiv, d);
} }
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");
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");
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");
system("stty -echo");
fgets(mdpatrouve, 31, stdin);
mdpatrouve[strlen(mdpatrouve) - 1] = '\0';
if(strcmp(mdpatrouve, mdp) == 0 )
{
system("stty echo");
return 1;
}
else
{
i--;
printf("Mot de passe incorrect, il vous reste %d chances\n",i);
}
system("stty echo");
}
return -1;
}
else return 0;
system("clear");
}
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax)
{
int select = 0;
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");
scanf("%d",&select);
}
}
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax)
{
int select = 0;
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");
scanf("%d",&select);
}
}
void clearpage(void)
{
char entre;
printf("\nappuyé sur la touche [ENTREE] pour continuer");
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);
}

@ -72,12 +72,14 @@ int insérerVille(VilleIUT *tiut[], char nomV[], Departement d, int *tLog, int t
void afficherDep(Departement d) void afficherDep(Departement d)
{ {
printf("%s\t%d\t%s\n", d.dept, d.nbP, d.respAd); printf("| %-32s\t%3d\t%-32s |\n", d.dept, d.nbP, d.respAd);
} }
void afficherVille(VilleIUT v) void afficherVille(VilleIUT v)
{ {
printf("%s\t", v.nom); printf("|----------------------------------|\n");
printf("| %-32s |\n", v.nom);
printf("|----------------------------------|\n");
} }
void afficherTIUT(VilleIUT *tiut[], int tLog) void afficherTIUT(VilleIUT *tiut[], int tLog)
@ -137,7 +139,7 @@ int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve)
void globale(void) void globale(void)
{ {
int tLog; int tLog, retour;
VilleIUT *tiut[100]; VilleIUT *tiut[100];
if(tiut == NULL) if(tiut == NULL)
{ {
@ -145,12 +147,22 @@ void globale(void)
exit(1); exit(1);
} }
tLog = chargement(tiut,100); tLog = chargement(tiut,100);
printf("Tlog : %d\n", tLog);
if(tLog < 0) if(tLog < 0)
{ {
printf("Le programme ne peut pas fonctionner\n"); printf("Le programme ne peut pas fonctionner\n");
exit(1); exit(1);
} }
afficherVilleDep(tiut, tLog); retour = login();
afficherDep(tiut[0]->lDept->d); while(retour != -1)
{
if(retour == 1)
{
menuAdmin(tiut, &tLog, 100);
}
if(retour == 0)
{
menuCandidat(tiut, &tLog, 100);
}
retour = login();
}
} }

@ -34,6 +34,11 @@ ListeDept supprimerDept(ListeDept lDept, Departement d);
int longueur(ListeDept lDept); int longueur(ListeDept lDept);
bool vide(ListeDept lDept); bool vide(ListeDept lDept);
bool rechercherDept(ListeDept lDept, Departement d); bool rechercherDept(ListeDept lDept, Departement d);
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 afficherDep(Departement d); void afficherDep(Departement d);
void afficherVille(VilleIUT v); void afficherVille(VilleIUT v);
void afficherTIUT(VilleIUT *tiut[], int tLog); void afficherTIUT(VilleIUT *tiut[], int tLog);

Loading…
Cancel
Save