remise en forme du testiut + ajout 3 choix pour pouvoir sauvegarder

master
Benjamin BACHELARD 2 years ago
parent 6a23f041ff
commit 6f1130d1f7

@ -7,205 +7,198 @@ void MenuAdministrateur(VilleIUT *tiut[],int n){
char departement[30], respon[30], Vmodif[31],tVille[31], tdepartemnt[30], AouD;
int choix, nbp, i, j, comp, Mnbp,good=0;
VilleIUT V;
printf("\n0-Revenir au menu\n1-Modifier place\n2-Creer un departement\n3-supprimer un département\n4-Lancer et Arreter la phase de canditature\n5-modifier nom responsable :");
scanf("\n%d",&choix);
if(choix==0){
system("cls"); // pour Windows
system("clear"); // pour Unix
printf("\n0-Revenir au menu\n1-Modifier place\n2-Creer un departement\n3-supprimer un département\n4-Lancer et Arreter la phase de canditature\n5-modifier nom responsable :");
scanf("\n%d",&choix);
}
if(choix==1){
printf("\nVille où se situe le departement à modifier :");
scanf("%s",Vmodif);
printf("\ndepartement à modifier:");
scanf("%s",departement);
for(i=0;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
for(j=0;j<3;j++){
if(strcmp(tiut[j]->ldept->departement, departement) == 0 && tiut[j]->ldept->AouD == 'D'){
printf("pb departement arret phase de candidature\n");
good=1;
}
}
}
}
if(good==0){
printf("\nnombre de place apres modification :");
scanf("%d",&Mnbp);
while(choix>0){
if(choix==1){
printf("\nVille où se situe le departement à modifier :");
scanf("%s",Vmodif);
printf("\ndepartement à modifier:");
scanf("%s",departement);
for(i=0;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
for(j=0;j<3;j++){
if(strcmp(tiut[i]->ldept->departement, departement) == 0 && tiut[i]->ldept->AouD == 'D'){
printf("%c",tiut[i]->ldept->AouD );
printf("pb departement arret phase de candidature\n");
good=1;
}
}
if(good==0){
printf("\nnombre de place apres modification :");
scanf("%d",&Mnbp);
tiut[i]->ldept=ModifinbP(tiut[i]->ldept,departement,Mnbp,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 nouveau responsable :");
scanf("%s",respon);
for(i=0;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=Enfiler(tiut[i]->ldept,departement,nbp,respon);
}
}
}
}
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 nouveau responsable :");
scanf("%s",respon);
for(i=0;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=Enfiler(tiut[i]->ldept,departement,nbp,respon);
}
}
}
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;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=suppression(tiut[i]->ldept,departement);
}
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;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=suppression(tiut[i]->ldept,departement);
}
}
}
}
if(choix==4){
//Lancer et arreter phase de canditature
printf("\nVille où se situe le departement :");
scanf("%s",Vmodif);
printf("\ndepartement :");
scanf("%s",departement);
printf("\nPour Activer taper A pour desactiver taper D :");
scanf("%c",&AouD);
for(i=0;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=ModifiAouD(tiut[i]->ldept,departement,AouD,n);
}
if(choix==4){
//Lancer et arreter phase de canditature
printf("\nVille où se situe le departement :");
scanf("%s",Vmodif);
printf("\ndepartement :");
scanf("%s",departement);
printf("\nPour Activer taper A pour desactiver taper D :");
scanf("%c",&AouD);
for(i=0;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=ModifiAouD(tiut[i]->ldept,departement,AouD,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;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=ModifiRespon(tiut[i]->ldept,departement,respon,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;i<n;i++){
comp=strcmp(tiut[i]->ville, Vmodif);
if(comp==0){
tiut[i]->ldept=ModifiRespon(tiut[i]->ldept,departement,respon,n);
}
}
}
affichage(tiut,n);
printf("\nVoulez-vous choisir une autre fonction ? Sinon taper 0 pour valider : ");
scanf("%d%*c",&choix);
}
affichage(tiut,n);
}
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[30], int MnbP, int n){
int comp,trouv,i;
for(i=0;i<=n;i++){
comp=strcmp(ld->departement,departement);
if(comp==0)
trouv=i;
}
if(trouv==0){
printf("departement non existant");
exit(1);
}
else{
ld->nbP=MnbP;
ListeD suppressionTete(ListeD ld){
ListeD ldsvt;
ldsvt=ld->suivant;
free(ld);
return ldsvt;
}
return ld;
}
ListeD ModifiRespon(ListeD ld, char departement[30], char respon[30], int n){
int comp,trouv,i;
for(i=0;i<=n;i++){
comp=strcmp(ld->departement,departement);
if(comp==0)
trouv=i;
}
if(trouv==0){
printf("departement non existant");
exit(1);
}
else{
strcpy(ld->resp, respon);
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;
}
return ld;
}
ListeD ModifiAouD(ListeD ld, char departement[30], char AouD,int n){
int comp,trouv,i;
for(i=0;i<=n;i++){
comp=strcmp(ld->departement,departement);
if(comp==0)
trouv=i;
ListeD ModifinbP(ListeD ld, char departement[30], int MnbP, int n){
int comp,trouv,i;
for(i=0;i<=n;i++){
comp=strcmp(ld->departement,departement);
if(comp==0)
trouv=i;
}
if(trouv==0){
printf("departement non existant");
exit(1);
}
else{
ld->nbP=MnbP;
}
return ld;
}
if(trouv==0){
printf("departement non existant");
exit(1);
ListeD ModifiRespon(ListeD ld, char departement[30], char respon[30], int n){
int comp,trouv,i;
for(i=0;i<=n;i++){
comp=strcmp(ld->departement,departement);
if(comp==0)
trouv=i;
}
if(trouv==0){
printf("departement non existant");
exit(1);
}
else{
strcpy(ld->resp, respon);
}
return ld;
}
else{
ld->AouD = AouD;
ListeD ModifiAouD(ListeD ld, char departement[30], char AouD,int n){
int comp,trouv,i;
for(i=0;i<=n;i++){
comp=strcmp(ld->departement,departement);
if(comp==0)
trouv=i;
}
if(trouv==0){
printf("departement non existant");
exit(1);
}
else{
ld->AouD = AouD;
}
return ld;
}
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->suivant = NULL;
printf("\naa");
if (ld == NULL) {
ld = mN;
} else {
MaillonDept *mD;
mD = ld;
while (mD->suivant != NULL) {
mD = mD->suivant;
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->suivant = NULL;
printf("\naa");
if (ld == NULL) {
ld = mN;
} else {
MaillonDept *mD;
mD = ld;
while (mD->suivant != NULL) {
mD = mD->suivant;
}
mD->suivant = mN;
}
mD->suivant = mN;
return ld;
}
return ld;
}
/*
VilleIUT defiler(VilleIUT V){
MaillonDept *temp;
if(testVide(V)){
printf("testVide");
/*
VilleIUT defiler(VilleIUT V){
MaillonDept *temp;
if(testVide(V)){
printf("testVide");
return V;
}
temp=V.Ville;
V.Ville=temp->suivant;
free(temp);
if(V.Ville==NULL)
V.Idept=NULL;
return V;
}
temp=V.Ville;
V.Ville=temp->suivant;
free(temp);
if(V.Ville==NULL)
V.Idept=NULL;
return V;
}
*/
}
*/

@ -1,29 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iut.h"
int main(){
int n,nc;
int n, nc, codeErr, rootChoice=1, choix;
char sauv;
VilleIUT *tiut[200];
Candidat *tcandidat[200];
//afficher(V);
n=chargement(tiut ,200);
printf("Nombre de villes : %d\n",n);
affichage(tiut,n);
nc=chargementcandidat(tcandidat ,200);
printf("\nNombre de candidat : %d\n",nc);
affichageCandidatchoix(tcandidat,nc);
printf("\nNombre de candidat : %d\n",nc);
while(rootChoice==1){
system("cls"); // pour Windows
system("clear"); // pour Unix
printf("\t\tTableau Ville et departement\n");
affichage(tiut,n);
printf("\n\n\n\t\tTableau Candidat et choix\n");
affichageCandidatchoix(tcandidat,nc);
printf("\n\nUtilisateur - 1\tAdministrateur - 2\tSauvegarder et quitter - 3\n\n");
scanf("%d",&choix);
if(choix==1){
printf("\nMenu Utilisateur");
MenuUtilisateur(tiut, n);
}
if(choix==2){
printf("\nMenu Administrateur");
MenuAdministrateur(tiut,n);
}
if(choix==3){
printf("\tVoulez vous sauvegarder? (O/N) : ");
scanf("%c%*c",&sauv);
if(sauv=='O')
//codeErr = fsauvegarde(t1, t2, t3,t4,t5, tAct, tNbEntree, &n, LEN, choix);
printf(">----------------------------------------<\n\n");
printf("\tTous les fichiers sauvegardés.\n\n");
printf("\tMerci de votre visite.\n\n");
printf("\t- Fin de journée -\n\n");
printf(">----------------------------------------<\n");
rootChoice = 0;
int choix;
printf("\n\nUtilisateur - 1\tAdministrateur - 2\n\n");
scanf("%d",&choix);
if(choix==1){
printf("\nMenu Utilisateur");
MenuUtilisateur(tiut, n);
}
if(choix==2){
printf("\nMenu Administrateur");
MenuAdministrateur(tiut,n);
}
}
}

Loading…
Cancel
Save