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.

282 lines
10 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include "saeP1.h"
#include "../annexe/saeAnnexe.h"
#include "../partie2/saeP2.h"
//Partie Consultant.
void MenuUser(VilleIUT* lvIUT[],int tlogi)
{
int intUserEntry=0;
printf("#--------------------------------------------------------------------#\n");
printf("| |\n");
printf("| SAE S1.02 |\n");
printf("| |\n");
printf("#--------------------------------------------------------------------#\n\n");
printf("Codes correspondant aux différentes actions :\n\n");
printf("1 : Rechercher les villes possèdant un IUT.\n");
printf("2 : Afficher tout les départements de chaques IUT\n");
printf("3 : Afficher le nombre de place en première année d'un IUT précis avec un département précis\n");
printf("4 : Rechercher les IUTs possèdant un département précis.\n");
printf("9 : Revenir à l'écran de sélection du profil.\n\n");
printf("#--------------------------------------------------------------------#\n\n");
while(intUserEntry!=9)
{
printf("Choisissez l'action que vous voulez exécuter : ");
if (!(scanf("%d",intUserEntry)))printf("Entrée innexacte. Veuillez réessayer");
if (intUserEntry==1) SearchCityWithIUT(lvIUT,tlogi);
if (intUserEntry==2) DepEachIUT(lvIUT,tlogi);
if (intUserEntry==3) SearchPlaceFromDepInIUT(lvIUT,tlogi);
if (intUserEntry==4) SearchIUTFromDep(lvIUT,tlogi);
if (intUserEntry==9) printf("Sortie en cours.\n");
else printf("Entrée innexacte. Veuillez réessayer");
}
}
void SearchCityWithIUT(VilleIUT* lvIUT[], int tlogi)
{
for (int i=0;i<tlogi;++i) printf("%s",lvIUT[i]->Ville);
}
void DepEachIUT(VilleIUT* lvIUT[], int tlogi)
{
for (int i=0;i<tlogi;++i)
{
printf("%s :",lvIUT[i]->Ville);
MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL) printf("\t-%s\n",MaillonAct->departement);
}
}
void SearchPlaceFromDepInIUT(VilleIUT* lvIUT[],int tlogi)
{
char sVille[31];
char sDep[31];
int boolF=0, i;
printf("Entrez le nom de la ville contenant le département recherché :\n");
scanf("%s",sVille);
printf("Département y étant disponible :\n");
for (i=0;i<tlogi;++i)
{
if (lvIUT[i]->Ville==sVille)
{
MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL) printf("%s",MaillonAct->departement);
boolF=1;
MaillonAct=MaillonAct->suivant;
break;
}
}
if (!boolF)
{
printf("La ville n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n");
return;
}
printf("Entrez le nom du département dont vous souhaitez connaitre le nombre de place\n");
scanf("%s",sDep);
MaillonDep* MaillonAct=lvIUT[i]->ldept;
while (MaillonAct!=NULL)
{
if(MaillonAct->departement==sDep)
{
printf("Nombre de place : %d\n",MaillonAct->nbp);
return;
}
MaillonAct=MaillonAct->suivant;
}
printf("Le département n'est pas dans la liste.\nMerci de vérifier l'orthographe.\n");
}
void SearchIUTFromDep(VilleIUT* lvIUT[],int tlogi)
{
char sDep[31];
printf("Merci de renseignez le département dont vous cherchez les IUTs :\n");
scanf("%s",sDep);
for (int i=0;i<tlogi;++i)
{
MaillonDep* MaillonAct=lvIUT[i]->ldept;
if(MaillonAct->departement==sDep) printf("%s",lvIUT[i]->Ville);
}
}
//Partie Administrateur.
void menuAdmin(VilleIUT* tiut[],int tlogi){
int quit=0;
while(!quit){
printf("#--------------------------------------------------------------------#\n");
printf("| |\n");
printf("| SAE S1.02 |\n");
printf("| |\n");
printf("#--------------------------------------------------------------------#\n\n");
printf("Codes correspondant aux différentes actions :\n\n");
printf("1 : Modifier le nombre de places dans un département.\n");
printf("2 : Créer un département dans un IUT.\n");
printf("3 : Supprimer un département dun IUT.\n");
printf("4 : Lancer et arrêter la phase de candidature.\n");
printf("5 : Modifier le nom d'un responsable de département.\n");
printf("9 : Revenir à l'écran de sélection du profil.\n\n");
printf("#--------------------------------------------------------------------#\n\n");
printf("Choisissez l'action que vous voulez exécuter : ");
int act;
scanf("%d",&act);
switch(act){
case 1:
modifPlaces(tiut,tlogi);
reset();
break;
case 2:
creerDep(tiut,tlogi);
reset();
break;
case 3:
supprimerDep(tiut,tlogi);
reset();
break;
case 4:
//gestionPhaseCandidatures(); A Faire (Partie 2).
reset();
break;
case 5:
modifNomResponsable(tiut,tlogi);
reset();
break;
case 9:
quit=1;
reset();
}
}
}
void modifPlaces(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):");
char ville[31];
scanf("%*c%s",&ville);
if(ville[0]=='Q' && ville[1]=="\0") return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville);
if(noVille<=0){
fprintf(stderr,"\nVille non existante !\n");
return;
}
VilleIUT* v=tiut[noVille];
printf("\n\nEntrez le département à modifier:");
char dep[31];
scanf("%*c%s",&dep);
if(!existe(tiut->ldept,dep)){
fprintf(stderr,"\nDépartement non existant !\n");
return;
}
MaillonDep* m=v->ldept
while(m->departement!=dep) m=m->suivant;
printf("\n\nIl y a actuellement %d place(s) dans le département. A combien voulez-vous modifier ce nombre ?\n\n",m->nbp);
int nPlaces;
scanf("%d",&nPlaces);
m->nbp=nPlaces;
printf("\n\nLe nombre de places dans le département %s de l'IUT de %s a bien été modifié à %d place(s).\n",dep,ville,nPlaces);
return;
}
void creerDep(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):");
char ville[31];
scanf("%*c%s",&ville);
if(ville[0]=='Q' && ville[1]=="\0") return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville);
if(noVille<=0){
fprintf(stderr,"\nVille non existante !\n");
return;
}
VilleIUT* v=tiut[noVille];
MaillonDep* m=v->ldept;
while(m->suivant!=NULL) m=m->suivant;
m->suivant=(MaillonDep*)malloc(sizeof(MaillonDep));
if(m->suivant==NULL){
perror("malloc");
exit(errno);
}
m=m->suivant;
printf("\n\nEntrez le nom du département à créer :");
char dep[31];
scanf("%*c%s",&dep);
strcpy(m->departement,dep);
printf("\n\nEntrez le nombre de places disponibles dans le département :");
scanf("%d",&m->nbp);
printf("\n\nEntrez le nom du responsable de département :");
char resp[51];
scanf("%*c%s",&resp);
strcpy(m->resp,resp);
printf("\n\nLe département %s a bien été ajouté à l'IUT de %s.\n",dep,ville);
return;
}
void supprimerDep(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):");
char ville[31];
scanf("%*c%s",&ville);
if(ville[0]=='Q' && ville[1]=="\0") return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville);
if(noVille<=0){
fprintf(stderr,"\nVille non existante !\n");
return;
}
VilleIUT* v=tiut[noVille];
printf("\n\nEntrez le département à supprimer:");
char dep[31];
scanf("%*c%s",&dep);
if(!existe(tiut->ldept,dep)){
fprintf(stderr,"\nDépartement non existant !\n");
return;
}
MaillonDep* m=v->ldept;
if(m->departement==dep){
printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->departement,v->Ville);
char choix;
if(choix!='Y') return;
v->ldept=m->suivant;
free(m);
}
else{
while(m->suivant->departement!=dep) m=m->suivant;
printf("\n\nVoulez-vous supprimer le département %s de la ville de %s ? (Y pour continuer)\n\n",m->suivant->departement,v->Ville);
char choix;
if(choix!='Y') return;
MaillonDep* temp;
temp=m->suivant;
m->suivant=m->suivant->suivant;
free(temp);
}
printf("\n\nLe département %s de l'IUT de %s a bien été supprimé.\n",dep,ville);
return;
}
void modifNomResponsable(VilleIUT* tiut[],int tlogi){
printf("\nEntrez la ville correspondant à l'IUT à modifier (Q pour abandonner):");
char ville[31];
scanf("%*c%s",&ville);
if(ville[0]=='Q' && ville[1]=="\0") return;
int noVille=rechercheTabPtVilleIUT(tiut,tlogi,ville);
if(noVille<=0){
fprintf(stderr,"\nVille non existante !\n");
return;
}
VilleIUT* v=tiut[noVille];
printf("\n\nEntrez le département à modifier:");
char dep[31];
scanf("%*c%s",&dep);
if(!existe(tiut->ldept,dep)){
fprintf(stderr,"\nDépartement non existant !\n");
return;
}
MaillonDep* m=v->ldept;
while(m->departement!=dep) m=m->suivant;
printf("\n\nLe responsable du département %s de l'IUT de la ville de %s est actuellement %s. Quel est le nom du nouveau responsable ?\n\n",m->departement,v->Ville,m->resp);
int nom;
scanf("%d",&nom);
strcpy(m->resp,nom);
printf("\n\nLe nom du responsable du département %s de l'IUT de %s a bien été changé pour %s.\n",dep,ville,nom);
return;
}