You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.8 KiB
111 lines
3.8 KiB
/**
|
|
* @file menu.c
|
|
* @brief Menu client et administrateur
|
|
*/
|
|
|
|
#include "main.h"
|
|
|
|
void clientMenu(float *weight, float *volume, float *price, int tabItemRef[], float unitPrice[], float *cagnotte, int basket_tab_ref[], int basket_tab_qte[], float tabWeight[], float tabVolume[], int tlogItem, int *tlogBasket)
|
|
{
|
|
int choice = 0, constraint;
|
|
while (choice != 6)
|
|
{
|
|
printf("\n=================================\n");
|
|
printf(" Menu Client\n");
|
|
printf("=================================\n");
|
|
printf("1\u2022 Entrer ses contraintes\n");
|
|
printf("2\u2022 Ajouter un article au panier\n");
|
|
printf("3\u2022 Afficher le panier\n");
|
|
printf("4\u2022 Réinitialiser le panier\n");
|
|
printf("5\u2022 Retirer un article du panier\n");
|
|
printf("6\u2022 Quitter\n");
|
|
printf("=================================\n");
|
|
printf("Votre choix: ");
|
|
scanf("%d", &choice);
|
|
switch (choice)
|
|
{
|
|
case 1:
|
|
clientConstraint(weight, volume, price);
|
|
break;
|
|
case 2:
|
|
basket_add(tabItemRef, unitPrice, cagnotte, basket_tab_ref, basket_tab_qte, tlogItem, tlogBasket);
|
|
constraint = constraintExceeded(*weight, *volume, price, cagnotte, tabWeight, tabVolume, unitPrice, tabItemRef, basket_tab_ref, basket_tab_qte, tlogItem, *tlogBasket);
|
|
if (constraint == -1)
|
|
basket_del_article(basket_tab_ref, basket_tab_qte, tlogBasket);
|
|
break;
|
|
case 3:
|
|
display_basket(basket_tab_ref, tabItemRef, basket_tab_qte, tabWeight, tabVolume, *cagnotte, unitPrice, tlogItem, *tlogBasket);
|
|
break;
|
|
case 4:
|
|
reinit_basket(tlogBasket);
|
|
break;
|
|
case 5:
|
|
basket_del_article(basket_tab_ref, basket_tab_qte, tlogBasket);
|
|
break;
|
|
case 6:
|
|
return;
|
|
default:
|
|
printf("Erreur, veuillez entrer un choix valide.\n");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void adminMenu(int clientID[], int clientPassword[], float cagnotte[], int suspended[], int isAdmin[], int tabReference[], float tabWeight[], float tabVolume[], float unitPrice[], int *tlogItem, int *tlogClient)
|
|
{
|
|
int choice = 0;
|
|
while (choice != 10)
|
|
{
|
|
printf("\n=================================\n");
|
|
printf(" Menu Client\n");
|
|
printf("=================================\n");
|
|
printf("1\u2022 Ajouter un client\n");
|
|
printf("2\u2022 Modifier les données d'un client\n");
|
|
printf("3\u2022 Supprimer un client\n");
|
|
printf("4\u2022 Ajouter un article\n");
|
|
printf("5\u2022 Supprimer un article\n");
|
|
printf("6\u2022 Afficher les données d'un article\n");
|
|
printf("7\u2022 Afficher la liste des articles\n");
|
|
printf("8\u2022 Afficher les données d'un client\n");
|
|
printf("9\u2022 Afficher la liste des clients\n");
|
|
printf("10\u2022 Quitter\n");
|
|
printf("=================================\n");
|
|
printf("Votre choix: ");
|
|
scanf("%d", &choice);
|
|
switch (choice)
|
|
{
|
|
case 1:
|
|
signup(clientID, clientPassword, cagnotte, suspended, isAdmin, tlogClient);
|
|
break;
|
|
case 2:
|
|
modifyClient(clientID, cagnotte, suspended, isAdmin, *tlogClient);
|
|
break;
|
|
case 3:
|
|
deleteClient(clientID, cagnotte, suspended, isAdmin, tlogClient);
|
|
break;
|
|
case 4:
|
|
inputItem(tabReference, tabWeight, tabVolume, unitPrice, tlogItem);
|
|
break;
|
|
case 5:
|
|
deleteItem(tabReference, tabWeight, tabVolume, unitPrice, tlogItem);
|
|
break;
|
|
case 6:
|
|
displayItem(tabReference, tabWeight, tabVolume, unitPrice, *tlogItem);
|
|
break;
|
|
case 7:
|
|
displayItemList(tabReference, tabWeight, tabVolume, unitPrice, *tlogItem);
|
|
break;
|
|
case 8:
|
|
displayClient(clientID, cagnotte, suspended, isAdmin, *tlogClient);
|
|
break;
|
|
case 9:
|
|
displayClientList(clientID, cagnotte, suspended, isAdmin, *tlogClient);
|
|
break;
|
|
case 10:
|
|
return;
|
|
default:
|
|
printf("Erreur, veuillez entrer un choix valide.\n");
|
|
break;
|
|
}
|
|
}
|
|
} |