Projet gestion de personel

cs_ahmeddrira Messages postés 3 Date d'inscription samedi 3 mars 2007 Statut Membre Dernière intervention 6 mai 2009 - 2 mai 2007 à 07:21
cs_ahmeddrira Messages postés 3 Date d'inscription samedi 3 mars 2007 Statut Membre Dernière intervention 6 mai 2009 - 2 mai 2007 à 21:22
drira ahmed



svp les amis  aidez moi a c

o

riger ce programe
c est mon projet de fin d etude
 c est petit mais il m a causer beaucoup de prob 
voisi le code source
svp pas de complication

#include<stdio.h>
#include<string.h>
#include<econio.h>
#include<econio.cpp>
#include<conio.h>
FILE *fp;
char nonsauv[10], /**np[999]={"ahmed drira","ali jaber","bilel","mohamed ali","ahmed","bilel amar"},*/ch1[20],*p1,*p2,/*cod[999]={"e25","e25","c20","e20","c10","c20"},ch2[20],*/ch3[20],*tempe[999][8];
int choix,ok,x,y,k,h,a,i,j,n ,salaire,id,/*date[999][3]={{3,3,2000},{5,5,1987},{5,8,9871},{6,5,1980},{5,6,2000},{20,3,1987}},*/choi,jour=0,moi=0,anne=0,/*ident[999]={1,2,3,4,5,6},nb[999]={0,1,0,2,0,0},*/temp;
char tape;
//**************************************
typedef struct employe//****
{char *np,*cod;       //****
int date[3];          //****//structur  employeé
int ident,nb;}employ; //****
employ tab[999];      //****//tableua de type structure qui contien tous les employeé
//***********************************************************************************************
//***********************************************************************************************
void enregistrer()                               //**
{   do{                                          //**
    fp=fopen("c:\\fich.txt","a+");}while(!fp);   //**
                                                 //**//fonction d enregistrement
for(j=0;j11)
printf("choix invalide");
}while(choix<1||choix>11);// VALIDITé DU CHOIx
}//***********************************************************************************************
//***********************************************************************************************
void ajoutpersonne()//ajout personne et leur enfant
{
    printf("vous avez choisie d ajouter une personne\n\n");
i++;//incrimentation du nombre de personne
 printf("ENTRER LE NON / LE PRENOM DE LA PERSONNE A AJOUTER\n");
 do{fflush(stdin);gets(ch1);

for(p1=ch1;p1<ch1+strlen(ch1);p1++)//test si le non prenom entrer son séparé par un espace
{ok=0;if(isspace(*p1)!=0) {ok++;break;}}//**
if(ok!=1)
printf("le nom prenom entrer contien plus qu un espace ou ne contien pas ");
else
{(tab[i].np)=(char*)malloc(strlen(ch1)*sizeof(char));
strcpy(tab[i].np,ch1);}}while(ok!=1);

printf("entrer la date de naissance de cette personne jour/moi/ann\202\n");
do{printf("entrer le jour\t");//test sur la validité de la date
fflush(stdin);
scanf("%d",&jour);
printf("entrer le moi\t");
scanf("%d",&moi);
printf("entrer l ann\202\t");
scanf("%d",&anne);}
while((jour>31||jour<1||moi<1||moi>12)||anne>1990||anne<1947||((moi==4||moi==6||moi==8||moi==9||moi==11)&&jour==31)||((moi==2)&&(anne%4==0)&&(jour>28))||((moi==2)&&(anne%4!=0)&&(jour>29))) ;
//affectation
tab[i].date[0]=jour;//
tab[i].date[1]=moi;//****affection
tab[i].date[2]=anne;//
printf("entrer l identifiant de cet personne de la forme <<xxxx>>\t");
do{scanf("%d",&tab[i].ident);
if(tab[i].ident>999||tab[i].ident<0)
printf("\aidentifiant invalide");}
while(tab[i].ident>999||tab[i].ident<0);//test sur l identifiant
printf("entrer le code <<GRADE/NOMBRE D HEURE DE TRAVAIL>>\t");
do{ok=0;gets(ch1);
if((*ch1=='e'||*(ch1)=='c')&&isdigit(*(ch1+1))!=0&&isdigit(*(ch1+2))!=0)
ok=1;}while(ok==0);// test sur entrer du cod caractere /entier
tab[i].cod=ch1;
printf("entrer le nombre d enfant de cet personne qui travaille dans la societ\202");
do{scanf("%d",&tab[i].nb);
}while(tab[i].nb<0||tab[i].nb>8);

x=tab[i].nb;
for(j=0;j<x;j++)
{printf("entrer les non des enfant de cet personne\n");fflush(stdin);
i++;
printf("entrer le non de l enfant numero %d \t",j+1);
fflush(stdin);gets(ch1);
tab[i].np=(char*)malloc(strlen(ch1)*sizeof(char));
strcpy(tab[i].np,ch1);
printf("\nentrer sa date de naissance\n\n");

do{printf("entrer le jour\t");//test sur la validité de la date
fflush(stdin);
scanf("%d",&jour);
printf("entrer le moi\t");
scanf("%d",&moi);
printf("entrer l ann\202\t");
scanf("%d",&anne);}
while((jour>31||jour<1||moi<1||moi>12)||anne>1990||anne<1947||((moi==4||moi==6||moi==8||moi==9||moi==11)&&jour==31)||((moi==2)&&(anne%4==0)&&(jour>28))||((moi==2)&&(anne%4!=0)&&(jour>29))) ;
//affectation
tab[i].date[0]=jour;
tab[i].date[1]=moi;
tab[i].date[2]=anne;

printf("entrer l identifiant de cet personne\t");
do{fflush(stdin);scanf("%d",&tab[i].ident);
if(tab[i].ident>999||tab[i].ident<0)
printf("identifiant invalide");}
while(tab[i].ident>999||tab[i].ident<0);//test sur l identifiant
printf("entrer le code <<GRADE/NOMBRE D HEURE DE TRAVAIL>>\t");
do{ok=0;gets(ch1);
if((*ch1=='e'||*(ch1)=='c')&&isdigit(*(ch1+1))!=0&&isdigit(*(ch1+2))!=0)
ok=1;}while(ok==0);// test sur entrer du cod caractere /entier
tab[i].cod=ch1;
tab[i].nb=0;
}
}

///***********************************************************************************************
//***********************************************************************************************
void ajoutenfant()
{do{
    fp=fopen("c:\\fich.txt","a+");}while(!fp);

    printf("vous avez choisie d ajouter les enfant d une personne\n\n");
printf("entrer l identifiant de la personne a ajouter les enfant\t");
do{ok=0;
scanf("%d",&id);
for(j=0;jj;k++)
{    tab[k+1].np=tab[k].np;
//tab[k+1].np=tab[k].np;
tab[k+1].nb=tab[k].nb;////////////**
tab[k+1].date[0]=tab[k].date[0];//**
tab[k+1].date[1]=tab[k].date[1];//**affectation
tab[k+1].date[2]=tab[k].date[2];//**
tab[k+1].ident=tab[k].ident;//////**
tab[k+1].cod=tab[k].cod;}/////////**

}

for(k=tab[j].nb;k<(tab[j].nb)+n;k++)
{i++;
printf("ajouter le non de l enfant numero %d",k+1);
gets(ch1);
tab[i].np=(char*)malloc(strlen(ch1)*sizeof(char));
strcpy(tab[i].np,ch1);

tab[j].nb+=n;
}

}

//***********************************************************************************************
//***********************************************************************************************
void suprimer()
{printf(" vous avez choisie de suprimer une personne");
    printf("entrer l identiant de la personne a suprimer");
do{ok=0;
scanf("%d",&id);
for(j=0;j0)
{for(h=j;h<(tab[j].nb)+j;h++)
{printf("lenfant numero %d s apelle %s",h+1,tab[h].np);}}//*****

}

void recherche()
{printf("vous avez choisi de chercher une personne par son non ou pr\202nom\n");
printf(" entrer le non et prenom de la personne a re chercher\t");fflush(stdin);
gets (ch1);
for(j=0;j0)
{for(k=j+1;k<j+1+tab[j].nb;k++)
{printf("l enfant %d s appelle %s \n",k-j,tab[k].nb);}
}break;

}//fin if

}//fin for
if(ok==0)

printf("le non entrer n existe pas");
   
}
//***********************************************************************************************
//***********************************************************************************************
void age()
{printf("vous avez choisie de retourner l age d une personne\n");

printf("entrer l identiant de la personne a retourner l age\t");
do{ok=0;fflush(stdin);
scanf("%d",&id);
for(j=0;j31||jour<1||moi<1||moi>12)||((moi==4||moi==6||moi==8||moi==9||moi==11)&&jour==31)||((moi==2)&&(anne%4==0)&&(jour>28))||((moi==2)&&(anne%4!=0)&&(jour>29))) ;
if(moi-tab[j].date[1]<0)
{x=anne-tab[j].date[2]-1;
y=12+(moi-tab[j].date[1]);}

printf("l age de cet personne a %d ann\202 et %d moi ",x,y);

}
void salaireper()
{printf("vous avez choisi de retourner le salaire d une personne");
printf("entrer l identiant de la personne a retourner le salaire\t");
do{ok=0;fflush(stdin);
scanf("%d",&id);
for(j=0;j31||jour<1||moi<1||moi>12)||((moi==4||moi==6||moi==8||moi==9||moi==11)&&jour==31)||((moi==2)&&(anne%4==0)&&(jour>28))||((moi==2)&&(anne%4!=0)&&(jour>29))) ;
tab[j].date[0]=jour;
tab[j].date[1]=moi;
tab[j].date[2]=anne;
      printf("\napuiez sur une touche pour passer au menue\n");
getch();
goto men;
       }
case 3:{printf("vous avez choisi de modifier l identifiant");
    printf("entrer le nouveau identifian");
    fflush(stdin);scanf("%d",&tab[j].ident);
printf("\napuiez sur une touche pour passer au menue\n");
getch();
goto men;
       }
case 4:{printf("vous aver choisi de modifier le nombre d enfant\n");
    printf("entrer le nouveau nombre de enfant  \t");
    scanf("%d",&ok);
    if(ok>tab[j].nb)
    {for(h=0;h<ok-tab[j].nb;h++)
    {   for(k=i;k>j;k--)
    {tab[k+1].np=tab[k].np;
    tab[k+1].np=tab[k].np;
    tab[k+1].nb=tab[k].nb;
    tab[k+1].date[0]=tab[k].date[0];
    tab[k+1].date[1]=tab[k].date[1];
    tab[k+1].date[2]=tab[k].date[2];
    tab[k+1].ident=tab[k].ident;
    tab[k+1].cod=tab[k].cod;                     //decalage pour ajouter les enfants
       
    x=j;   
       
        printf("entrer le non de l enfant numero %d",h+1);
        fflush(stdin);gets(ch1);
        tab[x+1].np=(char*)malloc(strlen(ch1)*sizeof(char));
        strcpy(tab[x+1].np,ch1);
        x++;
   
   
    }}
   
       }//fin de if
       else
           if(ok<tab[j].nb)
           {printf("vous avez duminuez le nombre d enfant\n");
           printf("vous devez ajuster les non des enfant qui travaille dans la societ\202\n");
           printf("lidentifiant du pere ou mere est %d",tab[j].ident); 
          
          
          
           }
      printf("\napuiez sur une touche pour passer au menue\n");
getch();
goto men; }//***fin case 4
case 5:{printf("vous avez choisi de modifier les nons des enfants\n");
printf("l identifiant de la personne choisie possede %d enfant\n",tab[j].nb);
for(h=j;h<=(j+tab[j].nb);h++)
printf( "%d)%s",tab[h].ident,tab[h].np);
do{ printf("entrerle numero que vous voulez modifiez le non");
       fflush(stdin);scanf("%d",&ok);fflush(stdin);
       gets(ch1);tab[j+ok].np=(char*)malloc(strlen(ch1)*sizeof(char));strcpy(tab[j+ok].np,ch1);
printf("non modifier");
printf("si vous voulez changer un autr non tapez 1");
scanf("%c",&tape);}
while(tape=='1');

      
    printf("\napuiez sur une touche pour passer au menue\n");
getch();
goto men;  
       }
case 6:{printf("vous avez choisi de modifier le code de cet employ\202\n");
printf("entrer le nouveau cod\t");   
      
       do{ok=0;gets(ch1);
if((*ch1=='e'||*(ch1)=='c')&&isdigit(*(ch1+1))!=0&&isdigit(*(ch1+2))!=0)
ok=1;}while(ok==0);
tab[j].cod=ch1;
      
      
       }printf("\napuiez sur une touche pour passer au menue\n");
getch();
goto men;

}

getch();}
//***************************************************************************************************+
//****************************************************************************************************
void trie()
{printf("vous avez choisie de trier la liste\n");
for(h=0;h0)//**********permutation
{strcpy(ch1,tab[h].np);
tab[h].np=(char*)malloc(strlen(tab[k].np)*sizeof(char));
strcpy(tab[h].np,tab[k].np);
tab[k].np=(char*)malloc(strlen(ch1)*sizeof(char));
strcpy(tab[k].np,ch1);

printf("********");

jour=tab[h].date[0];tab[h].date[0]=tab[k].date[0];tab[k].date[0]=jour;
moi=tab[h].date[1];tab[h].date[1]=tab[k].date[1];tab[k].date[1]=moi;
anne=tab[h].date[2];tab[k].date[2]=tab[h].date[2];tab[h].date[2]=anne;

temp=tab[h].ident;
tab[h].ident=tab[k].ident;
tab[k].ident=temp;

temp=tab[h].nb;tab[h].nb=tab[k].nb;tab[k].nb=temp;
strcpy(ch1,tab[h].cod);
tab[h].cod=(char*)malloc(strlen(tab[k].cod)*sizeof(char));
strcpy(tab[h].cod,tab[k].cod);
tab[k].cod=(char*)malloc(strlen(ch1)*sizeof(char));
strcpy(tab[k].cod,ch1);

}//***fin du if

}//**fin du for du k

}//fin du for du h 
}
void main()
{printf("\t\t\t\tBIEN VENUE\n\n\n");
printf("SI VOUS VOULEZ OUVRIR UNE SAUVGARDE TAPEZ [s] \n\nSINON TAPEZ [n] POUR CREE UNE NOUVELLE SAUVGARDE\t");
do{scanf("%c",&tape);}while(tape!='n'&&tape!='s');       
if(tape=='s')
{do{fp=fopen("c:\\fich.txt","r");}while(!fp);//ouverture du fichier en mode lecture
for(i=0;(!feof(fp));i++)//***test sur la fin du fichier
{fread(&tab[i],sizeof(employ),1,fp);}//copie de continue du fichier dans le programe(mémoire)
fclose(fp);//fermuture du programe
if(!i)printf("votre suavgarde n existe pas!!\n\n vous avez cre\202 une nouvelle sauvgarde\n");
printf("Appuiez sur une touche pour commensez\n");
getch();

}

    do{menu:
menu();
//***********************************************************************************************
//***********************************************************************************************
if(choix==1)
{clrscr();
do{
ajoutpersonne();

printf("si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez ajouter un autre personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);
enregistrer();
}
else if(tape=='m')
goto menu;
}while(tape=='a');}//fin (1)
else
//******************************************************************************************
//******************************************************************************************
if(choix==2)

{do{ajoutenfant();
printf("si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez ajouter les enfants d une autre personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;
}while(tape!='a');

}//***fin du if  2

//**fin du elese 1
//***********************************************************************************************
//***********************************************************************************************
else if(choix==3)
{do{suprimer();
   
   
   
    printf("si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez suprimer une autre personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;

}while(tape!='a');}//**fermuture du if 3

//***fin else 3
//***********************************************************************************************
//***********************************************************************************************
else 

if(choix==4)
{do{consulter();
printf("\n\n si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez consulter une autre personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;

}while(tape!='a');

}//*****fin   if 4

//***********************************************************************************************
//***********************************************************************************************
else if(choix==5)
{do{recherche();

printf("\n\n si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez chercherun autre personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else
if(tape=='m')
goto menu;

}while(tape!='a');

}//***fin du if 5
//***********************************************************************************************
//***********************************************************************************************
else if(choix==6)
{do{consulter();
printf("\n\n si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez retourner les informations sur les enfants d une personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;

}while(tape!='a');

}//*fin if choix 6
//***********************************************************************************************
//***********************************************************************************************
else 
if(choix==7)
{do{infopere();
printf("vous avez choisi de retourn\202 le non de pere ou de mere  d une personne");
printf("entrer le non de lenfant<<seulement le non>>");
fflush(stdin);
do{gets(ch1);ok=0;
for(j=0;j>",tab[h].np);
 

printf("\n\n si vous voulez quitter tapez 'q'\n si vous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez retourner le non de pere ou de mere d un enfant tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else
if(tape=='m')
goto menu;

}while(tape!='a');

}//****fin choi 7
//***********************************************************************************************
//***********************************************************************************************
else
if(choix==8)
{do{age();
printf("\n\n si vous voulez quitter tapez 'q'\nsivous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez retourner l age d une personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;

}while(tape!='a');
}//**fin choix 8
//***********************************************************************************************
//***********************************************************************************************
else
if(choix==9)
{do

{salaireper();

printf("\n\n si vous voulez quitter tapez 'q'\n si vous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez retourner le salaire d une personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}

}while(tape!='a');

}//**fin choi 9
else if(choix==10)
{do{retourinfo();
printf("\n\n si vous voulez quitter tapez 'q'\n si vous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez modifiez les information d une autre personne tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;

}while(tape!='a');

}//****fin choix 10

//***********************************************************************************************
//***********************************************************************************************
else
if(choix==11)
{do{clrscr();trie();
printf("\n\n si vous voulez quitter tapez 'q'\n si vous voulez revenir au menu tapez 'm'\n");
printf("si vous voulez trier une autre foix tapez 'a'\n");
do{scanf("%c",&tape);}while(tape!='a'&&tape!='q'&&tape!='m');
if(tape=='q')
{exit(-1);enregistrer();}
else if(tape=='m')
goto menu;

}while(tape!='a');

}//****fin de if  choix 11

}while(tape=='m');

}///***********************************************************************************************
//***********************************************************************************************
//*************************************************************************************************

1 réponse

cs_ahmeddrira Messages postés 3 Date d'inscription samedi 3 mars 2007 Statut Membre Dernière intervention 6 mai 2009
2 mai 2007 à 21:22
drira ahmed




aider moi svp
0
Rejoignez-nous