#include #include #include #include "iut.h" void MenuAdministrateur(VilleIUT *tiut[],int n){ char departement[30], respon[30], Vmodif[31],tVille[31], tdepartemnt[30], AouD; int choix = 1, nbp, i, j, Mnbp,good=0,reussi=0; VilleIUT V; while(choix>0 && choix<6){ printf("\n >--------------------------------------------------------<\n"); printf("\n\t0 - Revenir au menu"); printf("\n\t1 - Modifier une place"); printf("\n\t2 - Créer un département"); printf("\n\t3 - Supprimer un département"); printf("\n\t4 - Lancer et arrêter la phase de canditature"); printf("\n\t5 - Modifier le nom d'un responsable"); printf("\n\t6 - Afficher différents tableaux, FONCTION DE DEV UNIQUEMENT, A SUPPRIMER\n"); printf("\n >--------------------------------------------------------<\n"); printf("\n\tVotre choix : "); scanf("\n%d",&choix); system("cls"); system("clear"); if(choix==1){ char rech[31], rech2[31]; int trouve = 0; ListeD ld; printf("\nEntrez le nom d'une ville : "); scanf("%s%*c", &rech); for(i=0;ildept; if(strcmp(tiut[i]->ville, rech)==0){ printf("\nIUT trouvé à %s !\n", rech); printf("\nNom du département à modifier : "); scanf("%s", rech2); while(ld!=NULL){ if(strcmp(ld->departement, rech2)==0 && ld->AouD == 'D'){ printf("\nProblème, phase de candidature à l'arrêt pour ce département.\n"); good=1; }else if(strcmp(ld->departement, rech2)==0 && ld->AouD == 'A'){ printf("\nNombre de place après modification : "); scanf("%d",&Mnbp); tiut[i]->ldept=ModifinbP(tiut[i]->ldept, rech2, Mnbp,n); reussi=1; } trouve = 1; ld = ld->suivant; } } else if(i==n-1){ printf("\nIl n'y pas d'IUT dans votre ville.\n"); } } } if(choix==2){ //creer departemement printf("\nVille où se situe le departement :"); scanf("%s",Vmodif); printf("\ndepartement a creer :"); scanf("%s",departement); printf("\nnombre de place :"); scanf("%d",&nbp); printf("\nnom du responsable :"); scanf("%s",respon); for(i=0;iville, Vmodif)==0){ tiut[i]->ldept=Enfiler(tiut[i]->ldept,departement,nbp,respon); tiut[i]->nbDep=tiut[i]->nbDep+1; reussi=1; } } if(reussi==0) printf("pb erreur syntaxe\n"); } if(choix==3){ //supprimer departement et pauser condition pour choisir qui suppr printf("\nVille où se situe le departement :"); scanf("%s",Vmodif); printf("\ndepartement :"); scanf("%s",departement); for(i=0;iville, Vmodif)==0){ tiut[i]->ldept=suppression(tiut[i]->ldept,departement); tiut[i]->nbDep=tiut[i]->nbDep-1; reussi=1; } } if(reussi==0) printf("pb erreur syntaxe\n"); } if(choix==4){ //Lancer et arreter phase de canditature printf("\nVille où se situe le departement :"); scanf("%s",Vmodif); printf("\ndepartement :"); scanf("%s%*c",departement); printf("\nPour Activer taper A pour desactiver taper D :"); scanf("%c%*c",&AouD);; for(i=0;iville, Vmodif)==0){ tiut[i]->ldept=ModifiAouD(tiut[i]->ldept,departement,AouD,n); reussi=1; } } if(reussi==0) printf("pb erreur syntaxe\n"); } if(choix==5){ //modification responsable printf("\nVille où se situe le departement à modifier :"); scanf("%s",Vmodif); printf("\ndepartement à modifier:"); scanf("%s",departement); printf("\nnom du responsable :"); scanf("%s",respon); for(i=0;iville, Vmodif)==0){ tiut[i]->ldept=ModifiRespon(tiut[i]->ldept,departement,respon,n); reussi=1; } } if(reussi==0) printf("pb erreur syntaxe\n"); } if(choix==6){ //Fonction servant au développement du programme, fonction de test uniquement, à supprimer peut-être. affichage(tiut, n); char a[50]; scanf("%c%*c", a); } } } ListeD suppressionTete(ListeD ld){ ListeD ldsvt; ldsvt=ld->suivant; free(ld); return ldsvt; } ListeD suppression(ListeD ld,char *departement){ if(ld==NULL) return ld; if(strcmp(ld->departement,departement) ==0 ) return suppressionTete(ld); ld->suivant=suppression(ld->suivant,departement); return ld; } ListeD ModifinbP(ListeD ld, char departement[31], int MnbP, int n){ int i; for(i=0;i<=n;i++){ if(strcmp(ld->departement, departement)==0){ ld->nbP=MnbP; return ld; } ld=ld->suivant; } return ld; } ListeD ModifiRespon(ListeD ld, char departement[30], char respon[30], int n){ int i; for(i=0;i<=n;i++){ if(strcmp(ld->departement,departement)==0){ strcpy(ld->resp, respon); return ld; } ld=ld->suivant; } return ld; } ListeD ModifiAouD(ListeD ld, char departement[30], char AouD,int n){ int i; for(i=0;i<=n;i++){ if(strcmp(ld->departement,departement)==0){ ld->AouD=AouD; return ld; } ld=ld->suivant; } return ld; } ListeD Enfiler(ListeD ld, char departement[30], int nbP, char resp[30]) { MaillonDept *mN; mN = (MaillonDept*)malloc(sizeof(MaillonDept)); if(mN==NULL){printf("pb ouv malloc");exit(1);} strcpy(mN->departement, departement); mN->nbP = nbP; strcpy(mN->resp, resp); mN->AouD = 'A'; mN->suivant = NULL; if(ld == NULL) ld = mN; else { MaillonDept *mD; mD = ld; while(mD->suivant != NULL) mD = mD->suivant; mD->suivant = mN; } return ld; } int fsauvegarde(VilleIUT *tiut[], Candidat *tcandidat[], int n, int nc, int choix, int tmax){ int i, k, j; //Sauvegarde du fichier d'adhérents FILE *fe; fe=fopen("ville.don","w"); if(fe==NULL){ printf("\tPb overture fichier"); return-1; } for(i=0;iville, tiut[i]->nbDep); while(tiut[i]->ldept!=NULL){ fprintf(fe,"%s ",tiut[i]->ldept->departement); fprintf(fe,"%d ",tiut[i]->ldept->nbP); fprintf(fe,"%s ",tiut[i]->ldept->resp); fprintf(fe,"%c\n",tiut[i]->ldept->AouD); tiut[i]->ldept = tiut[i]->ldept->suivant; } } } fclose(fe); //Sauvegarde du fichier d'activités FILE *fe2; fe2=fopen("Candidat.don","w"); //Ici, le a permet d'écrire à la suite des informations précédentes dans le fichier sans les supprimer if(fe2==NULL){ printf("\tpb overture fichier"); return-1; } for(j=0;jnumero, tcandidat[j]->nom, tcandidat[j]->prenom, tcandidat[j]->note.Francais, tcandidat[j]->note.Maths, tcandidat[j]->note.Anglais, tcandidat[j]->nb_choix); while(tcandidat[j]->lchoix!=NULL){ fprintf(fe2,"%s ",tcandidat[j]->lchoix->ville); fprintf(fe2,"%s ",tcandidat[j]->lchoix->departement); fprintf(fe2,"%d ",tcandidat[j]->lchoix->decision); fprintf(fe2,"%d\n",tcandidat[j]->lchoix->validation); tcandidat[j]->lchoix = tcandidat[j]->lchoix->suivant; } } } fclose(fe2); return 0; }