Modif de login / menuCandidat / globale

master
Maël DAIM 2 years ago
parent 2af64e6c96
commit 3c7c278315

310
Msae.c

@ -552,10 +552,10 @@ void lancerPhaseCandidature(int *phaseCandidature)
// ###########################################################################################
// ###########################################################################################
int login(Candidat *tCand[],int tMax,int *numC,Candidat *c) /* Affiche un menu de connexion pour ensuite adapter l'affichage et les fonctionnalités au type d'utilisateur */
int login(Candidat *tCand[],int *tMax,int *pos) /* Affiche un menu de connexion pour ensuite adapter l'affichage et les fonctionnalités au type d'utilisateur */
{
int i = 3,trouve,pos;
char id, mdp[31] = "mettez20svp", mdpatrouve[31]; /* Déclaration d'un motdepasse administrateur */
int i = 3,trouve,numC;
char id, mdp[31] = "mettez20svp", mdpatrouve[31],choix; /* Déclaration d'un motdepasse administrateur */
system("clear");
printf("\t################################ Bienvenue! ################################\nSouhaitez-vous vous connecter en tant qu'utilisateur ou administeur ? (C/A)\nSaisie : ");
scanf("%c%*c",&id);
@ -598,19 +598,34 @@ int login(Candidat *tCand[],int tMax,int *numC,Candidat *c) /* Affiche un menu d
return -1;
}
if(id == 'C' || id == 'c')/* Si l'utilisateur sélectionne candidat, la fonction retourne 0 */
{
printf("Êtes-vous déjà enregistré / Avez-vous un numéro de candidat ?(o/n)\t");
scanf("%c%*c",&choix);
while(choix!='o'&&choix!='O'&&choix!='n'&&choix!='N')
{
printf("Êtes-vous déjà enregistré / Avez-vous un numéro de candidat ?(o/n)\t");
scanf("%c%*c",&choix);
}
if(choix=='o'|| choix=='O')
{
printf("\nInsérer votre numéro de Candidat :\t");
scanf("%d",numC);
pos=rechercherCandidat(tCand,tMax,*numC,&trouve);
scanf("%d",&numC);
*pos=rechercherCandidat(tCand,*tMax,numC,&trouve);
while(trouve==0)
{
printf("\nCe numéro n'existe pas. Veuillez Re-saisir :\t");
scanf("%d",numC);
pos=rechercherCandidat(tCand,tMax,*numC,&trouve);
scanf("%d",&numC);
*pos=rechercherCandidat(tCand,*tMax,numC,&trouve);
}
return 0;
}
c=tCand[pos];
if(choix=='n'|| choix=='N')
{
tCand=creerCandidat(tCand,tMax,pos);
return 0;
}
}
}
@ -732,26 +747,30 @@ void menuAdmin(VilleIUT *tiut[], int *tLog, int tMax,int *phaseCandidature) /* A
}
}
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tMaxC,Candidat *c,int phaseCandidature)
void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tMaxC,int posC,int phaseCandidature)
{
int select, pos;
int select, pos,i;
char ville[31], dept[31];
int trouve;
MaillonDept *m;
system("clear");
printf("_____________________________________________________\n");
printf("______________________________________________________________\n");
printf("| MENU CANDIDAT |\n");
printf("|---------------------------------------------------|\n");
printf("| Bienvenue %-32s |\n", c->prenom);
printf("|---------------------------------------------------|\n");
printf("|------------------------------------------------------------|\n");
printf("| Bienvenue %-32s |\n", tCand[posC]->prenom);
printf("|------------------------------------------------------------|\n");
printf("| Que souhaitez-vous faire ? |\n");
printf("|---------------------------------------------------|\n");
printf("|------------------------------------------------------------|\n");
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 Afficher les IUT possédant le département voulu |\n");
printf("| 5 Afficher vos choix |\n");
printf("| 6 Ajouter un choix |\n");
printf("| 7 Supprimer un choix |\n");
printf("| 8 Mettre à jour votre décision concernant un établissement |\n");
printf("| 9 Quitter |\n");
printf("|___________________________________________________|\n");
printf("|____________________________________________________________|\n");
printf("Saisie : ");
scanf("%d%*c",&select);
while(select != 9)
@ -804,15 +823,52 @@ void menuCandidat(VilleIUT *tiut[], int *tLog, int tMax,Candidat *tCand[],int tM
{
afficheDeptDesIUT(tiut,*tLog);
}
printf("_____________________________________________________\n");
if(select == 5)
{
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);
for(i = 0; i < tCand[pos]->nombreChoix; i++)
{
afficherChoix(tCand[pos]->tChoix[i]);
}
clearpage();
}
if(select == 7)
{
tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
for(i = 0; i < tCand[pos]->nombreChoix; i++)
{
afficherChoix(tCand[pos]->tChoix[i]);
}
clearpage();
}
if(select == 8)
{
miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix);
}
printf("______________________________________________________________\n");
printf("| MENU CANDIDAT |\n");
printf("|---------------------------------------------------|\n");
printf("|------------------------------------------------------------|\n");
printf("| Bienvenue %-32s |\n", tCand[posC]->prenom);
printf("|------------------------------------------------------------|\n");
printf("| Que souhaitez-vous faire ? |\n");
printf("|------------------------------------------------------------|\n");
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 Afficher les IUT possédant le département voulu |\n");
printf("| 5 Afficher vos choix |\n");
printf("| 6 Ajouter un choix |\n");
printf("| 7 Supprimer un choix |\n");
printf("| 8 Mettre à jour votre décision concernant un établissement |\n");
printf("| 9 Quitter |\n");
printf("|___________________________________________________|\n");
printf("|____________________________________________________________|\n");
printf("Saisie :");
scanf("%d%*c",&select);
}
@ -828,8 +884,8 @@ void clearpage(void) /* Permet de demander à l'utilisateur pour continuer à la
void globale(void) /* Permet l'initialisation du tableau, le chargement de celui-ci et l'appel des fonctions login, menus et enregistrement */
{
int tLog, retour,tMax,numC,phaseCandidature=0;
Candidat **tCand,*c;
int tLog, retour,tMax,numC,phaseCandidature=0,pos;
Candidat **tCand;
VilleIUT *tiut[100]; /* Déclaration du tableau de pointeurs tiut */
if(tiut == NULL) /* En cas de problème de mémoire, affiche un message d'erreur et quitte le programme */
{
@ -846,7 +902,7 @@ void globale(void) /* Permet l'initialisation du tableau, le chargement de celui
tCand = chargementCandidats(&tMax);
triCandidats(tCand, tMax);
retour = login(tCand,tMax,&numC,c); /* Appelle la fonction login */
retour = login(tCand,&tMax,&pos); /* Appelle la fonction login */
while(retour != -1) /* Tant que login ne retourne pas -1, la fonction appelle le menu adaptée en fonction du retour de login puis appelle de nouveau login */
{
if(retour == 1)
@ -855,79 +911,13 @@ void globale(void) /* Permet l'initialisation du tableau, le chargement de celui
}
if(retour == 0)
{
menuCandidat(tiut, &tLog, 100,tCand,tMax,c,phaseCandidature);
menuCandidat(tiut, &tLog, 100,tCand,tMax,pos,phaseCandidature);
}
retour = login(tCand,tMax,&numC,c);
retour = login(tCand,&tMax,&pos);
}
enregistrement(tiut, tLog);
}
// void menuCandidat(Candidat *tCand[], int tMax) /* Fonction affichant un menu adapté pour un candidat */
// {
// int pos,trouve, saisie, i, numeroC;
// system("clear");
// printf("Quel est votre numéro de candidat ?\nSaisie : "); /* Demande le numéro de candidat pour qu'il ne puisse accéder qu'à ses informations */
// scanf("%d%*c", &numeroC);
// printf("\n");
// pos = rechercherCandidat(tCand, tMax, numeroC, &trouve); /* Vérifie que le numéro de candidat est correct */
// if(trouve == 0)
// {
// printf("Erreur, vous n'êtes pas inscrit dans la base de données\n");
// return;
// }
// system("clear");
// printf("|------------------------------------------------------------|\n");
// printf("| Bienvenue %-32s |\n", tCand[pos]->prenom);
// printf("|------------------------------------------------------------|\n");
// printf("| Que souhaitez-vous faire ? |\n");
// printf("|------------------------------------------------------------|\n");
// printf("| 1 Afficher vos choix |\n");
// printf("| 2 Ajouter un choix |\n");
// printf("| 3 Supprimer un choix |\n");
// printf("| 4 Mettre à jour votre décision concernant un établissement |\n");
// printf("| 9 Quitter |\n");
// printf("|------------------------------------------------------------|\n");
// printf("Saisie : ");
// scanf("%d%*c", &saisie);
// printf("\n");
// while(saisie != 9) /* Saisie contrôlée et affichage du menu tant que le candidat ne demande pas à quitter */
// {
// system("clear");
// if(saisie == 1)
// {
// for(i = 0; i < tCand[pos]->nombreChoix; i++)
// {
// afficherChoix(tCand[pos]->tChoix[i]);
// }
// }
// if(saisie == 2)
// {
// tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
// }
// if(saisie == 3)
// {
// tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
// }
// if(saisie == 4)
// {
// miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix);
// }
// clearpage();
// printf("|------------------------------------------------------------|\n");
// printf("| Que souhaitez-vous faire ? |\n");
// printf("|------------------------------------------------------------|\n");
// printf("| 1 Afficher vos choix |\n");
// printf("| 2 Ajouter un choix |\n");
// printf("| 3 Supprimer un choix |\n");
// printf("| 4 Mettre à jour votre décision concernant un établissement |\n");
// printf("| 9 Quitter |\n");
// printf("|------------------------------------------------------------|\n");
// printf("Saisie : ");
// scanf("%d%*c", &saisie);
// printf("\n");
// }
// }
@ -1240,6 +1230,62 @@ void echangerChoix(Choix *tChoix[], int i, int j) /* Fonction permettant d'écha
/************************************************************************************************************/
/************************************************************************************************************/
Candidat ** creerCandidat(Candidat *tCand[], int *tMax,int *pos)
{
int trouve, i, numeroC;
char nom[31], prenom[31];
float notes[4];
Candidat *c;
printf("Quel est votre numéro de candidat ?\nSaisie : "); /* Demande à l'utilisateur le numéro du candidat pour l'insertion */
scanf("%d%*c", &numeroC);
printf("\n");
*pos = rechercherCandidat(tCand, *tMax, numeroC, &trouve); /* Vérifie que le numero de candidat n'existe pas déjà */
if(trouve == 1)
{
printf("Erreur, votre numéro de candidat existe déjà dans la base de données\n");
return tCand;
}
c = (Candidat *)malloc(sizeof(Candidat)); /* Allocation dynamique du candidat à insérer */
if(c == NULL)
{
printf("Erreur d'allocation mémoire lors de l'insertion du candidat\n");
return tCand;
}
printf("Quel est votre nom ?\n");
scanf("%s%*c", nom);
printf("\n");
printf("Quel est votre prenom ?\n");
scanf("%s%*c", prenom);
printf("\n");
printf("Quel est votre moyenne de maths ?\n");
scanf("%f%*c", &notes[0]);
printf("\n");
printf("Quel est votre moyenne de français ?\n");
scanf("%f%*c", &notes[1]);
printf("\n");
printf("Quel est votre moyenne d'anglais ?\n");
scanf("%f%*c", &notes[2]);
printf("\n");
printf("Quel est votre moyenne de spécialité ?\n");
scanf("%f%*c", &notes[3]);
printf("\n");
c->numeroC = numeroC;
strcpy(c->nom, nom); /* Ajout des valeurs dans le candidat à insérer */
strcpy(c->prenom, prenom);
c->notes[0] = notes[0];
c->notes[1] = notes[1];
c->notes[2] = notes[2];
c->notes[3] = notes[3];
tCand = reallocationCand(tCand, *tMax); /* Réallocation du tableau de candidats pour ajouter une place */
for(i = *tMax; i > *pos; i--) /* Décalage à droite des éléments du tableau à partir de la position d'insertion */
{
tCand[i] = tCand[i - 1];
}
tCand[*pos] = c; /* Ajout du candidat dans le tableau */
*tMax = *tMax + 1; /* Mise à jour de la taille physique du tableau */
return tCand;
}
Choix ** insererChoix(Choix *tChoix[], int *nombreChoix) /* Fonction permettant d'ajouter un nouveau choix dans un tableau de choix et retournant le tableau*/
{
int pos, trouve, i;
@ -1481,87 +1527,3 @@ int rechercherCandidat(Candidat *tCand[], int tMax, int numeroC, int *trouve) /*
return inf;
}
/********************************** Fonction globale et menus ***********************************************/
/************************************************************************************************************/
/************************************************************************************************************/
// void globale(void) /* Permet de gérer l'exécution du programme */
// {
// int tMax, pos, trouve, i;
// Candidat **tCand, c; /* Initialisation du tableau de candidats */
// tCand = chargementCandidats(&tMax); /* Remplissage du tableau par chargement */
// triCandidats(tCand, tMax); /* Tri du tableau */
// for(i = 0; i < tMax; i++) /* Tri du tableau choix pour chaque candidat */
// {
// triChoix(tCand[i]->tChoix, tCand[i]->nombreChoix);
// }
// menuCandidat(tCand, tMax); /* Appel du menu adapté au candidat */
// sauvegarder(tCand, tMax); /* Sauvegarde du tableau de candidats */
// }
// void menuCandidat(Candidat *tCand[], int tMax) /* Fonction affichant un menu adapté pour un candidat */
// {
// int pos,trouve, saisie, i, numeroC;
// system("clear");
// printf("Quel est votre numéro de candidat ?\nSaisie : "); /* Demande le numéro de candidat pour qu'il ne puisse accéder qu'à ses informations */
// scanf("%d%*c", &numeroC);
// printf("\n");
// pos = rechercherCandidat(tCand, tMax, numeroC, &trouve); /* Vérifie que le numéro de candidat est correct */
// if(trouve == 0)
// {
// printf("Erreur, vous n'êtes pas inscrit dans la base de données\n");
// return;
// }
// system("clear");
// printf("|------------------------------------------------------------|\n");
// printf("| Bienvenue %-32s |\n", tCand[pos]->prenom);
// printf("|------------------------------------------------------------|\n");
// printf("| Que souhaitez-vous faire ? |\n");
// printf("|------------------------------------------------------------|\n");
// printf("| 1 Afficher vos choix |\n");
// printf("| 2 Ajouter un choix |\n");
// printf("| 3 Supprimer un choix |\n");
// printf("| 4 Mettre à jour votre décision concernant un établissement |\n");
// printf("| 9 Quitter |\n");
// printf("|------------------------------------------------------------|\n");
// printf("Saisie : ");
// scanf("%d%*c", &saisie);
// printf("\n");
// while(saisie != 9) /* Saisie contrôlée et affichage du menu tant que le candidat ne demande pas à quitter */
// {
// system("clear");
// if(saisie == 1)
// {
// for(i = 0; i < tCand[pos]->nombreChoix; i++)
// {
// afficherChoix(tCand[pos]->tChoix[i]);
// }
// }
// if(saisie == 2)
// {
// tCand[pos]->tChoix = insererChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
// }
// if(saisie == 3)
// {
// tCand[pos]->tChoix = supprimerChoix(tCand[pos]->tChoix, &tCand[pos]->nombreChoix);
// }
// if(saisie == 4)
// {
// miseAJourChoixCand(tCand[pos]->tChoix, tCand[pos]->nombreChoix);
// }
// clearpage();
// printf("|------------------------------------------------------------|\n");
// printf("| Que souhaitez-vous faire ? |\n");
// printf("|------------------------------------------------------------|\n");
// printf("| 1 Afficher vos choix |\n");
// printf("| 2 Ajouter un choix |\n");
// printf("| 3 Supprimer un choix |\n");
// printf("| 4 Mettre à jour votre décision concernant un établissement |\n");
// printf("| 9 Quitter |\n");
// printf("|------------------------------------------------------------|\n");
// printf("Saisie : ");
// scanf("%d%*c", &saisie);
// printf("\n");
// }
// }
Loading…
Cancel
Save