diff --git a/FICHIERANGE/ange.c b/FICHIERANGE/fonctionsArticle.c similarity index 99% rename from FICHIERANGE/ange.c rename to FICHIERANGE/fonctionsArticle.c index c3f41a8..26ebec3 100644 --- a/FICHIERANGE/ange.c +++ b/FICHIERANGE/fonctionsArticle.c @@ -1,4 +1,4 @@ -#include "ange.h" +#include "fonctionsArticle.h" #include #include diff --git a/FICHIERANGE/ange.h b/FICHIERANGE/fonctionsArticle.h similarity index 100% rename from FICHIERANGE/ange.h rename to FICHIERANGE/fonctionsArticle.h diff --git a/FICHIERANGE/fonctionsCommande.c b/FICHIERANGE/fonctionsCommande.c new file mode 100644 index 0000000..fb7838d --- /dev/null +++ b/FICHIERANGE/fonctionsCommande.c @@ -0,0 +1,58 @@ +#include "fonctionsCommande.h" +#include "fonctionsArticle.h" +#include +#include + +int ajoutPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], int n) +{ + int refP,code,quantite; + printf("Saisir la référence du produit à ajouter au panier: "); + scanf("%d",&refP); + + code = posRef(Tref,refP,n); + while (code == -1) + { + printf("Erreur ; Cette référence n'existe pas dans la base de donnée; retapez : "); + scanf("%d",&refP); + code = posRef(Tref,refP,n); + } + + printf("Saisir la quantité souhaité pour le produit: "); + scanf("%d",&quantite); + while (quantite < 1) + { + printf("Erreur ; La quantité peut seulement être positive; retapez : "); + scanf("%d",&quantite); + } + printf("\nRéférence : %d\n",refP); + printf("Quantité : %d\n",quantite); + TrefC[nArticle] = refP; + TquanC[nArticle] = quantite; + return nArticle +=1; +} + +void affichPanier(int TrefC[],int TquanC[],int nArticle,int Tref[], float Tpoid[],float Tvolume[],float Tprix[],int n) +{ + printf("\nRéf\tQté\tPoids\tVol\tPrixU\tPoidsTot\tVolTot\tPrixTot\tCagnotte\n"); + int i, pos,cagnotte; + float prixtot; + int cfinal=0; + float prixfinal=0,volfinal=0,chargefinal=0; + for (i=0;i +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[],int n); diff --git a/FICHIERANGE/sae-S1.01 b/FICHIERANGE/sae-S1.01 index f31b822..1d013b7 100755 Binary files a/FICHIERANGE/sae-S1.01 and b/FICHIERANGE/sae-S1.01 differ diff --git a/FICHIERANGE/test.c b/FICHIERANGE/test.c new file mode 100644 index 0000000..201a453 --- /dev/null +++ b/FICHIERANGE/test.c @@ -0,0 +1,91 @@ +#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}; + n = TableArticle(Tref,Tpoid,Tvolume,Tprix); + + printf("Responsable / Client ? (R[0]/C[1])"); + scanf("%d",&rep); + if (rep == 0) + { + printf("Bienvenue Mr. le responsable :)\n"); + printf("Que voulez vous faire ? (afficher[0]/ajouter[1]/modifier[2]/supprimer[3]/quitter[-1]) "); + scanf("%d",&rep); + while (rep != -1) + { + while (rep < -1 || rep > 3) + { + printf("Erreur; (afficher[0]/ajouter[1]/modifier[2]/supprimer[3]/quitter[-1]) "); + scanf("%d",&rep); + } + if (rep == 0) + { + AffichTable(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 1) + { + AjoutArticle(); + n = TableArticle(Tref,Tpoid,Tvolume,Tprix); + printf("\n"); + } + if (rep == 2) + { + ModifArticle(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + if (rep == 3) + { + n = SupprArticle(Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + printf("Que faire ? (afficher[0]/ajouter[1]/modifier[2]/supprimer[3]/quitter[-1]) "); + scanf("%d",&rep); + if (rep == -1) + { + EcrireFichier(Tref,Tpoid,Tvolume,Tprix,n); + printf("Au revoir !\n"); + } + + } + } + else + { + printf("Bienvenue Mr. le client :)\n"); + printf("Que voulez vous faire ? (Ajout[0]/quitter[-1]) "); + scanf("%d",&rep); + int TrefC[200]={0},TquanC[200]={0},nArticle=0; + while (rep != -1) + { + while (rep < -1 || rep > 0) + { + printf("Erreur; (Ajout[0]/quitter[-1]) "); + scanf("%d",&rep); + } + if (rep == 0) + { + nArticle = ajoutPanier(TrefC,TquanC,nArticle,Tref,n); + affichPanier(TrefC,TquanC,nArticle,Tref,Tpoid,Tvolume,Tprix,n); + printf("\n"); + } + + printf("Que faire ? (Ajout[0]/quitter[-1]) "); + scanf("%d",&rep); + if (rep == -1) + { + printf("Au revoir !\n"); + } + + } + } +} +int main(void) +{ + testF(); + return 0; +} + diff --git a/FICHIERANGE/testange.c b/FICHIERANGE/testange.c deleted file mode 100644 index 2e287c1..0000000 --- a/FICHIERANGE/testange.c +++ /dev/null @@ -1,56 +0,0 @@ -#include "ange.h" - -void testF(void) -{ - int n=0,rep; - int Tref[100]={0}; - float Tpoid[100]={0},Tvolume[100]={0},Tprix[100]={0}; - - printf("Bienvenue Mr. le directeur :)\n"); - n = TableArticle(Tref,Tpoid,Tvolume,Tprix); - - printf("Que voulez vous faire ? (afficher[0]/ajouter[1]/modifier[2]/supprimer[3]/quitter[-1]) "); - scanf("%d",&rep); - while (rep != -1) - { - while (rep < -1 || rep > 3) - { - printf("Erreur; (afficher[0]/ajouter[1]/modifier[2]/supprimer[3]/quitter[-1]) "); - scanf("%d",&rep); - } - if (rep == 0) - { - AffichTable(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 1) - { - AjoutArticle(); - n = TableArticle(Tref,Tpoid,Tvolume,Tprix); - printf("\n"); - } - if (rep == 2) - { - ModifArticle(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - if (rep == 3) - { - n = SupprArticle(Tref,Tpoid,Tvolume,Tprix,n); - printf("\n"); - } - printf("Que faire ? (afficher[0]/ajouter[1]/modifier[2]/supprimer[3]/quitter[-1]) "); - scanf("%d",&rep); - if (rep == -1) - { - EcrireFichier(Tref,Tpoid,Tvolume,Tprix,n); - printf("Au revoir !\n"); - } - - } -} -int main(void) -{ - testF(); - return 0; -}