@ -56,52 +56,47 @@ int login(void)
//################# fonctions affichage ###########################
void afficherPlace ( MaillonDept m )
void afficherPlace ( Departement d )
{
printf ( " \n Pour ce département il y a %d places en 1ère année \n \n " , m . nbP ) ;
printf ( " \n Pour ce département il y a %d places en 1ère année \n \n " , d . nbP ) ;
}
/*
//################## fonctions insertion #########################
int insererDept ( VilleIUT v , MaillonDept m )
void afficherVilleDep ( VilleIUT v )
{
int trouve ;
MaillonDept * pos ;
pos = rechercheDept ( v . lDept , & trouve , m . dept ) ;
if ( trouve = = 0 )
ListeDept l ;
printf ( " _________________________________________________________________________________________________________________ \n " ) ;
printf ( " | Ville | Département | \n " ) ;
printf ( " |----------------------------------|----------------------------------------------------------------------------| \n " ) ;
l = v . lDept ;
while ( l ! = NULL )
{
printf ( " \n Département déjà présent dans cet IUT \n " )
return - 1 ;
printf ( " | %-32s | %-32s | %3d | %-32s | \n " , v . nom , l - > d . dept , l - > d . nbP , l - > d . respAd ) ;
printf ( " |----------------------------------|----------------------------------------------------------------------------| \n " ) ;
l = l - > suiv ;
}
m - > suiv = pos ;
pos = & m ;
return 1 ;
}
//################# fonctions recherche #########################
MaillonDept * rechercheDept ( ListeDept lDept , int * trouve , char nom [ ] )
{
while ( lDept - > suiv ! = NULL )
{
if ( strcmp ( nom , lDept - > dept ) = = 0 )
void afficherDep ( Departement d )
{
* trouve = 1 ;
return lDept ;
printf ( " _____________________________________________________________________________ \n " ) ;
printf ( " | Département | \n " ) ;
printf ( " |----------------------------------------------------------------------------| \n " ) ;
printf ( " | %-32s | %3d | %-32s | \n " , d . dept , d . nbP , d . respAd ) ;
printf ( " |----------------------------------------------------------------------------| \n " ) ;
}
if ( strcmp ( nom , lDept - > dept ) < 0 )
//################ fonction liste ######################################
bool vide ( ListeDept lDept )
{
* trouve = 0 ;
return lDept ;
}
lDept = lDept - > suiv ;
}
* trouve = 0 ;
return lDept ;
if ( lDept = = NULL )
return true ;
return false ;
}
*/
//################# fonctions recherche #########################
int rechercheIUT ( VilleIUT * tiut [ ] , int tLog , char ville [ ] , int * trouve )
{
@ -124,3 +119,141 @@ int rechercheIUT(VilleIUT *tiut[], int tLog, char ville[], int *trouve)
return inf ;
}
ListeDept rechercherDept ( ListeDept lDept , char dept [ ] , int * trouve )
{
if ( vide ( lDept ) )
{
* trouve = 0 ;
return lDept ;
}
if ( strcmp ( dept , lDept - > d . dept ) < 0 )
{
trouve = 0 ;
return lDept ;
}
if ( strcmp ( dept , lDept - > d . dept ) = = 0 )
{
* trouve = 1 ;
return lDept ;
}
return rechercherDept ( lDept - > suiv , dept , trouve ) ;
}
//#################### fonction mise à jour ############################
/*void miseAJourPlaces(VilleIUT *tiut[], int tLog)
{
int places ;
char ville [ 31 ] , dept [ 31 ] , choix ;
ListeDept l ;
printf ( " Dans quelle ville se situe le département concerné ? \n Saisie : " ) ;
scanf ( " %s%*c " , ville ) ;
printf ( " \n " ) ;
pos = rechercheIUT ( tiut , tLog , ville , & trouve ) ;
while ( trouve = = 0 )
{
printf ( " Cette ville n'existe pas, veuillez re-saisir : " ) ;
scanf ( " %s%*c " , ville ) ;
printf ( " \n " ) ;
pos = rechercheIUT ( tiut , tLog , ville , & trouve ) ;
}
l = tiut [ pos ] - > lDept ;
printf ( " Quel département souhaitez-vous mettre à jour ? \n Saisie : " ) ;
scanf ( " %s%*c " , dept ) ;
printf ( " \n " ) ;
l = rechercherDept ( l , dept , & trouve ) ;
while ( trouve = = 0 )
{
printf ( " Ce département n'existe pas, veuillez-resaisir : " ) ;
scanf ( " %s%*c " , dept ) ;
printf ( " \n " ) ;
l = rechercherDept ( l , dept , & trouve ) ;
}
printf ( " Vous avez sélectionné le département %s dans la ville de %s. \n Souhaitez-vous continuez ? (O/N) \n Saisie : " , dept , ville ) ;
scanf ( " %c%*c " , & choix ) ;
printf ( " \n " ) ;
if ( choix = = ' N ' )
{
return ;
}
printf ( " Il y a actuellement %d places. \n Quel est le nouveau nombre de places ? \n Saisie : " , l - > d . nbP ) ;
scanf ( " %d%*c " , & places ) ;
printf ( " \n Vous avez saisie %d places, veuillez confirmez (O/N) \n Saisie : " , places ) ;
scanf ( " %c%*c " , & choix ) ;
printf ( " \n " ) ;
if ( choix = = ' O ' )
{
l - > d . nbP = places ;
printf ( " La mise à jour a bien été effectuée. \n " ) ;
}
return ;
} */
void miseAJourNomDept ( Departement d , ListeDept l )
{
int trouve ;
char nomDept [ 31 ] , choix = ' n ' ;
system ( " clear " ) ;
afficherDep ( d ) ;
while ( choix ! = ' o ' )
{
printf ( " \n \n Quel est le nouveau nom du département? \n " ) ;
fgets ( nomDept , 31 , stdin ) ;
nomDept [ strlen ( nomDept ) - 1 ] = ' \0 ' ;
rechercherDept ( l , nomDept , & trouve ) ;
if ( trouve = = 1 )
}
}
void miseAJourGlobale ( VilleIUT * tiut [ ] , int tLog )
{
int trouve , pos , choix = 0 ;
char ville [ 31 ] , dept [ 31 ] ;
MaillonDept * m ;
Departement d ;
printf ( " Dans quelle ville voulez-vous faire des mises à jour? \t " ) ;
scanf ( " %s " , ville ) ;
pos = rechercheIUT ( tiut , tLog , ville , & trouve ) ;
if ( trouve ! = 1 )
{
printf ( " \n \n Cette ville n'existe pas \n " ) ;
clearpage ( ) ;
return ;
}
afficherVilleDep ( * tiut [ pos ] ) ;
printf ( " Quel département de %s voulez-vous modifier? \t " , ville ) ;
scanf ( " %s " , dept ) ;
m = rechercherDept ( tiut [ pos ] - > lDept , dept , & trouve ) ;
d = m - > d ;
if ( trouve ! = 1 )
{
printf ( " \n \n Ce département n'existe pas dans cette ville \n " ) ;
clearpage ( ) ;
return ;
}
afficherDep ( d ) ;
printf ( " \n \n " ) ;
while ( choix ! = 9 )
{
printf ( " ################### Menu des mises à jour ################### \n " ) ;
printf ( " \n \t 1.Mise à jour du nom du département \n \t 2.Mise à jour des places du département \n \t 3.Mise à jour du responsable du département \n \t 9.Quitter \n \n " ) ;
printf ( " \t Saisie: \t " ) ;
scanf ( " %d " , & choix ) ;
if ( choix = = 1 )
{
miseAJourNomDept ( d , tiut [ pos ] - > lDept ) ;
}
if ( choix = = 2 )
{
miseAJourPlaces ( d ) ;
}
if ( choix = = 3 )
{
miseAJourResp ( d ) ;
}
}
clearpage ( ) ;
afficherDep ( d ) ;
}