dimanche 17 octobre 2010

gestion des stagaire.cpp




                                         download:projet_de_gestien_des_stagaire.exe
#include <stdio.h>
#include <conio.h>
#include<stdlib.h>
#include<string.h>
#include<io.h>
FILE *index;
FILE *casanova;
char rep;
struct stagiaire

{
       char nom[20];
       char prenom[20];
       int mtr;
      char dn[20];
       };
       stagiaire stg;
FILE *absence;
    struct  sabsence
        {char dat[20];
        char duree[20];
        int mtr;
        char motif[20];
        int nmb;
        };
       sabsence abse;  
       int i,n;
   
          /************************************ajout****************************************/
       void ajout()
        {  int tr,mr;
        char aj;
            aj='o';
            while(aj=='o')
       {tr=1;      
         index = fopen("C:\\Documents and Settings\\test.txt","r");
         if(!index)
         {index = fopen("C:\\Documents and Settings\\test.txt","w");
       }
         else
         {system("cls");
               while(tr==1)
      {printf("tapez le mtr :");
             scanf("%d",&mr);
         index = fopen("C:\\Documents and Settings\\test.txt","r");
           while (!feof(index))
              {
               fscanf(index,"%s%s%d%s",stg.nom,stg.prenom,&stg.mtr,stg.dn);
               tr=2;
             if(mr==stg.mtr)
              { tr=1;  printf("ce matricule exist dèja\n");break;}}  fclose(index);    }
        
         index = fopen("C:\\Documents and Settings\\test.txt","a+");
         stg.mtr=mr;
         printf("tapez le nom ");
         scanf("%s",&stg.nom);
         printf("tapez le prenom ");
         scanf("%s",&stg.prenom);
         printf("tapez le dn ");
         scanf("%s",&stg.dn);
         fprintf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);
         system("cls");
         printf("voulez vous ajauter une autre parametre o/n :");
         scanf("%s",&aj);
          fclose(index);
        }}
          system("cls");
         }
 
         /***************************************consultation***********************************/
         void consultation()
      { int k;
               index = fopen("C:\\Documents and Settings\\test.txt","r");
               system("cls");
              k=0;
            while(!feof(index))
              { fscanf(index,"%s%s%d%s",&stg.nom,&stg.prenom,&stg.mtr,&stg.dn);                 
               if(stg.mtr==k)
            {break;}
             k=stg.mtr;
              printf("*********\nNom :%s\nprénom :%s\nmatricule :%d\nDate naissance :%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);
          
           
             }
             fclose(index);
             getch();}
        /**************************************Rechercher***************************************/
        void recherch()
        { int matt,test,mt;
        char ch[20],*nom,*prenom,*dan;
         int trv,choix;
          index = fopen("C:\\Documents and Settings\\test.txt","r");
          system("cls");
          printf("entrer le critaire 1: nom/2:prenom/3:matricule/4:date de naissance");           
          scanf("%d",&choix);
          if(choix==1)
              {
              printf("entrezle nom");
              scanf("%s",&ch);
     
                   while(!feof(index))
                      {
                   fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);
                   test=strcmp(stg.nom,ch);
                   if(test==0)
                   {
                   trv=1;
                   break;
                  } }}
          if(choix==2)
               {
              printf("entrez le prénom");
              scanf("%s",&ch);
     
                   while(!feof(index))
                     {
                   fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);
                   test=strcmp(stg.prenom,ch);
                   if(test==0)
                   {
                   trv=1;
                   break;
                   } }}                             
         if(choix==3)
              {
               printf("entrez le matricule");
               scanf("%d",&matt);
                   while(!feof(index))
                   {
                   fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);
                   if(stg.mtr==matt)
                   {
                   trv=1;
                   break;
                   }}}
       if(choix==4)
              {
              printf("entrez la date de naissance");
              scanf("%s",&ch);
     
                   while(!feof(index))
                    {
                  fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);
                  test=strcmp(stg.dn,ch);
                  if(test==0)
                  {
                  trv=1;
                  break;
                  }  }}                            
      if(trv==1)            
               { printf("*********\nNom :%s\nprénom :%s\nmatricule :%d\nDate naissance :%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);     }
      else            
               { printf("n'existe pas \n"); }         
                      
           fclose(index);
            getch();
            system("cls");   }
    /***********************************supprimer******************************************/
                void sup()
                {
                     int sp,tr;
                     char bo;
                     index = fopen("C:\\Documents and Settings\\test.txt","r");
                     casanova = fopen("C:\\Documents and Settings\\text.txt","w");
                     printf("entrez le matricule que tu veux supprimer :");
                     scanf("%d",&sp);
                     while(!feof(index)){
                                   fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);  
                                   if(stg.mtr==sp){
                                          tr=1;        
                                   printf("*********\nNom :%s\nprénom :%s\nmatricule :%d\nDate naissance :%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);
                                   break;}}
                                   if(tr==1){
                     printf("ete vous sur o/n");
                     scanf("%s",&bo);
                     if(bo=='o'){
                     while(!feof(index))
                    { fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);  
                     
                     if(sp!=stg.mtr)
                  { 
                       fprintf (casanova,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);  
                      }}
                      fclose(casanova);
                      fclose(index);
                      remove("C:\\Documents and Settings\\test.txt");
                      rename("C:\\Documents and Settings\\text.txt","C:\\Documents and Settings\\test.txt");
                      system("cls");
                       printf("\n\n\n !!!le parametre de stagiaire qui porte le matricule [%d] est supprimer !!!\n ",sp);
                       printf("\t\tpress entrez pour returnez ou menu principal\n");
                    
                       }
                       }
                      else{printf("\t\t!!!!ce matricule n'exist pas");}  getch();
                       }
     
           /****************************modifier******************************************/
           void modifier()
            {int trv,matt,mt,oix;
            char s,*nom,*pre,*da;
       casanova = fopen("C:\\Documents and Settings\\text.txt","w");
               printf("entrez le matricule de stagaire");
               scanf("%d",&matt);
    { index = fopen("C:\\Documents and Settings\\test.txt","r");
                while(!feof(index))
                    { fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);
                     if(matt!=stg.mtr)
                  {   fprintf (casanova,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);}}
    fclose(index);}
    index = fopen("C:\\Documents and Settings\\test.txt","r");
                   while(!feof(index))
                    { fscanf(index,"\n%s\n%s\n%d\n%s\n",stg.nom,stg.prenom,&stg.mtr,&stg.dn);
                 if(matt==stg.mtr)
                      {  trv=1;
                printf("*********\nNom :%s\nprénom :%s\nmatricule :%d\nDate naissance :%s\n",stg.nom,stg.prenom,stg.mtr,stg.dn);      
                         nom = stg.nom;      
                         pre=stg.prenom ;     
                         da=stg.dn;
                         break;  }}
    fclose(casanova);
                    casanova = fopen("C:\\Documents and Settings\\text.txt","a+");
    if(trv==1)
      {
              printf("qui ce que tu veux modifier n/p/d ou t :");
       scanf("%s",&s);
     
     switch(s)
     {
  case  'n':{ printf("entrez le nouveau nom");
           scanf("%s",nom);break;}
  case  'p':{ printf("entrez le nouveau prenom");
           scanf("%s",pre);break;}        
  case  'd':{ printf("entrez le nouvelle date de naissance");
           scanf("%s",da);break;}           
  case  't':{  printf("entrez le nouveau nom");
                 scanf("%s",nom);
                printf("entrez le nouveau prenom");
                 scanf("%s",pre);
                printf("entrez le nouvelle date de naissance");
                 scanf("%s",da);break;} }                         
                     fprintf (casanova,"\n%s\n%s\n%d\n%s\n",nom,pre,matt,da);   
                     printf("\t\t!!!! la modification est réussi press entrez pur aller ou menu\n");
                    }
        else   {system("cls");
               printf("\t\t!!!!ce matricule n'exist pas!!!!\n\t!!!!entrez 99 pour returnez ou menu ou 2 pour une autre essy!!!");
       }
         getch();          
   fclose(index);
  fclose(casanova);
            remove("C:\\Documents and Settings\\test.txt");
            rename("C:\\Documents and Settings\\text.txt","C:\\Documents and Settings\\test.txt");
}
 /*******************************************menu stgiaire *****************************/
                     
                  void mstagirair()   
          {    int ch;
        
       while(ch!=99)
         { system("color 4b");
          system("cls");
   printf("\t>>>>>>>>ôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô\n");
   printf("\t>       *******************************                    ôô   ôô\n");
   printf("\t> >     ôtaper**************1-ajout                  ôô         ôô\n");
   printf("\t>   >   ôtaper**************2-consultation     ôô               ôô\n");
   printf("\t>    > ôtaper **************3-rechercher ôô                     ôô\n");
   printf("\t>   >   ôtaper**************4-supprimer         ôô              ôô\n");
   printf("\t> >     ôtaper**************5-modifier                ôô        ôô\n");
   printf("\t>       ôtaper**************99-quitter menu stagiaire      ôô   ôô\n");
   printf("\t>>>>>>>>ôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôôô\n");
       printf("entrer votre choix :");
       scanf("%d",&ch);
       switch(ch)
       {
     
       case 1:{ajout(); break;}
       case 2: {consultation();break;}
       case 3:{recherch();break;}
       case 4:{sup();break;}
       case 5:{modifier();break;}
       case 99:{system("exit");printf(" retapez entrez......") ;break;}
       default:{printf("wa ta dakhl chi ra9em men li me3tik a lkanbo \n 3taytek a mikhi hhhh!!");getch();break;}
       }
    }     
}    
/*****************************************absence********************************************    
   ***********************************************************************************
             ********************************************************* 
                          ********************************
                                 ***************
                                     *******
                                      *****
                                        **
                                         */
       /*******************************ajouter d'absence*******************************/
       void  ajoutabs ()
       {int n=1,tr;
       char aj;
       aj='o';
        while(aj=='o'){
            absence = fopen("C:\\Documents and Settings\\abs.txt","r");
            if(!absence)
            {absence = fopen("C:\\Documents and Settings\\abs.txt","w");
            fclose(absence); }
            else{ tr=2; n=0;
                  absence = fopen("C:\\Documents and Settings\\abs.txt","r+");
           while(!feof(absence))
           {fscanf(absence,"%d%s%s%d%s",&abse.nmb,abse.dat,abse.duree,&abse.mtr,abse.motif);
          n=n+1;}
         printf("tapez le matricule ");
         scanf("%d",&abse.mtr);
         index = fopen("C:\\Documents and Settings\\test.txt","r");
         while(!feof(index))
         {fscanf(index,"%s%s%d%s",stg.nom,stg.prenom,&stg.mtr,stg.dn);
          if(abse.mtr==stg.mtr)
          {tr=1;}}fclose(index);
          if(tr==1){
         printf("tapez la date ");
         scanf("%s",&abse.dat);
         printf("tapez la duree ");
         scanf("%s",&abse.duree);
         printf("tapez le motif ");
         scanf("%s",&abse.motif);
         abse.nmb=n;
         fprintf (absence,"\n%d\n%s\n%s\n%d\n%s\n",abse.nmb,abse.dat,abse.duree,abse.mtr,abse.motif); 
          printf("voulez vous ajauter une autre parametre o/n :");
         scanf("%s",&aj);
         } if(tr==2) {printf("\t\tce matricule n'exist pas \n");fclose(absence);}}
       
          fclose(absence);}}
         /********************************consultation d'absence********************************/
            void consultationabs()
            {int k,i;
               absence = fopen("C:\\Documents and Settings\\abs.txt","r");
               system("cls");
               k=-2;
            while(!feof(absence))
              { index = fopen("C:\\Documents and Settings\\test.txt","r");
                fscanf(absence,"%d%s%s%d%s",&abse.nmb,abse.dat,abse.duree,&abse.mtr,abse.motif);
              while(!feof(index))
              { fscanf(index,"%s%s%d%s",stg.nom,stg.prenom,&stg.mtr,stg.dn);
              if(k!=abse.nmb){
               if(stg.mtr==abse.mtr)
               {printf("****************\n\tnom :%s\n\tprenom :%s\n",stg.nom,stg.prenom); break;   }}}fclose(index) ;
               if(k!=abse.nmb){
             printf("nombre :%d\nDate :%s\nDuree :%s\nmatricule :%d\nDate motif :%s\n",abse.nmb,abse.dat,abse.duree,abse.mtr,abse.motif);}k=abse.nmb;}
              fclose(absence);
             getch();}
  /*****************************************recherch absence***********************************/
      void recherchabs()
      {int s,tr,rch,test;
      char rd[20];
      absence = fopen("C:\\Documents and Settings\\abs.txt","r");
      index = fopen("C:\\Documents and Settings\\test.txt","r");
           system("cls");
           printf("entrez le crétère de recherche \n*1 pour Rnombre \n*2 pour Rduree \n*3 pour Rmatricule \n*4 pour Rmotif\n  :") ;
           scanf("%d",&s);
           if(s==1)
           {printf("entrez le nombre d'absence");
           scanf("%d",&rch);
                   while(!feof(absence))
                   {fscanf(absence,"%d%s%s%d%s",&abse.nmb,abse.dat,abse.duree,&abse.mtr,abse.motif);
                   if(rch==abse.nmb)
                   {tr=1;
                   break;}}
                   while(!feof(index))
                  {fscanf(index,"%s%s%d%s",stg.nom,stg.prenom,&stg.mtr,stg.dn);
                  if(stg.mtr==abse.mtr)
                  {break;
                  else printf("n'exist pas");} } }
                  
                  if(tr==1)
                  {printf("****************\n\tnom :%s\n\tprenom :%s\n",stg.nom,stg.prenom);
                   printf("nombre :%d\nDate :%s\nDuree :%s\nmatricule :%d\nDate motif :%s\n",abse.nmb,abse.dat,abse.duree,abse.mtr,abse.motif);
                  }
                
                  if(s==2)
                  {printf("entrez la duree par H ou par J ou par M");   
                  scanf("%s",&rd);
                  while(!feof(absence))
                  {fscanf(absence,"%d%s%s%d%s",&abse.nmb,abse.dat,abse.duree,&abse.mtr,abse.motif);
                  test=strcmp(abse.duree,rd);
                
                  if(test==0)
                  {  while(!feof(index))
                  {fscanf(index,"%s%s%d%s",stg.nom,stg.prenom,&stg.mtr,stg.dn);
                  if(stg.mtr==abse.mtr)
                   { printf("****************\n\tnom :%s\n\tprenom :%s\n",stg.nom,stg.prenom);  }}
                     printf("nombre :%d\nDate :%s\nDuree :%s\nmatricule :%d\nDate motif :%s\n",abse.nmb,abse.dat,abse.duree,abse.mtr,abse.motif);}}}                                 
              /*   if(tr==3)
                { printf("entre la date rechercher");
                scanf("%s"',abse.dat);
                while (!feof(index))
                {fscanf(index,"%s%s%d%s",stg.nom,stg.prenom,&stg.mtr,stg.dn);*/
               
                  getch();}                                      
  /*********************************menu absence*********************************************/
  void mabsence()
  {
       int ch;
        while(ch!=99){
       system("color 0b"); system("cls");
       printf("\t\töööööööööööööööööööööööööööööööööööööööööööööööö\n");
       printf("\t\tötaper..............1-ajout                    ö\n");
       printf("\t\tötaper..............2-consultation             ö\n");
       printf("\t\tötaper..............3-rechercher               ö\n");
       printf("\t\tötaper..............4-supprimer                ö\n");
       printf("\t\tötaper..............5-modifier                 ö\n");
       printf("\t\tötaper.............. 99-quitter                ö\n");
       printf("\t\töööööööööööööööööööööööööööööööööööööööööööööööö\n");
       printf("entrer votre choix:");
       scanf("%d",&ch);
           switch(ch)
       {
       case 1:{ajoutabs(); break;}
       case 2: {consultationabs();break;}
       case 3:{recherchabs();break;}
       //case 4:{supabs();break;}
       //case 5:{modifierabs();break;}
       case 99:{printf("press entrez......");break;}
       default:{printf("wa ta dakhl chi ra9em men li me3tik a lkanbo \n 3taytek a mikhi hhhh!!");getch();break;}
       }}}
          /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@main@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/  
                            
       main()
{      int choix ;
    
      while(choix!=77)
      { system("cls");
      system("color 0f");
      printf("\t-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n");
      printf("\t_-***pour aƒƒicher le contenu de stagaire  entrez *******1_-_-_-_\n");
      printf("\t_-***pour aƒƒicher le contenu d'abscence entrez   *******2_-_-_-_\n");
       printf("\t_***pour quetter totalement le programme        *******99_-_-_-_\n");
      printf("\t__-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n");
      printf("entrez votre choix :");
      scanf("%d",&choix);
      switch(choix)
      {
                   case 1:{mstagirair();break;}
                   case 2:{mabsence();break;}
                   case 99:{exit(-1);break;}
                   default :{printf("wa ta 1 ola 2 malek magloube :\n");break;}
               
       }          
    getch(); }   }


Aucun commentaire:

Enregistrer un commentaire