From 41c4f178ffcf0f738772b2f5548884ece8a852b9 Mon Sep 17 00:00:00 2001 From: "ange.bardet" Date: Tue, 7 Nov 2023 16:53:56 +0100 Subject: [PATCH] =?UTF-8?q?Le=20d=C3=A9but=20d'un=20nouveau=20monde.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FICHIERANGE/fonctionsArticle.c | 211 ----------------- FICHIERANGE/test.c | 117 ---------- FICHIERCYRIAQUE/-Wall | Bin 17080 -> 0 bytes FICHIERCYRIAQUE/fichierclient.don | 8 - FICHIERCYRIAQUE/sae | Bin 21464 -> 0 bytes FICHIERCYRIAQUE/sae.h | 10 - FICHIERCYRIAQUE/sae.h~ | 4 - FICHIERCYRIAQUE/testsae.c | 7 - .../fonctionsCommande.c => FonctionsClient.c | 15 +- .../fonctionsCommande.h => FonctionsClient.h | 1 + .../ajoutClient.c => FonctionsResponsable.c | 215 +++++++++++++++++- ...nctionsArticle.h => FonctionsResponsable.h | 9 + Globale.c | 140 ++++++++++++ FICHIERANGE/Makefile => Makefile | 0 affichages.c | 18 -- FICHIERANGE/articles.txt => articles.txt | 0 fichierclient.don | 1 + sae.c | 64 ------ sae.h | 4 - testsae.c | 7 - 20 files changed, 376 insertions(+), 455 deletions(-) delete mode 100644 FICHIERANGE/fonctionsArticle.c delete mode 100644 FICHIERANGE/test.c delete mode 100755 FICHIERCYRIAQUE/-Wall delete mode 100644 FICHIERCYRIAQUE/fichierclient.don delete mode 100755 FICHIERCYRIAQUE/sae delete mode 100644 FICHIERCYRIAQUE/sae.h delete mode 100644 FICHIERCYRIAQUE/sae.h~ delete mode 100644 FICHIERCYRIAQUE/testsae.c rename FICHIERANGE/fonctionsCommande.c => FonctionsClient.c (92%) rename FICHIERANGE/fonctionsCommande.h => FonctionsClient.h (91%) rename FICHIERCYRIAQUE/ajoutClient.c => FonctionsResponsable.c (67%) rename FICHIERANGE/fonctionsArticle.h => FonctionsResponsable.h (71%) create mode 100644 Globale.c rename FICHIERANGE/Makefile => Makefile (100%) delete mode 100644 affichages.c rename FICHIERANGE/articles.txt => articles.txt (100%) create mode 100644 fichierclient.don delete mode 100644 sae.c delete mode 100644 sae.h delete mode 100644 testsae.c diff --git a/FICHIERANGE/fonctionsArticle.c b/FICHIERANGE/fonctionsArticle.c deleted file mode 100644 index 7204140..0000000 --- a/FICHIERANGE/fonctionsArticle.c +++ /dev/null @@ -1,211 +0,0 @@ -#include "fonctionsArticle.h" -#include -#include - -void AjoutArticle(void) -{ - int ref; - float poid,volume,prix; - FILE *flot; - flot = fopen("articles.txt","a"); - if (flot == NULL) - { - printf("Problème avec la création du fichier\n"); - exit(1); - } - printf("Saisir la référence de l'article (-1 pour arrêter): "); - scanf("%d",&ref); - while (ref < -1) - { - printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); - scanf("%d",&ref); - } - while (ref >= 0) - { - printf("Saisir le poid(kg): "); - scanf("%f",&poid); - while (poid < 0) - { - printf("Erreur ; Le poid doit être positif ; retapez : "); - scanf("%f",&poid); - } - - printf("Saisir le volume: "); - scanf("%f",&volume); - while (volume < 0) - { - printf("Erreur ; Le volume doit être positif ; retapez : "); - scanf("%f",&volume); - } - - printf("Saisir le prix: "); - scanf("%f",&prix); - while (prix < 0) - { - printf("Erreur ; Le prix doit être positif ; retapez : "); - scanf("%f",&prix); - } - - fprintf(flot,"%d\t%.3f\t%.2f\t%.2f\n",ref,poid,volume,prix); - printf("Saisir la référence de l'article (-1 pour arrêter): "); - scanf("%d",&ref); - while (ref < -1) - { - printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); - scanf("%d",&ref); - } - } - fclose(flot); - printf("Fin de l'ajout.\n"); -} - -int TableArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[]) -{ - int ref,i=0; - float poid,volume,prix; - - FILE *flot; - flot = fopen("articles.txt","r"); - if (flot == NULL) - { - printf("Problème avec la lecture du fichier\n"); - exit(1); - } - - fscanf(flot,"%d %f %f %f",&ref,&poid,&volume,&prix); - while(feof(flot) == 0) - { - Tref[i] = ref; - Tpoid[i] = poid; - Tvolume[i] = volume; - Tprix[i] = prix; - i++; - fscanf(flot,"%d %f %f %f",&ref,&poid,&volume,&prix); - } - fclose(flot); - return i; -} - -void AffichTable(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) -{ - int i; - printf("référence\tpoids(kg)\tvolume(l)\tprix Unitaire\n"); - for (i=0;i < n;i++) - { - printf("%d\t\t%.2f\t\t%.3f\t\t%.2f\n",Tref[i],Tpoid[i],Tvolume[i],Tprix[i]); - } -} - -void AffichArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) -{ - int refR,pos; - printf("Afficher quel article ? "); - scanf("%d",&refR); - pos = posRef(Tref,refR,n); - if (pos == -1) - { - printf("L'article n'existe pas dans la base de donnée."); - } - else - { - printf("%d\t\t%.2f\t\t%.3f\t\t%.2f\n",Tref[pos],Tpoid[pos],Tvolume[pos],Tprix[pos]); - } -} - -void ModifArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) -{ - int refR; - printf("Saisir la référence de l'article a modifier: "); - scanf("%d",&refR); - while (refR < -1) - { - printf("Erreur ; Le numéro doit être positif; retapez : "); - scanf("%d",&refR); - } - int i; - for (i=0;i < n;i++) - { - if (Tref[i] == refR) - { - printf("Saisir le nouveau poid(kg): "); - scanf("%f",&Tpoid[i]); - while (Tpoid[i] < 0) - { - printf("Erreur ; Le poid doit être positif ; retapez : "); - scanf("%f",&Tpoid[i]); - } - - printf("Saisir le nouveau volume: "); - scanf("%f",&Tvolume[i]); - while (Tvolume[i] < 0) - { - printf("Erreur ; Le volume doit être positif ; retapez : "); - scanf("%f",&Tvolume[i]); - } - - printf("Saisir le nouveau prix: "); - scanf("%f",&Tprix[i]); - while (Tprix[i] < 0) - { - printf("Erreur ; Le prix doit être positif ; retapez : "); - scanf("%f",&Tprix[i]); - } - } - } -} - -void EcrireFichier(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) -{ - FILE *flot; - flot = fopen("articles.txt","w"); - if (flot == NULL) - { - printf("Problème avec la création du fichier\n"); - exit(1); - } - int i; - for (i=0;i < n;i++) fprintf(flot,"%d\t%.2f\t%.3f\t%.2f\n",Tref[i],Tpoid[i],Tvolume[i],Tprix[i]); - fclose(flot); - printf("Fichier écrit.\n"); -} - -int posRef(int Tref[],int refR, int n) -{ - int i; - for (i=0;i < n;i++) - { - if (Tref[i] == refR) - return i; - } - return -1; -} - -int SupprArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) -{ - int refR,pos; - printf("Saisir la référence de l'article a supprimer: "); - scanf("%d",&refR); - while (refR < -1) - { - printf("Erreur ; Le numéro doit être positif; retapez : "); - scanf("%d",&refR); - } - pos = posRef(Tref,refR,n); - if (pos == -1) - { - printf("L'article n'existe pas dans la base de donnée."); - return n; - } - else - { - int i; - for (i=pos;i<=n;i++) - { - Tref[i] = Tref[i+1]; - Tpoid[i] = Tpoid[i+1]; - Tvolume[i] = Tvolume[i+1]; - Tprix[i] = Tprix[i+1]; - } - return n-=1; - } -} \ No newline at end of file diff --git a/FICHIERANGE/test.c b/FICHIERANGE/test.c deleted file mode 100644 index be4fb34..0000000 --- a/FICHIERANGE/test.c +++ /dev/null @@ -1,117 +0,0 @@ -#include "fonctionsArticle.h" -#include "fonctionsCommande.h" - -void testF(void) -{ - int n=0,rep; - int Tref[100]={0}; - float Tpoid[100]={0},Tvolume[100]={0},Tprix[100]={0},volV,chargeV;; - n = TableArticle(Tref,Tpoid,Tvolume,Tprix); - printf("Responsable / Client ? (R[0]/C[1])"); - scanf("%d",&rep); - while (rep < 0 || rep > 1) - { - printf("Erreur; (R[0]/C[1]) "); - scanf("%d",&rep); - } - if (rep == 0) - { - printf("Bienvenue Mr. le responsable :)\n"); - printf("Que voulez vous faire ? (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); - scanf("%d",&rep); - while (rep != 9) - { - while ((rep < 0 || rep > 3) && rep != 9) - { - printf("Erreur; (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); - scanf("%d",&rep); - } - if (rep == 0) - { - AffichTable(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 1) - { - AffichArticle(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 2) - { - AjoutArticle(); - n = TableArticle(Tref,Tpoid,Tvolume,Tprix); - printf("\n"); - } - if (rep == 3) - { - ModifArticle(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 4) - { - n = SupprArticle(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep != 9) - { - printf("Que faire ? (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); - scanf("%d",&rep); - } - } - } - if (rep == 1) - { - printf("Bienvenue Mr. le client :)\n"); - volV = initVoiture(&chargeV); - printf("Que voulez vous faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); - scanf("%d",&rep); - int TrefC[200]={0},TquanC[200]={0},nArticle=0; - while (rep != 9) - { - while ((rep < 0 || rep > 4) && rep != 9) - { - printf("Erreur; (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); - scanf("%d",&rep); - } - if (rep == 0) - { - nArticle = ajoutPanier(TrefC,TquanC,nArticle,Tref,n); - affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); - printf("\n"); - } - if (rep == 1) - { - ModifArticlePanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 2) - { - nArticle = SupprArticlePanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 3) - { - affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); - printf("\n"); - } - if (rep == 4) - { - nArticle = ResetPanier(TrefC,TquanC,nArticle); - printf("\n"); - } - if (rep != 9) - { - printf("Que faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); - scanf("%d",&rep); - } - - } - } - EcrireFichier(Tref,Tpoid,Tvolume,Tprix,n); - printf("Au revoir !\n"); -} -int main(void) -{ - testF(); - return 0; -} \ No newline at end of file diff --git a/FICHIERCYRIAQUE/-Wall b/FICHIERCYRIAQUE/-Wall deleted file mode 100755 index 868d548df865c459fa78fc7dc0303687d46edb34..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17080 zcmeHOeQ;FO6~CM1BPeXbmqyX@K&io!B~Xb02HnjUFKs};fY^$UCHs~v-R#EQw=__z zu`x_DF_dwn!%Ve9r)o=Wr?xX~t=efcR@CV@YNwTc*iuKQ8=)En5l3MAJNMnQdHdKM zo&M38wtHds-19ph_uTXDdwF;7y>~XZwUl{0f{RyNCx{!aw2^=k)UQ+(kbtNc7vlR< z;&L$w`~->F@_em`&xA9taA6pEj2vqJbIz%_i_<$3_~-5~LiM7J3ih7nCA zI+iatQXQdqM0BUEl!%y#$haV4OClYyM9LJA?qoD>k+`ELWJIFzP%OIJ1dCzPVWg~3 z(lWY2(YPRHvKUK{!8Sh_4OMw~ebuwB+jpl1P2B;SvbgHNrR-gy;eK zw*6dSSLOG*fX$Hpg?6>{UCKZy1Emakg zOM2fk)n7hm&4Po6l!Nl@(THq^ z?R!^wU?_CQPM18-VW^}$uIgUQsOOPNl5Jv;G_;5}Q|j_K%EAlwKW{jTFj zWzY7nJD1HqMlt?!sdV@13H=d$X#en;f^h9e=fj7a&yfA$=F?%2Oe?O|K=Vm`XxS;e z!lTFUf@G3tMjvR-=tDoNh7WycNRwp$A|iv$nO0?x()U_FHlu-#~}ax(Oijn5_59EK9Xx zm|@u+J^M-Wa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d00PxqMTtT$|<7Zj(wy}xc$BAXPjk1WUVFepxWzV6@Ds6^OLR={%H{umX)vHyJC+S#Z$ z-26HmiiqQ9_$OSgjZqbrpX - -int modifclientglobal (void); -int ajoutClient (void); -int suspensioncarte (int *n); -int compteurtaillelogique (void); -int supressionclient (int *n); -int affichagesolo (void); -int affichageall (void); -int creationfichier(void); diff --git a/FICHIERCYRIAQUE/sae.h~ b/FICHIERCYRIAQUE/sae.h~ deleted file mode 100644 index 196d225..0000000 --- a/FICHIERCYRIAQUE/sae.h~ +++ /dev/null @@ -1,4 +0,0 @@ -#include - -void test(void); -void ajoutArticle(void); diff --git a/FICHIERCYRIAQUE/testsae.c b/FICHIERCYRIAQUE/testsae.c deleted file mode 100644 index 6be52ae..0000000 --- a/FICHIERCYRIAQUE/testsae.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "sae.h" - -int main(void) -{ - modifclientglobal(); - return 0; //cette instruction sert a dire au sys que prog termine -} diff --git a/FICHIERANGE/fonctionsCommande.c b/FonctionsClient.c similarity index 92% rename from FICHIERANGE/fonctionsCommande.c rename to FonctionsClient.c index 7286b75..0d38ba1 100644 --- a/FICHIERANGE/fonctionsCommande.c +++ b/FonctionsClient.c @@ -1,5 +1,5 @@ -#include "fonctionsCommande.h" -#include "fonctionsArticle.h" +#include "FonctionsClient.h" +#include "FonctionsResponsable.h" #include #include @@ -43,8 +43,19 @@ float initVoiture(float *chargeV) float volV; printf("Quel est le volume (L) du coffre de votre véhicule : "); scanf("%f",&volV); + while (volV < 0) + { + printf("Erreur ; Le volume doit être positif ; retapez : "); + scanf("%f",&volV); + } printf("Quel est la charge totale de votre véhicule (Kg) : "); scanf("%f",chargeV); + while (*chargeV < 0) + { + printf("Erreur ; La charge doit être positive ; retapez : "); + scanf("%f",chargeV); + } + return volV; } diff --git a/FICHIERANGE/fonctionsCommande.h b/FonctionsClient.h similarity index 91% rename from FICHIERANGE/fonctionsCommande.h rename to FonctionsClient.h index 1d8f906..7024dcf 100644 --- a/FICHIERANGE/fonctionsCommande.h +++ b/FonctionsClient.h @@ -1,4 +1,5 @@ #include + int ajoutPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], int n); void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],float chargeV, float volV,int n); float initVoiture(float *chargeV); diff --git a/FICHIERCYRIAQUE/ajoutClient.c b/FonctionsResponsable.c similarity index 67% rename from FICHIERCYRIAQUE/ajoutClient.c rename to FonctionsResponsable.c index 45f14a5..c338779 100644 --- a/FICHIERCYRIAQUE/ajoutClient.c +++ b/FonctionsResponsable.c @@ -1,7 +1,216 @@ +#include "FonctionsResponsable.h" +#include +#include -#include "sae.h" +void AjoutArticle(void) +{ + int ref; + float poid,volume,prix; + FILE *flot; + flot = fopen("articles.txt","a"); + if (flot == NULL) + { + printf("Problème avec la création du fichier\n"); + exit(1); + } + printf("Saisir la référence de l'article (-1 pour arrêter): "); + scanf("%d",&ref); + while (ref < -1) + { + printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); + scanf("%d",&ref); + } + while (ref >= 0) + { + printf("Saisir le poid(kg): "); + scanf("%f",&poid); + while (poid < 0) + { + printf("Erreur ; Le poid doit être positif ; retapez : "); + scanf("%f",&poid); + } + + printf("Saisir le volume: "); + scanf("%f",&volume); + while (volume < 0) + { + printf("Erreur ; Le volume doit être positif ; retapez : "); + scanf("%f",&volume); + } + + printf("Saisir le prix: "); + scanf("%f",&prix); + while (prix < 0) + { + printf("Erreur ; Le prix doit être positif ; retapez : "); + scanf("%f",&prix); + } + + fprintf(flot,"%d\t%.3f\t%.2f\t%.2f\n",ref,poid,volume,prix); + printf("Saisir la référence de l'article (-1 pour arrêter): "); + scanf("%d",&ref); + while (ref < -1) + { + printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); + scanf("%d",&ref); + } + } + fclose(flot); + printf("Fin de l'ajout.\n"); +} + +int TableArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[]) +{ + int ref,i=0; + float poid,volume,prix; + + FILE *flot; + flot = fopen("articles.txt","r"); + if (flot == NULL) + { + printf("Problème avec la lecture du fichier\n"); + exit(1); + } + + fscanf(flot,"%d %f %f %f",&ref,&poid,&volume,&prix); + while(feof(flot) == 0) + { + Tref[i] = ref; + Tpoid[i] = poid; + Tvolume[i] = volume; + Tprix[i] = prix; + i++; + fscanf(flot,"%d %f %f %f",&ref,&poid,&volume,&prix); + } + fclose(flot); + return i; +} + +void AffichTable(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) +{ + int i; + printf("référence\tpoids(kg)\tvolume(l)\tprix Unitaire\n"); + for (i=0;i < n;i++) + { + printf("%d\t\t%.2f\t\t%.3f\t\t%.2f\n",Tref[i],Tpoid[i],Tvolume[i],Tprix[i]); + } +} + +void AffichArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) +{ + int refR,pos; + printf("Afficher quel article ? "); + scanf("%d",&refR); + pos = posRef(Tref,refR,n); + if (pos == -1) + { + printf("L'article n'existe pas dans la base de donnée."); + } + else + { + printf("%d\t\t%.2f\t\t%.3f\t\t%.2f\n",Tref[pos],Tpoid[pos],Tvolume[pos],Tprix[pos]); + } +} + +void ModifArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) +{ + int refR; + printf("Saisir la référence de l'article a modifier: "); + scanf("%d",&refR); + while (refR < -1) + { + printf("Erreur ; Le numéro doit être positif; retapez : "); + scanf("%d",&refR); + } + int i; + for (i=0;i < n;i++) + { + if (Tref[i] == refR) + { + printf("Saisir le nouveau poid(kg): "); + scanf("%f",&Tpoid[i]); + while (Tpoid[i] < 0) + { + printf("Erreur ; Le poid doit être positif ; retapez : "); + scanf("%f",&Tpoid[i]); + } + + printf("Saisir le nouveau volume: "); + scanf("%f",&Tvolume[i]); + while (Tvolume[i] < 0) + { + printf("Erreur ; Le volume doit être positif ; retapez : "); + scanf("%f",&Tvolume[i]); + } + + printf("Saisir le nouveau prix: "); + scanf("%f",&Tprix[i]); + while (Tprix[i] < 0) + { + printf("Erreur ; Le prix doit être positif ; retapez : "); + scanf("%f",&Tprix[i]); + } + } + } +} + +void EcrireFichier(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) +{ + FILE *flot; + flot = fopen("articles.txt","w"); + if (flot == NULL) + { + printf("Problème avec la création du fichier\n"); + exit(1); + } + int i; + for (i=0;i < n;i++) fprintf(flot,"%d\t%.2f\t%.3f\t%.2f\n",Tref[i],Tpoid[i],Tvolume[i],Tprix[i]); + fclose(flot); + printf("Fichier écrit.\n"); +} -int modifclientglobal (void) +int posRef(int Tref[],int refR, int n) +{ + int i; + for (i=0;i < n;i++) + { + if (Tref[i] == refR) + return i; + } + return -1; +} + +int SupprArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) +{ + int refR,pos; + printf("Saisir la référence de l'article a supprimer: "); + scanf("%d",&refR); + while (refR < -1) + { + printf("Erreur ; Le numéro doit être positif; retapez : "); + scanf("%d",&refR); + } + pos = posRef(Tref,refR,n); + if (pos == -1) + { + printf("L'article n'existe pas dans la base de donnée."); + return n; + } + else + { + int i; + for (i=pos;i<=n;i++) + { + Tref[i] = Tref[i+1]; + Tpoid[i] = Tpoid[i+1]; + Tvolume[i] = Tvolume[i+1]; + Tprix[i] = Tprix[i+1]; + } + return n-=1; + } +} + +void modifclientglobal (void) { int n,coderreur,choix; @@ -46,7 +255,7 @@ int modifclientglobal (void) } printf("Au revoir !\n"); - return 0; + return; } diff --git a/FICHIERANGE/fonctionsArticle.h b/FonctionsResponsable.h similarity index 71% rename from FICHIERANGE/fonctionsArticle.h rename to FonctionsResponsable.h index 21e5ba8..30c545f 100644 --- a/FICHIERANGE/fonctionsArticle.h +++ b/FonctionsResponsable.h @@ -8,3 +8,12 @@ void AffichArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n void EcrireFichier(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n); int SupprArticle(int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n); int posRef(int Tref[],int refR, int n); + +void modifclientglobal (void); +int ajoutClient (void); +int suspensioncarte (int *n); +int compteurtaillelogique (void); +int supressionclient (int *n); +int affichagesolo (void); +int affichageall (void); +int creationfichier(void); diff --git a/Globale.c b/Globale.c new file mode 100644 index 0000000..84e8590 --- /dev/null +++ b/Globale.c @@ -0,0 +1,140 @@ +#include "FonctionsClient.h" +#include "FonctionsResponsable.h" + +void global(void) +{ + int n=0,rep; + int Tref[100]={0}; + float Tpoid[100]={0},Tvolume[100]={0},Tprix[100]={0},volV,chargeV;; + n = TableArticle(Tref,Tpoid,Tvolume,Tprix); + printf("Responsable / Client ? (R[0]/C[1])"); + scanf("%d",&rep); + while (rep < 0 || rep > 1) + { + printf("Erreur; (R[0]/C[1]) "); + scanf("%d",&rep); + } + if (rep == 0) + { + printf("Bienvenue Mr. le responsable :)\n"); + printf("Que voulez vous faire ? (Gestion d'articles[0]/Gestion de clients[1]/quitter[9]) "); + scanf("%d",&rep); + while (rep != 9) + { + while ((rep < 0 || rep > 1) && rep != 9) + { + printf("Erreur; (Gestion d'articles[0]/Gestion de clients[1]/quitter[9]) "); + scanf("%d",&rep); + } + if (rep == 0) + { + printf("Que voulez vous faire ? (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); + scanf("%d",&rep); + while (rep != 9) + { + while ((rep < 0 || rep > 3) && rep != 9) + { + printf("Erreur; (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); + scanf("%d",&rep); + } + if (rep == 0) + { + AffichTable(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 1) + { + AffichArticle(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 2) + { + AjoutArticle(); + n = TableArticle(Tref,Tpoid,Tvolume,Tprix); + printf("\n"); + } + if (rep == 3) + { + ModifArticle(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 4) + { + n = SupprArticle(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep != 9) + { + printf("Que faire ? (afficher[0]/afficher article[1]/ajouter[2]/modifier[3]/supprimer[4]/quitter[9]) "); + scanf("%d",&rep); + } + } + rep=0; + } + if (rep == 1) + { + modifclientglobal(); + } + if (rep != 9) + { + printf("Que faire ? (Gestion d'articles[0]/Gestion de clients[1]/quitter[9]) "); + scanf("%d",&rep); + } + } + } + if (rep == 1) + { + printf("Bienvenue Mr. le client :)\n"); + volV = initVoiture(&chargeV); + printf("Que voulez vous faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); + scanf("%d",&rep); + int TrefC[200]={0},TquanC[200]={0},nArticle=0; + while (rep != 9) + { + while ((rep < 0 || rep > 4) && rep != 9) + { + printf("Erreur; (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); + scanf("%d",&rep); + } + if (rep == 0) + { + nArticle = ajoutPanier(TrefC,TquanC,nArticle,Tref,n); + affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); + printf("\n"); + } + if (rep == 1) + { + ModifArticlePanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 2) + { + nArticle = SupprArticlePanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 3) + { + affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,chargeV,volV,n); + printf("\n"); + } + if (rep == 4) + { + nArticle = ResetPanier(TrefC,TquanC,nArticle); + printf("\n"); + } + if (rep != 9) + { + printf("Que faire ? (Ajout[0]/ModifierArticle[1]/SupprimerArticle[2]/AfficherPanier[3]/ResetPanier[4]/quitter[9]) "); + scanf("%d",&rep); + } + + } + } + EcrireFichier(Tref,Tpoid,Tvolume,Tprix,n); + printf("Au revoir !\n"); +} +int main(void) +{ + global(); + return 0; +} \ No newline at end of file diff --git a/FICHIERANGE/Makefile b/Makefile similarity index 100% rename from FICHIERANGE/Makefile rename to Makefile diff --git a/affichages.c b/affichages.c deleted file mode 100644 index 1d2fcd8..0000000 --- a/affichages.c +++ /dev/null @@ -1,18 +0,0 @@ -void AffRecap(void){ - - FILE *flot; - - flot = fopen("logs.txt","r"); - - if(flot == NULL) { - printf("ERR0R: FILE NOT VALID."); - return; - } - - int refe, qt,poids, vol, prixU; - int pdt=poids*qt, vt=vol*qt, pxt=prixU*qt, cagn; - - while(feof(flot)==0) { - printf("\tRéférences\tQuantités\tPoids (KG)\tVolume (L)\tPrix Unitaire\tPoids Total\tCagnotte\n"); - } -} \ No newline at end of file diff --git a/FICHIERANGE/articles.txt b/articles.txt similarity index 100% rename from FICHIERANGE/articles.txt rename to articles.txt diff --git a/fichierclient.don b/fichierclient.don new file mode 100644 index 0000000..8619d63 --- /dev/null +++ b/fichierclient.don @@ -0,0 +1 @@ +344 0.00 0 diff --git a/sae.c b/sae.c deleted file mode 100644 index 5191098..0000000 --- a/sae.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "sae.h" -#include - -void test(void) -{ - printf("Test.\n"); -} - -void ajoutArticle(void) -{ - int ref; - float poid,volume,prix; - FILE *flot; - flot = fopen("articles.txt","a"); - if (flot == NULL) - { - printf("Problème avec la création du fichier\n"); - exit(1); - } - printf("Saisir la référence de l'article (-1 pour arrêter): "); - scanf("%d",&ref); - while (ref < -1) - { - printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); - scanf("%d",&ref); - } - while (ref != -1) - { - printf("Saisir le poid(kg): "); - scanf("%f",&poid); - while (poid < 0) - { - printf("Erreur ; Le poid doit être positif ; retapez : "); - scanf("%f",poid); - } - - printf("Saisir le volume: "); - scanf("%f",&volume); - while (volume < 0) - { - printf("Erreur ; Le volume doit être positif ; retapez : "); - scanf("%f",volume); - } - - printf("Saisir le prix: "); - scanf("%f",&prix); - while (prix < 0) - { - printf("Erreur ; Le prix doit être positif ; retapez : "); - scanf("%f",prix); - } - - fprintf(flot,"%d\t%.3f\t%.2f\t%.2f\n",ref,poid,volume,prix); - printf("Saisir la référence de l'article (-1 pour arrêter): "); - scanf("%d",&ref); - while (ref < -1) - { - printf("Erreur ; Le numéro doit être positif (ou -1 pour arrêter); retapez : "); - scanf("%d",&ref); - } - } - fclose(flot); - printf("Fin \n"); -} \ No newline at end of file diff --git a/sae.h b/sae.h deleted file mode 100644 index 196d225..0000000 --- a/sae.h +++ /dev/null @@ -1,4 +0,0 @@ -#include - -void test(void); -void ajoutArticle(void); diff --git a/testsae.c b/testsae.c deleted file mode 100644 index f8db13a..0000000 --- a/testsae.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "sae.h" - -int main(void) -{ - ajoutArticle(); - return 0; //cette instruction sert a dire au sys que prog termine -}