création des fonction d'admin et modification du fichier SAEl.c fonction recherche

master
Alexis LAURENT 2 years ago
parent 98e0803a83
commit 04697876ff

101
SAE.c

@ -36,6 +36,7 @@ bool verifQuit(void)
return true;
if (strcmp(choix,"non")==0)
return false;
printf("Erreur de sélection ! Veillez réessayer \n")
}
}
@ -50,9 +51,24 @@ bool verifSelection(void)
return true;
if (strcmp(choix,"non")==0)
return false;
printf("Erreur de sélection ! Veillez réessayer \n")
}
}
bool confirmationSup(void)
{
char choix[4];
while(1)
printf("Êtes-vous sûr de vouloir supprimer/moddifié : ");
scanf("%s", choix);
if (strcmp(choix,"oui")==0)
return true;
if (strcmp(choix,"non")==0)
return false;
printf("Erreur de sélection ! Veillez réessayer \n")
}
int menuUtilisateurAffiche(void)
{
int choix;
@ -267,7 +283,7 @@ void AffichageNbplaceDeptVille(VilleIUT **tiut, int nbEle)
}
}
else printf("Cette Ville n'as pas d'IUT (exit -> pour quitter)\n");
else printf("Cette Ville n'as pas d'IUT\n");
}
free(aux);
}
@ -300,19 +316,24 @@ void AffichageDeptVille(VilleIUT **tiut, int nbEle)
ListeDept *aux;
aux =(ListeDept *)malloc(sizeof(ListeDept));
char code[30];
int pos, nbocc = 0;
int pos = 0, nbocc = 0;
while(1)
{
printf("IUT : ");
printf("département : ");
scanf("%s",code);
aux = tiut[pos]->idDept;
printf("\nIUT ayant un département %s : \n",code);
for(pos = 0; pos < nbEle; pos++)
{
aux = tiut[pos]->idDept;
while(aux != NULL)
{
if(strcmp(aux->departement, code)==0)
{
affichageListeDept(aux)
nbocc = nbocc + 1;
break;
}
aux = aux->suiv;
}
}
if (nbocc == 0)
@ -333,10 +354,9 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
printf("IUT : ");
scanf("%s",code);
pos = rechVille(tiut, nbEle, code,&trouve);
aux = tiut[pos]->idDept;
if (trouve == 1)
{
aux = tiut[pos]->idDept;
while(1)
{
printf("Département : ");
@ -347,8 +367,8 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
{
printf("Ancien nombre de places : %d",tiut[pos]->idDept->nbPers);
printf("Nouveau nombre de places : ", nouvNbPlace);
scanf("%d", &nouvNbPlace)
tiut[pos]->idDept->nbPers = nouvNbPlace
scanf("%d", &nouvNbPlace);
tiut[pos]->idDept->nbPers = nouvNbPlace;
printf("Mise à jour effectuer avec succès !");
break;
}
@ -363,6 +383,71 @@ void MiseAJourNbPlace(VilleIUT **tiut, int nbEle)
}
}
free(aux);
}
void creationDept(VilleIUT **tiut, int nbEle)
{
char code[30], nom[30];
int trouve, pos, nbP;
while(1)
{
printf("Dans quel IUT voulez-vous créer un département : ");
scanf("%s", code);
pos = rechVille(tiut, nbEle, code, &trouve);
if (trouve == 1)
{
while(1)
{
printf("Nom du Département : ");
scanf("%s", code);
if (recherche(tiut[pos]->idDept, code))
printf("Département déjà existant");
if (!recherche(tiut[pos]->idDept, code))
printf("Nom du Responsable du Département de %s : ",code);
fgets(nom,30,stdin);
nom[strlen(nom)-1] = "\0";
printf("Nombre de place du Département %s : ",code);
scanf("%d", nbP);
tiut[pos]->idDept = inserer(tiut[pos]->idDept,code,nom,nbP)
printf("insertion du département %s effectuer \n", code);
if (!verifSelection())
break;
}
}
if (trouve == 0)
printf("Cet ville n'a pas d'IUT\n");
if(!verifSelection())
break;
}
}
void suppressionDept(VilleIUT **tiut, int nbEle)
{
char code[30];
int trouve, pos, nbP;
while(1)
{
printf("Dans quel IUT voulez-vous supprimer un département : ");
scanf("%s", code);
pos = rechVille(tiut, nbEle, code, &trouve);
if (trouve == 1)
{
printf("Nom du Département : ");
scanf("%s", code);
if (recherche(tiut[pos]->idDept, code))
if (confirmationSup())
tiut->idDept = supprimer(tiut->idDept, code);
if (!recherche(tiut[pos]->idDept, code))
printf("Ce Département n'existe pas dans l'IUT de %s \n",tiut[pos]->ville);
if (!verifSelection())
break;
}
}
}
void clearpage(void)

@ -181,14 +181,16 @@ ListeDept inserer(ListeDept l, char *dept, char *nom, int nbP)
// return cpt;
// }
// bool recherche(ListeDept l, char code[], int *pos)
// {
// if (l == NULL)
// return false;
// if (strcmp(l->departement, code)==0)
// return true;
// return recherche(l->suiv, x);
// }
bool recherche(ListeDept l, char code[])
{
if (l == NULL)
return false;
if ((strcmp(code,l->departement)) < 0)
return false;
if (strcmp(code,l->departement)==0)
return true;
return recherche(l->suiv, x);
}
// ListeDept ajouterEnQueue(ListeDept l, int x)
// {

Loading…
Cancel
Save