|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
GESTIONS DES STOCKS
Information sur la source
Description
Mini projet sur la gestion des stocks, simple et bien commenté, mais s 'il ya des commentaires ou des suggetions ne hesité pas... Je remercie les autres membres qui ont la gentillesse de poser des sources et qui sont d'un grand interet pour tous...
Source
-
- #include<iostream>
- #include<stdio.h>
- #include<windows.h>
- #include<time.h>
- #include<conio.h>
- #include<string.h>
- #include<stdlib.h>
- //#include"menu.h"
- using namespace std;
- //********************************************************
- //** Classe _Date :pour gerer Les dates **
- //** Champs : jj=jour,mm=mois,aa=année **
- //********************************************************
- class _Date
- {
- public:
- int jj;
- int mm;
- int aa;
-
- _Date(){};
- _Date(int j,int m,int a){ jj=j;mm=m;aa=a;}
- int fj(){return jj;}
- int fm(){return mm;}
- int fa(){return aa;}
- bool datevalide();
- _Date & operator = (const _Date & source);
-
- };
- _Date & _Date::operator=(const _Date & source)
- {
- jj=source.jj;
- mm=source.mm;
- aa=source.aa;
- return *this;
- }
-
- bool _Date::datevalide()
- {
- if((mm>12)||(mm<1)||(jj<1)||(jj>31)) return false;
- else if((mm==1)||(mm==3)||(mm==5)||(mm==7)||(mm==8)||(mm==10)||(mm==12)) return true;
- else if(mm!=2){
- if((jj>0)&&(jj<31)) return true;
- else return false;}
- else if(((aa%4==0)&&(aa%100!=0))||((aa%400)==0))
-
- if((jj>0) && (jj<=29)) return true;
- else return false;
- else if(jj>0 && jj<=28) return true;
- else return false;
- }
- //**********************************************************
- //** Classe Article pour gerer Les article **
- //** Champs : code: entier unique,designation: chaines **
- //** des caracteres,quantite un double, priachat,prixvente**
- //** le type d'operation effectuée sur l'article **
- //**********************************************************
- class article
- {
- public:
- int code;
- char designation[50];
- float quantite;
- float prixachat;
- float prixvente;
- _Date date;
- _Date date_m;
- char operation[3];
- article(){};
- article(int coden,char *design,float quant,float pa,float pv,_Date dat,_Date mod,char *op);
- article( article &);
- article & operator=(const article&);
- int fcode(){return code;}
- char *fdesignation(){return designation;}
- float fprixachat(){return prixachat;}
- float fprixvente(){return prixvente;}
- float fquantite(){return quantite;}
- char *foperation(){ return operation;}
- void ajouter();
- void sortir();
- float prix_vente();
- float reduction();
- float benefice();
- void supprimer();
- void Afficher();
- };
- //************ Variable global pour gener la taille ****
- //*** d'un article surtout pour travailler avec les ***
- //*** les fichiers ***
- //*******************************************************
- int taille=sizeof(article);
- article::article( article & source)
- {
- code=source.code;
- strcpy(designation,source.designation);
- quantite=source.quantite;
- prixachat=source.prixachat;
- prixvente=source.prixvente;
- date=source.date;
- date_m=source.date_m;
- strcpy(operation,source.operation);
- }
-
- article & article::operator=(const article & source)
- {
- code=source.code;
- strcpy(designation,source.designation);
- quantite=source.quantite;
- prixachat=source.prixachat;
- prixvente=source.prixvente;
- date=source.date;
- date_m=source.date_m;
- strcpy(operation,source.operation);
- return *this;
- }
- //************************************************************
- //** Procedure : Message d'urgence **
- //** Parametre : une chaine de caractere contenant le **
- //** message à afficher **
- //** Traitement: c'est une procedure qui affiche **
- //** un message clignotant lors d'une action **
- //** particulière tel que erreur ou recherche**
- //** Utilise : la fonction sleep **
- //** **
- //************************************************************
-
-
- void MessageUrgence(char *msg)
- {
- int i;
- for(i=0;i<2;i++)
- {
-
- system("cls");
- Sleep(500);
- printf("\n\a\a%s",msg);
- Sleep(500);
- }
- }
-
- //***********************************************************
- //*******************MESSAGE DU SAUVE-CHARGE*****************
- //***********************************************************
-
- void msgSauvCharg(char *msg)
- {
- int j;
-
- system("cls");
- printf("\n\n\n\n\n\n\n\n\n\t\t\t\t%s",msg);
- for(j=0;j<=5;j++)
- {
- Sleep(120);
- printf(".");
- }
-
- }
- //*********************************************************
- //** Procedure : Afficher un articles **
- //** Parametre : les listes des:articles, codes, **
- //** quantite,prix achat,prix vente **
- //*********************************************************
- void article::Afficher()
- {
- //*********************************************************************
- //************ DESSIN DU TABLEAU RECUPELATIF DES TOTALES ********
- //*********************************************************************
- printf("\n\n\n \xda");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4");
- printf("\xbf\n");
- printf(" \xb3 CODE \xb3");
- printf(" NOMS \xb3");
- printf(" QUANTITE \xb3");
- printf(" PRIXACH \xb3");
- printf(" PRIXVEN \xb3");
- printf(" TYPE OPERTION \xb3");
- printf("\n \xc3");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4");
- printf("\xb4\n");
- printf(" \xb3 %3.0d \xb3",fcode());
- cout<<" "<<fdesignation() <<" \xb3";
- cout<<" "<<fquantite() <<" \xb3";
- cout<<" "<<fprixachat() <<" \xb3";
- cout<<" "<<fprixvente() <<" \xb3";
- cout<<" "<<foperation() <<" \xb3";
- printf("\n \xc0");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
- printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4");
- printf("\xd9\n");
- printf("\n\n");
- system("pause");
- }
- //**************************************************************
- //** Procedure Entete pour afficher la date et heure courant****
- //**************************************************************
- void EnTete()
- {
- system("cls");
- system("color 6f");
- char tmpbuf[128],datebuf[128];
- _strtime( tmpbuf );
- _strdate( datebuf );
- printf("\xc9");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd");
- printf("\xbb");
- printf("\n\xba %s \xba \xba Gestion de stock \xba \xba %s \xba\n",tmpbuf,datebuf);
- printf("\xc8");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
- printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd");
- printf("\xbc");
- printf("\n\n");
-
- }
-
-
-
- //**************************************************************
- //** Recherche un article par son code dans les fichiers *****
- //** contenant les donnees ****
- //**************************************************************
- bool rechercher(char *N_fichier,int cod)
- {
- FILE *pf;
- int Nb_eng,i;
- article x;
- pf=fopen(N_fichier,"r");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- int pos=-1;
- for(i=0;(i<Nb_eng)&&(pos==-1);i++)
- {
- fread(&x,taille,1,pf);
- if(x.code==cod) pos=i;
- }
- //fcloseall();
- if(pos==-1) return false;
- else return true;
- }
- //***************************************************************
- //** Procedure pour ajouter un nouveau article *****
- //** dans le fichier article et historique *****
- //***************************************************************
- void ajouter(char *N_fichier,char *S_fichier)
- {
- system("cls");
- EnTete();
- FILE * pf;
- FILE * stat;
- article a;
- int cod;
- // char dat_buff[10];
- int n,i;
- cout<<"donner le nombre d'article : ";
- cin>>n;
- pf=fopen(N_fichier,"a+");
- stat=fopen(S_fichier,"a+");
- for(i=0;i<n;i++)
- {
-
- do
- {
-
- cout<<"\n Entrer le code de l'article : ";
- cin>>cod;
- if(rechercher(N_fichier,cod)==true) MessageUrgence("ce code correspond a un autre article");
- }while(rechercher(N_fichier,cod)==true);
-
- a.code=cod;
- cout<<"Entrer sa designation : ";
- cin>>a.designation;
- cout<<"Entrer sa quantite : ";
- cin>>a.quantite;
- cout<<"Entrer son prix achat : ";
- cin>>a.prixachat;
- cout<<"Entrer son prix de vente : ";
- cin>>a.prixvente;
- do{
- cout<<"\t\tSaisir date valide !!! "<<endl;
- cout<<"Entrer le Jour : ";
- cin>>a.date.jj;
- cout<<" Mois : ";
- cin>>a.date.mm;
- cout<<" Annee : ";
- cin>>a.date.aa;
- }while(a.date.datevalide()!=true);
- a.date_m.jj=a.date.jj;
- a.date_m.mm=a.date.mm;
- a.date_m.aa=a.date.aa;
- //a.date_m=a.date;
- strcpy(a.operation ,"cr");
- fwrite(&a,taille,1,pf);
- fwrite(&a,taille,1,stat);
- }
- fclose(pf);
- fclose(stat);
- }
- //**************************************************************
- //** Procedure pour lire un article contenu dans un fichier***
- //** ************************************************************
- //***************************************************************
- void Lecture(char * N_fichier)
- {
- system("cls");
- EnTete();
- FILE * pf;
- article a;
- int i,Nb_eng;
- pf=fopen(N_fichier,"r");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- if(Nb_eng==0){ MessageUrgence("Desolé le stock est vide ");}
- else{
- for(i=0;i<Nb_eng;i++)
- {
- fread(&a,taille,1,pf);
- cout<<a.fcode() <<" | "<< a.fdesignation() <<" | "<<a.fquantite() <<" | "<<a.fprixachat() <<" | "<<a.fprixvente()<<" | "<<a.date.fj()<<":"<<a.date.fm()<<":"<<a.date.fa()<<"| "<<a.foperation()<<endl;
- }
- }
- fclose(pf);
- system("pause");
-
- }
- //****************************************************************
- //** Procedure pour Visualiser article en lui donnant son code**
- //** *************************************************************
- //****************************************************************
- void Visualiser(char *N_fichier,int cod)
- {
-
- system("cls");
- EnTete();
- FILE *pf;
- int Nb_eng,i;
- article x;
- pf=fopen(N_fichier,"r");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,pf);
- if(cod==x.code) break;
- }
- if(i==Nb_eng) MessageUrgence(" ce code ne correspond a aucun article ");
- else {
- //cout<<x.fcode()<<"\xba"<<x.fdesignation()<<" \xba"<<x.fquantite()<<" \xba "<<x.fprixachat()<<" | "<<x.fprixvente()<<" | "<<x.date.fj()<<":"<<x.date.fm()<<":"<<x.date.fa()<<"| "<<x.foperation()<<endl;
- x.Afficher();
- }
- fclose(pf);
- }
- //***************************************************************
- //** Procedure pour sortir un article **************
- //** ************************************************************
- //***************************************************************
- void Sortir(char *N_fichier,char *S_fichier,int cod)
- {
- system("cls");
- EnTete();
- FILE *pf,*stat;
- int Nb_eng,i;
- article x;
- float quant;
- pf=fopen(N_fichier,"r+");
- stat=fopen(N_fichier,"a+");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,pf);
- if(cod==x.code) break;
- }
- if(i==Nb_eng) MessageUrgence("ce code ne correspond a aucun article");
- else
- {
- cout<<"\n Entrer la quantite que vous voulez sortir : ";
- cin>>quant;
- if(x.quantite<quant) cout<<"\n quentite insuffisante "<<endl;
- else
- {
- x.quantite=x.quantite-quant;
- strcpy(x.operation,"So");
- fwrite(&x,taille,1,stat);
- fseek(pf,-taille,1);
- fwrite(&x,taille,1,pf);
-
- }
- }
- fcloseall();
- system("pause");
- }
- //*****************************************************************
- //** Procedure pour la modification de la quantité d un article***
- //** ***************************************************************
- //******************************************************************
- void modif_quantite(char *N_fichier,char *S_fichier,int cod)
- {
- system("cls");
- EnTete();
- FILE *pf,*stat;
- int Nb_eng,i;
- article x;
- float quant;
- pf=fopen(N_fichier,"r+");
- stat=fopen(N_fichier,"a+");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,pf);
- if(cod==x.code) break;
- }
- if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
- else{
- cout<<" entrer la nouvelle valeur :"<<endl;
- cin>>quant;
- x.quantite=quant;
- strcpy(x.operation,"Mo");
- fwrite(&x,taille,1,stat);
- fseek(pf,-taille,1);
- fwrite(&x,taille,1,pf);
-
- }
- fcloseall();
- }
- //*****************************************************************
- //** Procedure pour la modification du prix vente d un article***
- //** ***************************************************************
- //******************************************************************
- void modif_prixv(char *N_fichier,char *S_fichier,int cod)
- {
- system("cls");
- EnTete();
- FILE *pf,*stat;
- int Nb_eng,i;
- article x;
- float pv;
- pf=fopen(N_fichier,"r+");
- stat=fopen(S_fichier,"a+");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,pf);
- if(cod==x.code) break;
- }
- if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
- else{
- cout<<"\n entrer le nouveau prix de vente :"<<endl;
- cin>>pv;
- x.prixvente=pv;
- strcpy(x.operation,"Mo");
- fwrite(&x,taille,1,stat);
- fseek(pf,-taille,1);
- fwrite(&x,taille,1,pf);
-
- }
- fcloseall();
- }
- //******************************************************************
- //** Procedure pour la modification du prix achat d un article***
- //** ***************************************************************
- //******************************************************************
- void modif_prixa(char *N_fichier,char *S_fichier,int cod)
- {
-
- system("cls");
- EnTete();
- FILE *pf,*stat;
- int Nb_eng,i;
- article x;
- float pa;
- pf=fopen(N_fichier,"r+");
- stat=fopen(S_fichier,"a+");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,pf);
- if(cod==x.code) break;
- }
- if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
- else{
- cout<<"\n entrer le nouveau prix de vente :"<<endl;
- cin>>pa;
- x.prixachat=pa;
- strcpy(x.operation,"Mo");
- fwrite(&x,taille,1,stat);
- fseek(pf,-taille,1);
- fwrite(&x,taille,1,pf);
- }
- fcloseall();
- }
- //********************************************************************
- //** Procedure pour la modification de la designation d un article***
- //** ******************************************************************
- //*********************************************************************
- void modif_design(char *N_fichier,char *S_fichier,int cod)
- {
-
- system("cls");
- EnTete();
- FILE *pf,*stat;
- int Nb_eng,i;
- article x;
- char desi[50];
- pf=fopen(N_fichier,"r+");
- stat=fopen(S_fichier,"a+");
- fseek(pf,0,2);
- Nb_eng=ftell(pf)/taille;
- fseek(pf,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,pf);
- if(cod==x.code) break;
- }
- if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
- else{
- cout<<"\n entrer la nouvelle designation :"<<endl;
- cin>>desi;
- strcpy(x.designation,desi);
- strcpy(x.operation,"Mo");
- fwrite(&x,taille,1,stat);
- fseek(pf,-taille,1);
- fwrite(&x,taille,1,pf);
-
- }
- fcloseall();
- }
- //*****************************************************************
- //** Procedure pour Trier les articles par designation ***
- //** ***************************************************************
- //******************************************************************
- void tri_design(char *N_fichier)
- {
- FILE * f;
- article x,*t;
- int Nb_eng,i,k;
- f=fopen(N_fichier,"r+");
- fseek(f,0,2);
- Nb_eng=ftell(f)/taille;
- t=new article[Nb_eng];
- fseek(f,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,f);
- t[i]=x;
- }
- do{
- k=0;
- for(i=0;i<Nb_eng-1;i++)
- if(strcmp(t[i].designation,t[i+1].designation)>0)
- {
- x=t[i];
- t[i]=t[i+1];
- t[i+1]=x;
- k=1;
- }
-
- }while(k==1);
- fseek(f,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- x=t[i];
- fwrite(&x,taille,1,f);
- }
- fclose(f);
- delete t;
- }
- //*****************************************************************
- //** Procedure pour Trier les articles par prix achat ***
- //** ***************************************************************
- //******************************************************************
- void tri_pa(char *N_fichier)
- {
- FILE * f;
- article x,*t;
- int Nb_eng,i,k;
- f=fopen(N_fichier,"r+");
- fseek(f,0,2);
- Nb_eng=ftell(f)/taille;
- t=new article[Nb_eng];
- fseek(f,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,f);
- t[i]=x;
- }
- do{
- k=0;
- for(i=0;i<Nb_eng-1;i++)
- if(t[i].prixachat < t[i+1].prixachat)
- {
- x=t[i];
- t[i]=t[i+1];
- t[i+1]=x;
- k=1;
- }
-
- }while(k==1);
- fseek(f,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- x=t[i];
- fwrite(&x,taille,1,f);
- }
- fclose(f);
- delete t;
- }
-
- //******************************************************************
- //** Procedure pour Trier les articles par quantité ******
- //** ***************************************************************
- //******************************************************************
- void tri_qt(char *N_fichier)
- {
- FILE * f;
- article x,*t;
- int Nb_eng,i,k;
- f=fopen(N_fichier,"r+");
- fseek(f,0,2);
- Nb_eng=ftell(f)/taille;
- t=new article[Nb_eng];
- fseek(f,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- fread(&x,taille,1,f);
- t[i]=x;
- }
- do{
- k=0;
- for(i=0;i<Nb_eng-1;i++)
- if(t[i].quantite < t[i+1].quantite)
- {
- x=t[i];
- t[i]=t[i+1];
- t[i+1]=x;
- k=1;
- }
-
- }while(k==1);
- fseek(f,0,0);
- for(i=0;i<Nb_eng;i++)
- {
- x=t[i];
- fwrite(&x,taille,1,f);
- }
- fclose(f);
- delete t;
- }
- //*********************************************************************
- //************************ A PROPOS **************************
- //*********************************************************************
- void A_Propos()
- {
- EnTete();
- cout<<"\n\t\tMASTER INFORMTIQUE,TELECOMMUNICATION,IMAGERIE";
- cout<<"\n\n\n\t\tMini projet : Gestion des stocks";
- cout<<"\n\n\n\t\tRealise par :\tMAHAMAT BORGOU Hassan";
- cout<<"\n\n\t\t \tNDAW Marie Elisa Adam";
- cout<<"\n\n\n\t\tEncadre par :\tMr. HIMMI *****";
- cout<<"\n\n\n\n\t\t\tAnnée Universitaire 2006/2007";
- cout<<"\n\n";
- system("pause");
-
-
- }
-
- //********************************************************
- //** Fonction : MenuPrincipale **
- //** Parametre : pas de parametre **
- //** Traitement: creation du menu principale **
- //** Retourne : un entier qui est le choix **
- //********************************************************
- int MenuPrincipal()
- {
- int choix;
- EnTete();
- printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
- printf("\n \xb3 Menu Principale \xb3");
- printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
- printf("\n\n");
- printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
- printf("\n \xba \xba");
- printf("\n \xba Ajouter un nouveau article............1 \xba");
- printf("\n \xba sortir un article.....................2 \xba");
- printf("\n \xba Lister les articles...................3 \xba");
- printf("\n \xba Gestion des aricles...................4 \xba");
- printf("\n \xba Statistique...........................5 \xba");
- printf("\n \xba A propos..............................6 \xba");
- printf("\n \xba Quitter...............................9 \xba");
- printf("\n \xba \xba");
- printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
- printf("\n\n Votre choix : ");
- scanf("%d",&choix);
- return choix;
- }
-
- //********************************************************
- //** Fonction : MenuGestionArticle **
- //** Parametre : pas de parametre **
- //** Traitement: creation du menu GestionArticle **
- //** Retourne : un entier qui est le choix **
- //********************************************************
- int MenuGestionArticle()
- {
-
- int choix;
- EnTete();
- printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
- printf("\n \xb3 Gestion des articles \xb3");
- printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
- printf("\n\n");
- printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
- printf("\n \xba \xba");
- printf("\n \xba Visualiser un Article.................1 \xba");
- printf("\n \xba Modifier la designation...............2 \xba");
- printf("\n \xba Modifier la quantite..................3 \xba");
- printf("\n \xba Modifier le prix d'achat..............4 \xba");
- printf("\n \xba Modifier le prix de vente.............5 \xba");
- printf("\n \xba Retour................................9 \xba");
- printf("\n \xba \xba");
- printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
- printf("\n\n Votre choix : ");
- scanf("%d",&choix);
- //choix=getch();
- //putch(choix);
- Sleep(120);
-
- return choix;
- }
-
- //********************************************************
- //** Fonction : MenuGestionModification **
- //** Parametre : pas de parametre **
- //** Traitement: creation du menu GestionModification**
- //** Retourne : un entier qui est le choix **
- //********************************************************
- int MenuModification()
- {
-
- int choix;
- EnTete();
- printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
- printf("\n \xb3 Modifications des articles \xb3");
- printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
- printf("\n\n");
- printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
- printf("\n \xba \xba");
- printf("\n \xba Modifier la code.................1 \xba");
- printf("\n \xba Modifier la designation..........2 \xba");
- printf("\n \xba Modifier la quantite.............3 \xba");
- printf("\n \xba Modifier le Prix achat...........4 \xba");
- printf("\n \xba Modifier le Prix vente...........5 \xba");
- printf("\n \xba Retour...........................9 \xba");
- printf("\n \xba \xba");
- printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
- printf("\n\n Votre choix : ");
- scanf("%d",&choix);
- choix=getch();
- putch(choix);
- Sleep(120);
- return choix;
- }
-
-
- //********************************************************
- //** Fonction : MenuGestionStatistique **
- //** Parametre : pas de parametre **
- //** Traitement: creation du menu GestionStatistique **
- //** Retourne : un entier qui est le choix **
- //********************************************************
- int MenuGestionStatistique()
- {
- int choix;
- EnTete();
- printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
- printf("\n \xb3 Gestion des historiques \xb3");
- printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
- printf("\n\n");
- printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
- printf("\n \xba \xba");
- printf("\n \xba Visualiser historiques................1 \xba");
- printf("\n \xba Classer par nom......................2 \xba");
- printf("\n \xba Classer par quantite.................3 \xba");
- printf("\n \xba Classer par prix d'achat.............4 \xba");
- printf("\n \xba Retour................................7 \xba");
- printf("\n \xba \xba");
- printf("\n \xba \xba");
- printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
- printf("\n\n Votre choix : ");
- scanf("%d",&choix);
- //choix=getch();
- //putch(choix);
- Sleep(120);
- return choix;
- }
-
- /*****************************************************************
- //**** ******************** ****
- //****** ** ** *****
- //********* ***PROGRAMME PRINCIPALE*** **********
- //****** ** ** *****
- //**** ******************** ****
- //*****************************************************************/
- void main()
- {
-
- int choix_principal=0,choix_second=0,choix,tmp,cod;
- char NF[]="f1.txt";
- char NF1[]="f2.txt";
- msgSauvCharg("Master iti");
- msgSauvCharg("mini projet d'algorithmique");
- msgSauvCharg("chargement des articles");
- msgSauvCharg("chargement des historiques");
-
- while((choix_second!=27)&&(choix_principal!=9))
- {
- choix_principal=MenuPrincipal();
- switch(choix_principal)
- {
-
- case 1:
- ajouter(NF,NF1);
- break;
- case 2:
- cout<<"\n entrer le code de l'article à sortir : ";
- cin>>cod;
- Sortir(NF,NF1,cod);
- break;
- case 3:
- Lecture(NF);
- break;
- case 4://gestion des articles
- choix_second=MenuGestionArticle();
- while(choix_second!=27)
- {
- if( choix_second==1)
- {
- EnTete();
- cout<<"\t***** VISUALISATION DE L ARTICLE *********"<<endl;
- cout<<"\n entrer votre code a visualiser : ";
- cin>>cod;
- Visualiser(NF,cod);
- choix_second=MenuGestionArticle();
- }
- if( choix_second==2)
- {
- EnTete();
- cout<<"\t*******MODIFICATION DE LA DESIGNATION ******** :"<<endl;
- cout<<"\t Entrer le code de l' article a modifier : ";
- cin>>tmp;
- modif_design(NF,NF1,tmp);
- choix_second=MenuGestionArticle();
- }
- if( choix_second==3)
- {
- EnTete();
- cout<<"\t*******MODIFICATION DE LA QUANTITE ******** :"<<endl;
- cout<<"\t Entrer le code de l' article a modifier : ";
- cin>>tmp;
- modif_quantite(NF,NF1,tmp);
- choix_second=MenuGestionArticle();
- }
- if( choix_second==4)
- {
- EnTete();
- cout<<"\t*******MODIFICATION DU PPRIX D ACHAT ******* :"<<endl;
- cout<<"\t Entrer le code de l' article a modifier : ";
- cin>>tmp;
- modif_prixa(NF,NF1,tmp);
- choix_second=MenuGestionArticle();
- }
- if(choix_second==5)
- {
- EnTete();
- cout<<"\t*******MODIFICATION DU PRIX VENTE ******** :"<<endl;
- cout<<"\t Entrer le code de l' article a modifier :";
- cin>>tmp;
- modif_prixv(NF,NF1,tmp);
- choix_second=MenuGestionArticle();
- }
- if(choix_second==9)
- choix_second=27;
- }
- break;
- case 5: //gestion des statistiques
- choix_second=MenuGestionStatistique();
- while(choix_second!=27)
- {
- if( choix_second==1)
- {
-
- cout<<"\t***** VISUALISATION DES HISTORIQUES *********"<<endl;
- Lecture(NF);
- choix_second=MenuGestionStatistique();
- }
- if( choix_second==2)
- {
- cout<<"\t ******ORDONNER LES ARTICLES PAR NOMS********"<<endl;
- tri_design(NF);
- Lecture(NF);
- choix_second=MenuGestionStatistique();
- }
- if( choix_second==3)
- {
- cout<<"\t *******TRIER PAR LA QUANTITE ***************"<<endl;
- tri_qt(NF);
- Lecture(NF);
- choix_second=MenuGestionStatistique();
- }
- if( choix_second==4)
- {
- cout<<"\t************** TRIER PAR PRIX ACHAT *********** "<<endl;
- tri_pa(NF);
- Lecture(NF);
- choix_second=MenuGestionStatistique();
- }
- if(choix_second==7)
- choix_second=27;
- }
- break;
- case 6:
- A_Propos();
-
- break;
- case 9: break;
- }
- }
-
- }
#include<iostream>
#include<stdio.h>
#include<windows.h>
#include<time.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
//#include"menu.h"
using namespace std;
//********************************************************
//** Classe _Date :pour gerer Les dates **
//** Champs : jj=jour,mm=mois,aa=année **
//********************************************************
class _Date
{
public:
int jj;
int mm;
int aa;
_Date(){};
_Date(int j,int m,int a){ jj=j;mm=m;aa=a;}
int fj(){return jj;}
int fm(){return mm;}
int fa(){return aa;}
bool datevalide();
_Date & operator = (const _Date & source);
};
_Date & _Date::operator=(const _Date & source)
{
jj=source.jj;
mm=source.mm;
aa=source.aa;
return *this;
}
bool _Date::datevalide()
{
if((mm>12)||(mm<1)||(jj<1)||(jj>31)) return false;
else if((mm==1)||(mm==3)||(mm==5)||(mm==7)||(mm==8)||(mm==10)||(mm==12)) return true;
else if(mm!=2){
if((jj>0)&&(jj<31)) return true;
else return false;}
else if(((aa%4==0)&&(aa%100!=0))||((aa%400)==0))
if((jj>0) && (jj<=29)) return true;
else return false;
else if(jj>0 && jj<=28) return true;
else return false;
}
//**********************************************************
//** Classe Article pour gerer Les article **
//** Champs : code: entier unique,designation: chaines **
//** des caracteres,quantite un double, priachat,prixvente**
//** le type d'operation effectuée sur l'article **
//**********************************************************
class article
{
public:
int code;
char designation[50];
float quantite;
float prixachat;
float prixvente;
_Date date;
_Date date_m;
char operation[3];
article(){};
article(int coden,char *design,float quant,float pa,float pv,_Date dat,_Date mod,char *op);
article( article &);
article & operator=(const article&);
int fcode(){return code;}
char *fdesignation(){return designation;}
float fprixachat(){return prixachat;}
float fprixvente(){return prixvente;}
float fquantite(){return quantite;}
char *foperation(){ return operation;}
void ajouter();
void sortir();
float prix_vente();
float reduction();
float benefice();
void supprimer();
void Afficher();
};
//************ Variable global pour gener la taille ****
//*** d'un article surtout pour travailler avec les ***
//*** les fichiers ***
//*******************************************************
int taille=sizeof(article);
article::article( article & source)
{
code=source.code;
strcpy(designation,source.designation);
quantite=source.quantite;
prixachat=source.prixachat;
prixvente=source.prixvente;
date=source.date;
date_m=source.date_m;
strcpy(operation,source.operation);
}
article & article::operator=(const article & source)
{
code=source.code;
strcpy(designation,source.designation);
quantite=source.quantite;
prixachat=source.prixachat;
prixvente=source.prixvente;
date=source.date;
date_m=source.date_m;
strcpy(operation,source.operation);
return *this;
}
//************************************************************
//** Procedure : Message d'urgence **
//** Parametre : une chaine de caractere contenant le **
//** message à afficher **
//** Traitement: c'est une procedure qui affiche **
//** un message clignotant lors d'une action **
//** particulière tel que erreur ou recherche**
//** Utilise : la fonction sleep **
//** **
//************************************************************
void MessageUrgence(char *msg)
{
int i;
for(i=0;i<2;i++)
{
system("cls");
Sleep(500);
printf("\n\a\a%s",msg);
Sleep(500);
}
}
//***********************************************************
//*******************MESSAGE DU SAUVE-CHARGE*****************
//***********************************************************
void msgSauvCharg(char *msg)
{
int j;
system("cls");
printf("\n\n\n\n\n\n\n\n\n\t\t\t\t%s",msg);
for(j=0;j<=5;j++)
{
Sleep(120);
printf(".");
}
}
//*********************************************************
//** Procedure : Afficher un articles **
//** Parametre : les listes des:articles, codes, **
//** quantite,prix achat,prix vente **
//*********************************************************
void article::Afficher()
{
//*********************************************************************
//************ DESSIN DU TABLEAU RECUPELATIF DES TOTALES ********
//*********************************************************************
printf("\n\n\n \xda");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc2");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4");
printf("\xbf\n");
printf(" \xb3 CODE \xb3");
printf(" NOMS \xb3");
printf(" QUANTITE \xb3");
printf(" PRIXACH \xb3");
printf(" PRIXVEN \xb3");
printf(" TYPE OPERTION \xb3");
printf("\n \xc3");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc5");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4");
printf("\xb4\n");
printf(" \xb3 %3.0d \xb3",fcode());
cout<<" "<<fdesignation() <<" \xb3";
cout<<" "<<fquantite() <<" \xb3";
cout<<" "<<fprixachat() <<" \xb3";
cout<<" "<<fprixvente() <<" \xb3";
cout<<" "<<foperation() <<" \xb3";
printf("\n \xc0");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc1");
printf("\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4");
printf("\xd9\n");
printf("\n\n");
system("pause");
}
//**************************************************************
//** Procedure Entete pour afficher la date et heure courant****
//**************************************************************
void EnTete()
{
system("cls");
system("color 6f");
char tmpbuf[128],datebuf[128];
_strtime( tmpbuf );
_strdate( datebuf );
printf("\xc9");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcb\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd");
printf("\xbb");
printf("\n\xba %s \xba \xba Gestion de stock \xba \xba %s \xba\n",tmpbuf,datebuf);
printf("\xc8");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xca\xcd");
printf("\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd");
printf("\xbc");
printf("\n\n");
}
//**************************************************************
//** Recherche un article par son code dans les fichiers *****
//** contenant les donnees ****
//**************************************************************
bool rechercher(char *N_fichier,int cod)
{
FILE *pf;
int Nb_eng,i;
article x;
pf=fopen(N_fichier,"r");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
int pos=-1;
for(i=0;(i<Nb_eng)&&(pos==-1);i++)
{
fread(&x,taille,1,pf);
if(x.code==cod) pos=i;
}
//fcloseall();
if(pos==-1) return false;
else return true;
}
//***************************************************************
//** Procedure pour ajouter un nouveau article *****
//** dans le fichier article et historique *****
//***************************************************************
void ajouter(char *N_fichier,char *S_fichier)
{
system("cls");
EnTete();
FILE * pf;
FILE * stat;
article a;
int cod;
// char dat_buff[10];
int n,i;
cout<<"donner le nombre d'article : ";
cin>>n;
pf=fopen(N_fichier,"a+");
stat=fopen(S_fichier,"a+");
for(i=0;i<n;i++)
{
do
{
cout<<"\n Entrer le code de l'article : ";
cin>>cod;
if(rechercher(N_fichier,cod)==true) MessageUrgence("ce code correspond a un autre article");
}while(rechercher(N_fichier,cod)==true);
a.code=cod;
cout<<"Entrer sa designation : ";
cin>>a.designation;
cout<<"Entrer sa quantite : ";
cin>>a.quantite;
cout<<"Entrer son prix achat : ";
cin>>a.prixachat;
cout<<"Entrer son prix de vente : ";
cin>>a.prixvente;
do{
cout<<"\t\tSaisir date valide !!! "<<endl;
cout<<"Entrer le Jour : ";
cin>>a.date.jj;
cout<<" Mois : ";
cin>>a.date.mm;
cout<<" Annee : ";
cin>>a.date.aa;
}while(a.date.datevalide()!=true);
a.date_m.jj=a.date.jj;
a.date_m.mm=a.date.mm;
a.date_m.aa=a.date.aa;
//a.date_m=a.date;
strcpy(a.operation ,"cr");
fwrite(&a,taille,1,pf);
fwrite(&a,taille,1,stat);
}
fclose(pf);
fclose(stat);
}
//**************************************************************
//** Procedure pour lire un article contenu dans un fichier***
//** ************************************************************
//***************************************************************
void Lecture(char * N_fichier)
{
system("cls");
EnTete();
FILE * pf;
article a;
int i,Nb_eng;
pf=fopen(N_fichier,"r");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
if(Nb_eng==0){ MessageUrgence("Desolé le stock est vide ");}
else{
for(i=0;i<Nb_eng;i++)
{
fread(&a,taille,1,pf);
cout<<a.fcode() <<" | "<< a.fdesignation() <<" | "<<a.fquantite() <<" | "<<a.fprixachat() <<" | "<<a.fprixvente()<<" | "<<a.date.fj()<<":"<<a.date.fm()<<":"<<a.date.fa()<<"| "<<a.foperation()<<endl;
}
}
fclose(pf);
system("pause");
}
//****************************************************************
//** Procedure pour Visualiser article en lui donnant son code**
//** *************************************************************
//****************************************************************
void Visualiser(char *N_fichier,int cod)
{
system("cls");
EnTete();
FILE *pf;
int Nb_eng,i;
article x;
pf=fopen(N_fichier,"r");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,pf);
if(cod==x.code) break;
}
if(i==Nb_eng) MessageUrgence(" ce code ne correspond a aucun article ");
else {
//cout<<x.fcode()<<"\xba"<<x.fdesignation()<<" \xba"<<x.fquantite()<<" \xba "<<x.fprixachat()<<" | "<<x.fprixvente()<<" | "<<x.date.fj()<<":"<<x.date.fm()<<":"<<x.date.fa()<<"| "<<x.foperation()<<endl;
x.Afficher();
}
fclose(pf);
}
//***************************************************************
//** Procedure pour sortir un article **************
//** ************************************************************
//***************************************************************
void Sortir(char *N_fichier,char *S_fichier,int cod)
{
system("cls");
EnTete();
FILE *pf,*stat;
int Nb_eng,i;
article x;
float quant;
pf=fopen(N_fichier,"r+");
stat=fopen(N_fichier,"a+");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,pf);
if(cod==x.code) break;
}
if(i==Nb_eng) MessageUrgence("ce code ne correspond a aucun article");
else
{
cout<<"\n Entrer la quantite que vous voulez sortir : ";
cin>>quant;
if(x.quantite<quant) cout<<"\n quentite insuffisante "<<endl;
else
{
x.quantite=x.quantite-quant;
strcpy(x.operation,"So");
fwrite(&x,taille,1,stat);
fseek(pf,-taille,1);
fwrite(&x,taille,1,pf);
}
}
fcloseall();
system("pause");
}
//*****************************************************************
//** Procedure pour la modification de la quantité d un article***
//** ***************************************************************
//******************************************************************
void modif_quantite(char *N_fichier,char *S_fichier,int cod)
{
system("cls");
EnTete();
FILE *pf,*stat;
int Nb_eng,i;
article x;
float quant;
pf=fopen(N_fichier,"r+");
stat=fopen(N_fichier,"a+");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,pf);
if(cod==x.code) break;
}
if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
else{
cout<<" entrer la nouvelle valeur :"<<endl;
cin>>quant;
x.quantite=quant;
strcpy(x.operation,"Mo");
fwrite(&x,taille,1,stat);
fseek(pf,-taille,1);
fwrite(&x,taille,1,pf);
}
fcloseall();
}
//*****************************************************************
//** Procedure pour la modification du prix vente d un article***
//** ***************************************************************
//******************************************************************
void modif_prixv(char *N_fichier,char *S_fichier,int cod)
{
system("cls");
EnTete();
FILE *pf,*stat;
int Nb_eng,i;
article x;
float pv;
pf=fopen(N_fichier,"r+");
stat=fopen(S_fichier,"a+");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,pf);
if(cod==x.code) break;
}
if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
else{
cout<<"\n entrer le nouveau prix de vente :"<<endl;
cin>>pv;
x.prixvente=pv;
strcpy(x.operation,"Mo");
fwrite(&x,taille,1,stat);
fseek(pf,-taille,1);
fwrite(&x,taille,1,pf);
}
fcloseall();
}
//******************************************************************
//** Procedure pour la modification du prix achat d un article***
//** ***************************************************************
//******************************************************************
void modif_prixa(char *N_fichier,char *S_fichier,int cod)
{
system("cls");
EnTete();
FILE *pf,*stat;
int Nb_eng,i;
article x;
float pa;
pf=fopen(N_fichier,"r+");
stat=fopen(S_fichier,"a+");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,pf);
if(cod==x.code) break;
}
if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
else{
cout<<"\n entrer le nouveau prix de vente :"<<endl;
cin>>pa;
x.prixachat=pa;
strcpy(x.operation,"Mo");
fwrite(&x,taille,1,stat);
fseek(pf,-taille,1);
fwrite(&x,taille,1,pf);
}
fcloseall();
}
//********************************************************************
//** Procedure pour la modification de la designation d un article***
//** ******************************************************************
//*********************************************************************
void modif_design(char *N_fichier,char *S_fichier,int cod)
{
system("cls");
EnTete();
FILE *pf,*stat;
int Nb_eng,i;
article x;
char desi[50];
pf=fopen(N_fichier,"r+");
stat=fopen(S_fichier,"a+");
fseek(pf,0,2);
Nb_eng=ftell(pf)/taille;
fseek(pf,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,pf);
if(cod==x.code) break;
}
if(i==Nb_eng) cout<<"\n ce code ne correspond à aucun article "<<endl;
else{
cout<<"\n entrer la nouvelle designation :"<<endl;
cin>>desi;
strcpy(x.designation,desi);
strcpy(x.operation,"Mo");
fwrite(&x,taille,1,stat);
fseek(pf,-taille,1);
fwrite(&x,taille,1,pf);
}
fcloseall();
}
//*****************************************************************
//** Procedure pour Trier les articles par designation ***
//** ***************************************************************
//******************************************************************
void tri_design(char *N_fichier)
{
FILE * f;
article x,*t;
int Nb_eng,i,k;
f=fopen(N_fichier,"r+");
fseek(f,0,2);
Nb_eng=ftell(f)/taille;
t=new article[Nb_eng];
fseek(f,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,f);
t[i]=x;
}
do{
k=0;
for(i=0;i<Nb_eng-1;i++)
if(strcmp(t[i].designation,t[i+1].designation)>0)
{
x=t[i];
t[i]=t[i+1];
t[i+1]=x;
k=1;
}
}while(k==1);
fseek(f,0,0);
for(i=0;i<Nb_eng;i++)
{
x=t[i];
fwrite(&x,taille,1,f);
}
fclose(f);
delete t;
}
//*****************************************************************
//** Procedure pour Trier les articles par prix achat ***
//** ***************************************************************
//******************************************************************
void tri_pa(char *N_fichier)
{
FILE * f;
article x,*t;
int Nb_eng,i,k;
f=fopen(N_fichier,"r+");
fseek(f,0,2);
Nb_eng=ftell(f)/taille;
t=new article[Nb_eng];
fseek(f,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,f);
t[i]=x;
}
do{
k=0;
for(i=0;i<Nb_eng-1;i++)
if(t[i].prixachat < t[i+1].prixachat)
{
x=t[i];
t[i]=t[i+1];
t[i+1]=x;
k=1;
}
}while(k==1);
fseek(f,0,0);
for(i=0;i<Nb_eng;i++)
{
x=t[i];
fwrite(&x,taille,1,f);
}
fclose(f);
delete t;
}
//******************************************************************
//** Procedure pour Trier les articles par quantité ******
//** ***************************************************************
//******************************************************************
void tri_qt(char *N_fichier)
{
FILE * f;
article x,*t;
int Nb_eng,i,k;
f=fopen(N_fichier,"r+");
fseek(f,0,2);
Nb_eng=ftell(f)/taille;
t=new article[Nb_eng];
fseek(f,0,0);
for(i=0;i<Nb_eng;i++)
{
fread(&x,taille,1,f);
t[i]=x;
}
do{
k=0;
for(i=0;i<Nb_eng-1;i++)
if(t[i].quantite < t[i+1].quantite)
{
x=t[i];
t[i]=t[i+1];
t[i+1]=x;
k=1;
}
}while(k==1);
fseek(f,0,0);
for(i=0;i<Nb_eng;i++)
{
x=t[i];
fwrite(&x,taille,1,f);
}
fclose(f);
delete t;
}
//*********************************************************************
//************************ A PROPOS **************************
//*********************************************************************
void A_Propos()
{
EnTete();
cout<<"\n\t\tMASTER INFORMTIQUE,TELECOMMUNICATION,IMAGERIE";
cout<<"\n\n\n\t\tMini projet : Gestion des stocks";
cout<<"\n\n\n\t\tRealise par :\tMAHAMAT BORGOU Hassan";
cout<<"\n\n\t\t \tNDAW Marie Elisa Adam";
cout<<"\n\n\n\t\tEncadre par :\tMr. HIMMI *****";
cout<<"\n\n\n\n\t\t\tAnnée Universitaire 2006/2007";
cout<<"\n\n";
system("pause");
}
//********************************************************
//** Fonction : MenuPrincipale **
//** Parametre : pas de parametre **
//** Traitement: creation du menu principale **
//** Retourne : un entier qui est le choix **
//********************************************************
int MenuPrincipal()
{
int choix;
EnTete();
printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
printf("\n \xb3 Menu Principale \xb3");
printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
printf("\n\n");
printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
printf("\n \xba \xba");
printf("\n \xba Ajouter un nouveau article............1 \xba");
printf("\n \xba sortir un article.....................2 \xba");
printf("\n \xba Lister les articles...................3 \xba");
printf("\n \xba Gestion des aricles...................4 \xba");
printf("\n \xba Statistique...........................5 \xba");
printf("\n \xba A propos..............................6 \xba");
printf("\n \xba Quitter...............................9 \xba");
printf("\n \xba \xba");
printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
printf("\n\n Votre choix : ");
scanf("%d",&choix);
return choix;
}
//********************************************************
//** Fonction : MenuGestionArticle **
//** Parametre : pas de parametre **
//** Traitement: creation du menu GestionArticle **
//** Retourne : un entier qui est le choix **
//********************************************************
int MenuGestionArticle()
{
int choix;
EnTete();
printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
printf("\n \xb3 Gestion des articles \xb3");
printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
printf("\n\n");
printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
printf("\n \xba \xba");
printf("\n \xba Visualiser un Article.................1 \xba");
printf("\n \xba Modifier la designation...............2 \xba");
printf("\n \xba Modifier la quantite..................3 \xba");
printf("\n \xba Modifier le prix d'achat..............4 \xba");
printf("\n \xba Modifier le prix de vente.............5 \xba");
printf("\n \xba Retour................................9 \xba");
printf("\n \xba \xba");
printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
printf("\n\n Votre choix : ");
scanf("%d",&choix);
//choix=getch();
//putch(choix);
Sleep(120);
return choix;
}
//********************************************************
//** Fonction : MenuGestionModification **
//** Parametre : pas de parametre **
//** Traitement: creation du menu GestionModification**
//** Retourne : un entier qui est le choix **
//********************************************************
int MenuModification()
{
int choix;
EnTete();
printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
printf("\n \xb3 Modifications des articles \xb3");
printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
printf("\n\n");
printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
printf("\n \xba \xba");
printf("\n \xba Modifier la code.................1 \xba");
printf("\n \xba Modifier la designation..........2 \xba");
printf("\n \xba Modifier la quantite.............3 \xba");
printf("\n \xba Modifier le Prix achat...........4 \xba");
printf("\n \xba Modifier le Prix vente...........5 \xba");
printf("\n \xba Retour...........................9 \xba");
printf("\n \xba \xba");
printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
printf("\n\n Votre choix : ");
scanf("%d",&choix);
choix=getch();
putch(choix);
Sleep(120);
return choix;
}
//********************************************************
//** Fonction : MenuGestionStatistique **
//** Parametre : pas de parametre **
//** Traitement: creation du menu GestionStatistique **
//** Retourne : un entier qui est le choix **
//********************************************************
int MenuGestionStatistique()
{
int choix;
EnTete();
printf("\n \xda\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xbf");
printf("\n \xb3 Gestion des historiques \xb3");
printf("\n \xc0\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xc4\xd9");
printf("\n\n");
printf("\n \xc9\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbb");
printf("\n \xba \xba");
printf("\n \xba Visualiser historiques................1 \xba");
printf("\n \xba Classer par nom......................2 \xba");
printf("\n \xba Classer par quantite.................3 \xba");
printf("\n \xba Classer par prix d'achat.............4 \xba");
printf("\n \xba Retour................................7 \xba");
printf("\n \xba \xba");
printf("\n \xba \xba");
printf("\n \xc8\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xbc");
printf("\n\n Votre choix : ");
scanf("%d",&choix);
//choix=getch();
//putch(choix);
Sleep(120);
return choix;
}
/*****************************************************************
//**** ******************** ****
//****** ** ** *****
//********* ***PROGRAMME PRINCIPALE*** **********
//****** ** ** *****
//**** ******************** ****
//*****************************************************************/
void main()
{
int choix_principal=0,choix_second=0,choix,tmp,cod;
char NF[]="f1.txt";
char NF1[]="f2.txt";
msgSauvCharg("Master iti");
msgSauvCharg("mini projet d'algorithmique");
msgSauvCharg("chargement des articles");
msgSauvCharg("chargement des historiques");
while((choix_second!=27)&&(choix_principal!=9))
{
choix_principal=MenuPrincipal();
switch(choix_principal)
{
case 1:
ajouter(NF,NF1);
break;
case 2:
cout<<"\n entrer le code de l'article à sortir : ";
cin>>cod;
Sortir(NF,NF1,cod);
break;
case 3:
Lecture(NF);
break;
case 4://gestion des articles
choix_second=MenuGestionArticle();
while(choix_second!=27)
{
if( choix_second==1)
{
EnTete();
cout<<"\t***** VISUALISATION DE L ARTICLE *********"<<endl;
cout<<"\n entrer votre code a visualiser : ";
cin>>cod;
Visualiser(NF,cod);
choix_second=MenuGestionArticle();
}
if( choix_second==2)
{
EnTete();
cout<<"\t*******MODIFICATION DE LA DESIGNATION ******** :"<<endl;
cout<<"\t Entrer le code de l' article a modifier : ";
cin>>tmp;
modif_design(NF,NF1,tmp);
choix_second=MenuGestionArticle();
}
if( choix_second==3)
{
EnTete();
cout<<"\t*******MODIFICATION DE LA QUANTITE ******** :"<<endl;
cout<<"\t Entrer le code de l' article a modifier : ";
cin>>tmp;
modif_quantite(NF,NF1,tmp);
choix_second=MenuGestionArticle();
}
if( choix_second==4)
{
EnTete();
cout<<"\t*******MODIFICATION DU PPRIX D ACHAT ******* :"<<endl;
cout<<"\t Entrer le code de l' article a modifier : ";
cin>>tmp;
modif_prixa(NF,NF1,tmp);
choix_second=MenuGestionArticle();
}
if(choix_second==5)
{
EnTete();
cout<<"\t*******MODIFICATION DU PRIX VENTE ******** :"<<endl;
cout<<"\t Entrer le code de l' article a modifier :";
cin>>tmp;
modif_prixv(NF,NF1,tmp);
choix_second=MenuGestionArticle();
}
if(choix_second==9)
choix_second=27;
}
break;
case 5: //gestion des statistiques
choix_second=MenuGestionStatistique();
while(choix_second!=27)
{
if( choix_second==1)
{
cout<<"\t***** VISUALISATION DES HISTORIQUES *********"<<endl;
Lecture(NF);
choix_second=MenuGestionStatistique();
}
if( choix_second==2)
{
cout<<"\t ******ORDONNER LES ARTICLES PAR NOMS********"<<endl;
tri_design(NF);
Lecture(NF);
choix_second=MenuGestionStatistique();
}
if( choix_second==3)
{
cout<<"\t *******TRIER PAR LA QUANTITE ***************"<<endl;
tri_qt(NF);
Lecture(NF);
choix_second=MenuGestionStatistique();
}
if( choix_second==4)
{
cout<<"\t************** TRIER PAR PRIX ACHAT *********** "<<endl;
tri_pa(NF);
Lecture(NF);
choix_second=MenuGestionStatistique();
}
if(choix_second==7)
choix_second=27;
}
break;
case 6:
A_Propos();
break;
case 9: break;
}
}
}
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
gestion de stock d'un magasin [ par alae_87 ]
je veux pour un mini projet un programme en c en utilisant les fichiers, qui permet le gestion de stock d'un magasin.merci
GESTION STOCK ET FICHIER CLIENTS [ par ERVATDU ]
Bonjour,Je suis artisan toiletteur, et dans le cadre du suivi de mes stocks et fichier clients, j'ai depuis plusieurs mois chercher plusieurs info sur
gestion de stock une pharmacie [ par ljaafar ]
j'ai besoin d'un programme en langage C realise a base des FICHIER , pour la gestion d'un stock d'une pharmacie.....merci
jai besoin d'un code en C pour la gestion de stock [ par martintchabgou ]
Je suis à la recherche d'un code en C concernant la gestion de stock pour un débutant.
commerce [ par milan0086 ]
est ce que je peut avoir une aide sur un log sur la gestion commerciel ou gestion des stok facture laivraison meci
gestion d'un processus des archives [ par omario09 ]
bonjour a tous, bain je suis un débutant en programmation .net et je suis entrain d'effectuer un stage au saint d'une entreprise et mon theme c'est de
gestion des entretients préventif [ par ares697atz ]
bonjour,je recherche une petite appliquation, avec laquelle je souhaite gerrer mon parc de véhicule et ainsi à partir d'un prévisionnel de temps d'uti
gestion CPropertyPage [ par coverHarry ]
Bonsoir à tous,Voilà mon problème. Je programme en C++ avec les MFC. Je développe une librairie chargée par un logiciel à son démarrage et qui permet
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|