modif menus login et lancerCandidature

master
Maël DAIM 2 years ago
parent 13a9d34ad0
commit 268b2f3ec4

293
Msae.c

@ -532,17 +532,37 @@ void lancerPhaseCandidature(int *phaseCandidature)
{ {
char choix; char choix;
system("clear"); system("clear");
printf("Êtes-vous sur de lancer la phase de candidature?(o/n)"); if (*phaseCandidature==0)
scanf("%c",&choix);
if(choix!='O' && choix!='o')
{ {
printf("La phase de candidature n'a pas été lancée.\n"); printf("La phase de candidature n'a pas été lancée.\n");
scanf("%c",&choix); printf("\nÊtes-vous sur de lancer la phase de candidature?(o/n)\t");
clearpage(); scanf("%c",&choix);
return; if(choix!='O' && choix!='o')
{
printf("La phase de candidature n'a pas été lancée.\n");
scanf("%c",&choix);
clearpage();
return;
}
*phaseCandidature=1;
printf("\nLa phase de candidature a été lancée.\n");
}
if(*phaseCandidature==1)
{
printf("La phase de candidature est en court.\n");
printf("\nÊtes-vous sur d'arrêter la phase de candidature?(o/n)\t");
scanf("%c",&choix);
if(choix!='O' && choix!='o')
{
printf("La phase de candidature n'a pas été arrêtée.\n");
scanf("%c",&choix);
clearpage();
return;
}
*phaseCandidature=2;
printf("\nLa phase de candidature a été arrêtée.\n");
} }
*phaseCandidature=1;
printf("\nLa phase de candidature a été lancée.\n");
clearpage(); clearpage();
} }
@ -628,8 +648,6 @@ int login(Candidat *tCand[],int *tMax,int *pos) /* Affiche un menu de connexion
} }
} }
void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax,int *phaseCandidature) /* Affiche un menu de choix adaptés pour un administrateur et appelle les fonctions en conséquence */ void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax,int *phaseCandidature) /* Affiche un menu de choix adaptés pour un administrateur et appelle les fonctions en conséquence */
{ {
int select, pos; int select, pos;
@ -677,54 +695,58 @@ void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax,int *phaseCandidature) /* A
{ {
creerDept(tiut, *tLog); creerDept(tiut, *tLog);
} }
if(select == 4) if(*phaseCandidature==0)
{
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 */ if(select == 4)
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"); retirerDept(tiut, *tLog);
} }
else /* Sinon, appelle la fonction d'insertion */ if(select == 5)
{ {
insererVille(tiut, ville, tLog, tMax, pos); miseAJourGlobale(tiut, *tLog);
} }
} if(select == 6)
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"); 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);
}
} }
else /* Sinon, demande confirmation, si confirmé, supprime la ville, sinon annule la suppression */ if(select == 7)
{ {
printf("Êtes-vous sur de vouloir supprimer cette ville ? (O/n)\nSaisie : "); /* Demande confirmation de la suppression */ printf("Quel est le nom de la ville à supprimer ?\nSaisie : "); /* Demande le nom de la ville à supprimer */
scanf("%c%*c", &choix); scanf("%s%*c", ville);
printf("\n"); printf("\n");
if(choix == 'N' || choix == 'n') /* Si le choix et non, annule la supression */ 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("Suppression annulée\n"); printf("Erreur, cette ville n'existe pas !\n");
} }
else else /* Sinon, demande confirmation, si confirmé, supprime la ville, sinon annule la suppression */
{ {
supprimerVille(tiut, ville, tLog, pos); 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);
}
} }
} }
} }
if(select==8) if(select==8)
{ {
lancerPhaseCandidature(phaseCandidature); lancerPhaseCandidature(phaseCandidature);
@ -823,35 +845,41 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM
{ {
afficheDeptDesIUT(tiut,*tLog); afficheDeptDesIUT(tiut,*tLog);
} }
if(select == 5) if(phaseCandidature==1)
{ {
for(i = 0; i < tCand[pos]->nombreChoix; i++) if(select == 5)
{ {
afficherChoix(tCand[pos]->tChoix[i]); for(i = 0; i < tCand[pos]->nombreChoix; i++)
} {
} afficherChoix(tCand[pos]->tChoix[i]);
if(select == 6) }
{ }
tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); if(select == 6)
for(i = 0; i < tCand[pos]->nombreChoix; i++) {
{ tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
afficherChoix(tCand[pos]->tChoix[i]); for(i = 0; i < tCand[pos]->nombreChoix; i++)
} {
clearpage(); afficherChoix(tCand[pos]->tChoix[i]);
} }
if(select == 7) clearpage();
{ }
tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix); if(select == 7)
for(i = 0; i < tCand[pos]->nombreChoix; i++) {
{ tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
afficherChoix(tCand[pos]->tChoix[i]); for(i = 0; i < tCand[pos]->nombreChoix; i++)
} {
clearpage(); afficherChoix(tCand[pos]->tChoix[i]);
} }
if(select == 8) clearpage();
}
}
if(phaseCandidature=2)
{ {
miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix); if(select == 8)
} {
miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix);
}
}
printf("______________________________________________________________\n"); printf("______________________________________________________________\n");
printf("| MENU CANDIDAT |\n"); printf("| MENU CANDIDAT |\n");
printf("|------------------------------------------------------------|\n"); printf("|------------------------------------------------------------|\n");
@ -1527,3 +1555,126 @@ int rechercherCandidat(Candidat *tCand[], int tMax, int numeroC, int *trouve) /*
return inf; return inf;
} }
/**************************************** File d'attente ****************************************************/
/************************************************************************************************************/
/************************************************************************************************************/
FileCand filenouv(void)
{
FileCand f;
f.t = NULL;
f.q = NULL;
return f;
}
FileCand adjq(FileCand f, Candidat *c)
{
MaillonCandidat *m;
m = (MaillonCandidat *)malloc(sizeof(MaillonCandidat));
if(m == NULL)
{
printf("Erreur de malloc pour la file d'attente\n");
exit(1);
}
m->c = c;
m->suiv = NULL;
if(videFile(f))
{
f.t = m;
f.q = m;
return f;
}
f.q->suiv = m;
f.q = m;
return f;
}
FileCand supt(FileCand f)
{
MaillonCandidat *aux;
if(videFile(f))
{
printf("Opération interdite\n");
exit(1);
}
if(f.t == f.q)
{
free(f.t);
return filenouv();
}
aux = f.t;
f.t = f.t->suiv;
free(aux);
return f;
}
FileCand supCand(FileCand f, int numeroC)
{
}
Candidat * tete(FileCand f)
{
if(videFile(f))
{
printf("File d'attente vide\n");
exit(1);
}
return f.t->c;
}
int longueur(FileCand f)
{
int i = 0;
while(f.t != NULL)
{
f.t = f.t->suiv;
i++;
}
return i;
}
int positionFileAttente(FileCand f, int numeroC)
{
int i = 0;
while(f.t != NULL)
{
if(numeroC == f.t->c->numeroC)
{
return i;
}
f.t = f.t->suiv;
i++;
}
return i;
}
bool vide(FileCand f)
{
if(f.t == NULL && f.q == NULL)
return true;
return false;
}
void afficher(FileCand f)
{
printf("|----------------------------------------------------------------------------|\n");
printf("| Liste d'attente |\n");
printf("|----------------------------------------------------------------------------|\n");
while(f.t != NULL)
{
printf("| %-4d | %-32s | %-32s |\n",f.t->c->numeroC, f.t->c->nom, f.t->c->prenom);
printf("|----------------------------------------------------------------------------|\n");
f.t = f.t->suiv;
}
printf("\n");
}
bool videFile(FileCand f)
{
if(f.t==f.q)
{
return true;
}
return false;
}
Loading…
Cancel
Save