Mise à jour de 'src/app/interface/interface_resp.c'

pull/8/head
parent 47e3fcfb76
commit e647914e2e

@ -20,9 +20,11 @@ void affiche_resp(void){
printf("||\t2 : Afficher un article \t \t \t \t || \n"); printf("||\t2 : Afficher un article \t \t \t \t || \n");
printf("||\t3 : Afficher un client \t \t \t \t \t || \n"); printf("||\t3 : Afficher un client \t \t \t \t \t || \n");
printf("||\t4 : Afficher les clients \t \t \t \t || \n"); printf("||\t4 : Afficher les clients \t \t \t \t || \n");
printf("||\t5 : Supprimer un article \t \t \t \t || \n"); printf("||\t5 : Ajouter un article \t \t \t \t \t || \n");
printf("||\t6 : Modifier un article \t \t \t \t || \n"); printf("||\t6 : Supprimer un article \t \t \t \t || \n");
printf("||\t7 : Réinitialiser le panier. \t \t \t \t || \n"); printf("||\t7 : Modifier un article \t \t \t \t || \n");
printf("||\t8 : Ajouter un client\t \t \t \t \t || \n");
printf("||\t9 : Quittez. \t \t \t \t \t \t || \n");
printf("+-----------------------------------------------------------------+\n"); printf("+-----------------------------------------------------------------+\n");
} }
/* /*
@ -47,9 +49,10 @@ void affiche_resp(int a){
void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique) void affichArticles( int tRef[], float tPoids[], float tVol[], float tPrix[], int tLogique)
{ {
printf("\t Liste des articles \n\n"); printf("\t Liste des articles \n\n");
printf("\t Ref\t Poids\t Volume\t Prix\n");
for ( int i = 0; i < tLogique; ++i) for ( int i = 0; i < tLogique; ++i)
{ {
printf("\t %d %.2f %.2f %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); printf("\t %d\t %.2f\t %.2f\t %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]);
} }
} }
@ -57,16 +60,17 @@ void affichUnArticle(int tRef[], float tPoids[], float tVol[], float tPrix[], in
{ {
int ref; int ref;
printf("\tQuelle est la référence de l'article à rechercher ?\n"); printf("\tQuelle est la référence de l'article à rechercher ?\n");
while(scanf("%d", &ref != 1 || ref <= 0)) while(scanf("%d", &ref) != 1 || ref <= 0)
{ {
printf("\tEntrez une référence valide\n"); printf("\tEntrez une référence valide\n");
while(getchar() != '\n'); while(getchar() != '\n');
} }
printf("\t Ref\t Poids\t Volume\t Prix\n");
for ( int i = 0; i < tLogique; ++i) for ( int i = 0; i < tLogique; ++i)
{ {
if ( ref == tRef[i] ) if ( ref == tRef[i] )
{ {
printf("\t %d %.2f %.2f %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]); printf("\t %d\t %.2f\t %.2f\t %.2f\n\n", tRef[i], tPoids[i], tVol[i], tPrix[i]);
return; return;
} }
} }
@ -82,11 +86,12 @@ void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogiqu
printf("\t Veuillez entrez un numéro valide !\n"); printf("\t Veuillez entrez un numéro valide !\n");
while(getchar() != '\n'); while(getchar() != '\n');
} }
printf("\t NumClient\t Cagnotte\t Etat\n");
for ( int i = 0; i < tLogique; ++i) for ( int i = 0; i < tLogique; ++i)
{ {
if ( numC == tNumClient[i] ) if ( numC == tNumClient[i] )
{ {
printf("\t %d %.2f %d\n\n", tNumClient[i], tCagnotte[i], tSus[i]); printf("\t %d\t\t %.2f\t %d\n\n", tNumClient[i], tCagnotte[i], tSus[i]);
return; return;
} }
} }
@ -96,65 +101,52 @@ void affichUnClient(int tNumClient[], float tCagnotte[], int tSus[], int tLogiqu
void affichClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique) void affichClients(int tNumClient[], float tCagnotte[], int tSus[], int tLogique)
{ {
printf("\t Liste des clients\n"); printf("\t Liste des clients\n");
printf("\t NumClient\t Cagnotte\t Etat\n");
for ( int i = 0; i < tLogique; ++i) for ( int i = 0; i < tLogique; ++i)
{ {
printf("\t %d %.2f %d\n\n", tNumClient[i], tCagnotte[i], tSus[i]); printf("\t %d\t\t %.2f\t\t %d\n\n", tNumClient[i], tCagnotte[i], tSus[i]);
} }
printf("\t Fin de la liste ! \n"); printf("\t Fin de la liste ! \n");
} }
void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix) void affichAjoutArticle(int *ref, float *poids, float *volume, float *prix)
{ {
printf("Entrez la ref du nouveaux produit\n"); printf("\t Entrez la ref du nouveaux produit\n");
scanf("%d", ref); while(scanf("%d", ref) != 1 || *ref <= 0)
if ( *ref < 0 )
{ {
while ( *ref < 0 ) printf("\t Veuillez entrer une référence valide.\n");
{ while(getchar() != '\n');
printf("Entrez un nombre correct !\n");
scanf("%d", ref);
}
} }
printf("Entrez le poids du nouveaux produit\n");
scanf("%f", poids); printf("\t Entrez le poids du nouveaux produit\n");
if ( *poids < 0 ) while(scanf("%f", poids) != 1 || *poids <= 0)
{ {
while ( *poids < 0 ) printf("\t Veuillez entrer un poids valide.\n");
{
printf("Entrez un nombre correct !\n"); while(getchar() != '\n');
scanf("%f", poids);
}
} }
printf("Entrez le volume du nouveaux produit\n");
scanf("%f", volume); printf("\t Entrez le volume du nouveaux produit\n");
if ( *volume < 0 ) while(scanf("%f", volume) != 1 || *volume <= 0)
{ {
while ( *volume < 0 ) printf("\t Veuillez entrer un volume valide.\n");
{ while(getchar() != '\n');
printf("Entrez un poids correct !\n");
scanf("%f", poids);
}
} }
printf("Entrez le prix du nouveaux produit\n");
scanf("%f", prix); printf("\t Entrez le prix du nouveaux produit\n");
if ( *prix < 0 ) while(scanf("%f", prix) != 1 || *prix <= 0)
{ {
while ( *prix < 0 ) printf("\t Veuillez entrer un prix valide.\n");
{ while(getchar() != '\n');
printf("Entrez un prix correct !\n");
scanf("%f", prix);
}
} }
} }
void affichSupprimerArticle(int *ref) void affichSupprimerArticle(int *ref)
{ {
printf("\t Quel est la référence de l'article voulez-vous supprimez\n"); printf("\t Quel est la référence de l'article voulez-vous supprimez\n");
while(scanf("%d", ref == 1 || *ref <= 0)) while(scanf("%d", ref ) != 1 || *ref <= 0)
{ {
printf("\t Veuillez entrer une référence valide."); printf("\t Veuillez entrer une référence valide.\n");
while(getchar() != '\n'); while(getchar() != '\n');
} }
} }
@ -173,25 +165,43 @@ void affichModifierArticle(int *ref, float *poids, float *volume, float *prix)
printf("\t Quel est le nouveau poids à entrer ?\n"); printf("\t Quel est le nouveau poids à entrer ?\n");
while(scanf("%f", poids) != 1 || *poids <= 0) while(scanf("%f", poids) != 1 || *poids <= 0)
{ {
printf("\t Veuillez entrer un poids correct !"); printf("\t Veuillez entrer un poids correct !\n");
while (getchar() != '\n'); while (getchar() != '\n');
} }
printf("\t Quel est le nouveau volume à entrer ?\n"); printf("\t Quel est le nouveau volume à entrer ?\n");
while(scanf("%f", volume) != 1 || *volume <= 0) while(scanf("%f", volume) != 1 || *volume <= 0)
{ {
printf("\t Veuillez entrer un volume correct !"); printf("\t Veuillez entrer un volume correct !\n");
while (getchar() != '\n'); while (getchar() != '\n');
} }
printf("\t Quel est le nouveau prix à entrer ?\n"); printf("\t Quel est le nouveau prix à entrer ?\n");
while(scanf("%f", prix) != 1 || *prix <= 0) while(scanf("%f", prix) != 1 || *prix <= 0)
{ {
printf("\t Veuillez entrer un prix correct !"); printf("\t Veuillez entrer un prix correct !\n");
while (getchar() != '\n'); while (getchar() != '\n');
} }
} }
void affichAjoutClient(int tNumClient[], int tLogique, int *numC)
{
printf("\t Veuillez entrer le numéro du nouveau client\n");
while(scanf("%d", numC) != 1 || *numC <= 0)
{
printf("Entrez un numéro valide !\n");
while(getchar() != '\n');
}
for ( int i = 0 ; i < tLogique; ++i)
{
if ( *numC == tNumClient[i] )
{
fprintf(stderr,"\t Client déjà existant.\n");
return;
}
}
}
/* /*
void menu_resp(int *choix, int jour) { void menu_resp(int *choix, int jour) {
affiche_resp(); affiche_resp();
@ -209,7 +219,7 @@ void menu_resp(int *choix) {
affiche_resp(); affiche_resp();
//affiche_resp(jour); //affiche_resp(jour);
printf("Vous choisissez: "); printf("Vous choisissez: ");
while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 5) { while (scanf("%d", choix) != 1 || *choix < 0 || *choix > 9) {
while (getchar() != '\n'); while (getchar() != '\n');
affiche_resp(); affiche_resp();
printf("Veuillez entrer un choix valide : "); printf("Veuillez entrer un choix valide : ");
@ -217,7 +227,8 @@ void menu_resp(int *choix) {
} }
void global_resp(){ void global_resp(){
int choix, a; int choix, ref = 0;
float poids = 0, volume = 0 , prix = 0;
int tRef[MAX_ARTICLES]; int tRef[MAX_ARTICLES];
float tPoids[MAX_ARTICLES]; float tPoids[MAX_ARTICLES];
float tVol[MAX_ARTICLES]; float tVol[MAX_ARTICLES];
@ -229,31 +240,43 @@ void global_resp(){
int tLogArticle = chargementArticles(tRef, tPoids, tVol, tPrix, MAX_ARTICLES); int tLogArticle = chargementArticles(tRef, tPoids, tVol, tPrix, MAX_ARTICLES);
int tLogClient = charger_clients(tNumClient, tCagnotte, tSus, MAX_CLIENTS); int tLogClient = charger_clients(tNumClient, tCagnotte, tSus, MAX_CLIENTS);
menu_resp(&choix); do {
switch (choix) {
case 1:
affichArticles(tRef, tPoids, tVol, tPrix, tLogArticle); menu_resp(&choix);
break; switch (choix) {
case 2: case 1:
affichUnArticle(tRef, tPoids, tVol, tPrix, tLogArticle); affichArticles(tRef, tPoids, tVol, tPrix, tLogArticle);
break; break;
case 3: case 2:
affichUnClient(tNumClient, tCagnotte, tSus, tLogClient); affichUnArticle(tRef, tPoids, tVol, tPrix, tLogArticle);
break; break;
case 4: case 3:
affichClients(tNumClient, tCagnotte, tSus, tLogClient); affichUnClient(tNumClient, tCagnotte, tSus, tLogClient);
break; break;
case 5: case 4:
modifierArticle(tRef, tPoids, tVol, tPrix, tLogArticle); affichClients(tNumClient, tCagnotte, tSus, tLogClient);
break; break;
case 6: case 5:
supprimerArticle(tRef, tPoids, tVol, tPrix, &tLogArticle); ajouterArticle(tRef, tPoids, tVol, tPrix, &tLogArticle, MAX_ARTICLES, ref, poids, volume, prix);
break; break;
case 7: case 6:
printf("Ouai tkt ^^'"); supprimerArticle(tRef, tPoids, tVol, tPrix, &tLogArticle);
break; break;
default: case 7:
printf("Veuillez entrer un choix valide ! \n"); modifierArticle(tRef, tPoids, tVol, tPrix, tLogArticle);
break; break;
} case 8:
ajouterClient(tNumClient, tCagnotte, tSus, &tLogClient, MAX_CLIENTS);
break;
case 9:
sauvegardArticles(tRef, tPoids, tVol, tPrix, tLogArticle);
affichArticles(tRef, tPoids, tVol, tPrix, tLogArticle);
return;
default:
printf("Veuillez entrer un choix valide ! \n");
break;
}
} while (choix != 9);
} }
Loading…
Cancel
Save