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