Menu GestionCompteAdherent fini (manque le travail de Jean)

main
DahmaneYanis 3 years ago
parent b75c881151
commit d074b7609b

@ -0,0 +1,5 @@
{
"files.associations": {
"stdlib.h": "c"
}
}

@ -2,10 +2,19 @@
#include <stdlib.h> #include <stdlib.h>
#ifdef __linux__ #ifdef __linux__
#define clean system("clear"); #define clean system("clear");
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
#define clean system("cls"); #define clean system("cls");
#define color system("color 70"); #define color system("color 70");
#endif
#ifndef wait
#define wait printf("\nAppuyez sur entree pour continuer...");\
scanf("%*c%c", &trash);
#endif
#ifndef _rep_
#define _rep_ scanf(" %c", &rep);
#endif #endif

@ -3,8 +3,8 @@
void GestionAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int *nbAdherents, int taillePhysique); void GestionAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int *nbAdherents, int taillePhysique);
int AffichageGestionAdherent(void); int AffichageGestionAdherent(void);
int AffichageGestionCompteAdherent(void); int AffichageGestionCompteAdherent(int cible);
void GestionCompteAdherent(); void GestionCompteAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int nbAdherents);
int CibleInfosAdherent(void); int CibleAdherent(int tabNoCarte[], int nbAdherents);
void AfficheBandeauGCA(void);

@ -61,14 +61,14 @@ void SupprimerAdherent(int *nbAdherents, int tabNoCarte[], int tabEtatCarte[], i
if (trouve == 0) if (trouve == 0)
{ {
printf("\nNumero de carte %d inexistant. Souhaitez vous un affichage detaille des adherents (O/N) : ", cible); printf("\nNumero de carte %d inexistant. Souhaitez vous un affichage detaille des adherents (O/N) : ", cible);
scanf(" %c", &rep); _rep_
// Verification de la validité de la réponse // Verification de la validité de la réponse
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous un affichage detaille des adherents (O/N) : "); printf("Reponse incorrecte. Souhaitez vous un affichage detaille des adherents (O/N) : ");
scanf(" %c", &rep); _rep_
} }
if (rep == 'O') if (rep == 'O')
@ -85,14 +85,14 @@ void SupprimerAdherent(int *nbAdherents, int tabNoCarte[], int tabEtatCarte[], i
AfficheInfosAdherent(cible, tabNoCarte, tabEtatCarte, tabPointCarte, *nbAdherents); AfficheInfosAdherent(cible, tabNoCarte, tabEtatCarte, tabPointCarte, *nbAdherents);
printf("\nConfirmez vous la suppression de l'adherent (O/N) : "); printf("\nConfirmez vous la suppression de l'adherent (O/N) : ");
scanf(" %c", &rep); _rep_
// Verification de la validité de la réponse // Verification de la validité de la réponse
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Confirmez vous la suppression de l'adherent %d (O/N) : ", tabNoCarte[indice]); printf("Reponse incorrecte. Confirmez vous la suppression de l'adherent %d (O/N) : ", tabNoCarte[indice]);
scanf(" %c", &rep); _rep_
} }
// Suppression de l'adherent // Suppression de l'adherent
if (rep == 'O') if (rep == 'O')
@ -120,14 +120,14 @@ void SupprimerAdherent(int *nbAdherents, int tabNoCarte[], int tabEtatCarte[], i
// Test pour savoir si on supprime encore un adhérent ou si on retourne au menu principal // Test pour savoir si on supprime encore un adhérent ou si on retourne au menu principal
printf("\nSouhaitez vous entrer un autre numero d'adherent (O/N) : "); printf("\nSouhaitez vous entrer un autre numero d'adherent (O/N) : ");
scanf(" %c", &rep); _rep_
clean clean
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : "); printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : ");
scanf(" %c", &rep); _rep_
} }
if(rep == 'N') if(rep == 'N')
@ -191,8 +191,7 @@ void AfficheAdherents(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[],
if (noPage+commande > nbPages || noPage+commande < 1) if (noPage+commande > nbPages || noPage+commande < 1)
{ {
help(1); help(1);
printf("\nAppuyer sur entree pour continuer..."); wait
scanf("%*c%c", &trash);
} }
else else
{ {
@ -313,13 +312,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
if (!trouve && indice == -1) if (!trouve && indice == -1)
{ {
printf("Carte adherente introuvable. Souhaitez-vous rechercher un autre adherent (O/N) : ", noCarte); printf("Carte adherente introuvable. Souhaitez-vous rechercher un autre adherent (O/N) : ", noCarte);
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : "); printf("Reponse incorrecte. Souhaitez vous entrer un autre numero d'adherent (O/N) : ");
scanf(" %c", &rep); _rep_
} }
// Abandon de la recharge // Abandon de la recharge
@ -347,13 +346,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
AfficheInfosAdherent(noCarte, tabNoCarte, tabEtatCarte, tabPointCarte, nbAdherents); AfficheInfosAdherent(noCarte, tabNoCarte, tabEtatCarte, tabPointCarte, nbAdherents);
printf("\nVoulez-vous toujours recharger la carte numero %d (O/N) : ", noCarte); printf("\nVoulez-vous toujours recharger la carte numero %d (O/N) : ", noCarte);
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Voulez-vous toujours recharger la carte numero %d (O/N) : ", noCarte); printf("Reponse incorrecte. Voulez-vous toujours recharger la carte numero %d (O/N) : ", noCarte);
scanf(" %c", &rep); _rep_
} }
// Annulation de la recharge // Annulation de la recharge
@ -361,13 +360,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
{ {
clean clean
printf("Transaction annulee.\nSouhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Transaction annulee.\nSouhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
} }
// Fin de programme // Fin de programme
@ -403,13 +402,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
printf("\nTransaction de %d credits faite.\n", credit); printf("\nTransaction de %d credits faite.\n", credit);
printf("Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
} }
// Nouveau rechargement de carte // Nouveau rechargement de carte
@ -433,13 +432,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
clean clean
printf("Etat de la carte actuel : %d", tabEtatCarte[indice]); printf("Etat de la carte actuel : %d", tabEtatCarte[indice]);
printf("\nVoulez-vous la reactiver (O/N) : "); printf("\nVoulez-vous la reactiver (O/N) : ");
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte.\nEtat de la carte actuel : %d. Voulez-vous reactiver la carte numero %d (O/N) : ", tabEtatCarte[indice], noCarte); printf("Reponse incorrecte.\nEtat de la carte actuel : %d. Voulez-vous reactiver la carte numero %d (O/N) : ", tabEtatCarte[indice], noCarte);
scanf(" %c", &rep); _rep_
} }
// Réactivation de la carte et ajout des crédits // Réactivation de la carte et ajout des crédits
@ -452,13 +451,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
printf("\nTransaction de %d credits faite.\n", credit); printf("\nTransaction de %d credits faite.\n", credit);
printf("Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
} }
// Nouveau rechargement de carte // Nouveau rechargement de carte
@ -481,13 +480,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
{ {
clean clean
printf("Souhaitez-vous effectuer quand meme la transaction de %d credit (O/N) : ", credit); printf("Souhaitez-vous effectuer quand meme la transaction de %d credit (O/N) : ", credit);
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez-vous effectuer quand meme la transaction de %d credit (O/N) : ", credit); printf("Reponse incorrecte. Souhaitez-vous effectuer quand meme la transaction de %d credit (O/N) : ", credit);
scanf(" %c", &rep); _rep_
} }
// Mettre des crédits sans réactiver la carte // Mettre des crédits sans réactiver la carte
@ -498,13 +497,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
printf("\nTransaction de %d credits faite.\n", credit); printf("\nTransaction de %d credits faite.\n", credit);
printf("Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
} }
// Nouveau rechargement de carte // Nouveau rechargement de carte
@ -527,13 +526,13 @@ void RechargeCarte(int noCarte, int tabNoCarte[], int tabEtatCarte[], int tabPoi
{ {
clean clean
printf("Transaction annulee.\nSouhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Transaction annulee.\nSouhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : "); printf("Reponse incorrecte. Souhaitez-vous faire une nouvelle transaction de credit (O/N) : ");
scanf(" %c", &rep); _rep_
} }
// Fin de programme // Fin de programme
@ -614,14 +613,14 @@ void CreerAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], in
clean clean
printf("Adherent cree. Souhaitez vous un affichage detaille des adherents (O/N) : "); printf("Adherent cree. Souhaitez vous un affichage detaille des adherents (O/N) : ");
scanf(" %c", &rep); _rep_
// Verification de la validité de la réponse // Verification de la validité de la réponse
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous un affichage detaille des adherents (O/N) : "); printf("Reponse incorrecte. Souhaitez vous un affichage detaille des adherents (O/N) : ");
scanf(" %c", &rep); _rep_
} }
if (rep == 'O') if (rep == 'O')
@ -631,14 +630,14 @@ void CreerAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], in
clean clean
printf("Souhaitez vous creer un autre adherent (O/N) : "); printf("Souhaitez vous creer un autre adherent (O/N) : ");
scanf(" %c", &rep); _rep_
// Verification de la validité de la réponse // Verification de la validité de la réponse
while (rep != 'N' && rep != 'O') while (rep != 'N' && rep != 'O')
{ {
clean clean
printf("Reponse incorrecte. Souhaitez vous creer un autre adherent (O/N) : "); printf("Reponse incorrecte. Souhaitez vous creer un autre adherent (O/N) : ");
scanf(" %c", &rep); _rep_
} }
if (rep == 'N') if (rep == 'N')

@ -22,5 +22,7 @@ int main(void){
//int indice = TrouverAdherent(tabCarte, tailleLog, 5, &trouve); //int indice = TrouverAdherent(tabCarte, tailleLog, 5, &trouve);
//printf("Indice: %d\nTrouve = %d", indice, trouve); //printf("Indice: %d\nTrouve = %d", indice, trouve);
//CreerAdherent(tabCarte, tabEtat, tabPoint, &tailleLog, taillePhysique); //CreerAdherent(tabCarte, tabEtat, tabPoint, &tailleLog, taillePhysique);
GestionAdherent(tabCarte, tabEtat, tabPoint, &tailleLog, taillePhysique); //GestionAdherent(tabCarte, tabEtat, tabPoint, &tailleLog, taillePhysique);
GestionCompteAdherent(tabCarte, tabEtat, tabPoint, tailleLog);
} }

@ -54,35 +54,29 @@ void GestionAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[],
default : default :
clean clean
printf("\nChoix invalide.\n"); printf("\nChoix invalide.\n");
printf("Appuyez sur entree pour continuer..."); wait
scanf("%c", &trash);
} }
} }
} }
#include "../header/menus.h"
#include "../header/adherent.h"
/** /**
* @brief Permet l'affichage de GestionCompteAdherent * @brief Permet l'affichage de GestionCompteAdherent
* *
* @return int Choix de l'utilisateur * @return int Choix de l'utilisateur
*/ */
int AffichageGestionCompteAdherent(void) int AffichageGestionCompteAdherent(int cible)
{ {
int choix; int choix;
clean AfficheBandeauGCA();
printf("===============================================================\n"); printf("[ADHERENT %d]\n", cible);
printf("\t\tMENU GESTION D'UN COMPTE ADHERENT\n");
printf("===============================================================\n");
printf("\nChoix disponible :\n"); printf("\nChoix disponible :\n");
printf("\t0. Retour au menu principal\n"); printf("\t0. Retour au menu principal\n");
printf("\t1. Afficher les infos d'un adherent\n"); printf("\t1. Afficher les infos d'un adherent\n");
printf("\t2. Recharger une carte\n"); printf("\t2. Recharger une carte\n");
printf("\t3. Desactiver/activer une carte\n"); printf("\t3. Desactiver/activer une carte\n");
printf("\t4. Changer d'adherent\n");
printf("\nChoix : "); printf("\nChoix : ");
scanf("%d", &choix); scanf("%d", &choix);
@ -95,44 +89,74 @@ int AffichageGestionCompteAdherent(void)
* @param tabNoCarte [TABLEAU] Liste des adherents * @param tabNoCarte [TABLEAU] Liste des adherents
* @param tabEtatCarte [TABLEAU] Etats des cartes * @param tabEtatCarte [TABLEAU] Etats des cartes
* @param tabPointCarte [TABLEAU] Crédit des cartes * @param tabPointCarte [TABLEAU] Crédit des cartes
* @param nbAdherents [POINTEUR - Taille Logique] Nombre d'adhérents * @param nbAdherents [Taille Logique] Nombre d'adhérents
* @param taillePhysique [Taille Physique]
*/ */
void GestionCompteAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int *nbAdherents, int taillePhysique) void GestionCompteAdherent(int tabNoCarte[], int tabEtatCarte[], int tabPointCarte[], int nbAdherents)
{ {
int actif = 1; int actif = 1;
int choix, cible; int choix, cible;
char trash; char trash;
cible = CibleAdherent(tabNoCarte, nbAdherents); // Numéro de la carte de l'adhérent que l'on va traiter
while(actif) while(actif)
{ {
choix = AffichageGestionAdherent(); choix = AffichageGestionCompteAdherent(cible);
switch(choix) switch(choix)
{ {
case 0 : actif = 0; break; case 0 : actif = 0; break;
case 1 : cible = CibleInfosAdherent(); AfficheInfosAdherent(cible, tabNoCarte, tabEtatCarte, tabPointCarte, *nbAdherents);break; case 1 : AfficheInfosAdherent(cible, tabNoCarte, tabEtatCarte, tabPointCarte, nbAdherents); wait break;
case 2 : CreerAdherent(tabNoCarte, tabEtatCarte, tabPointCarte, nbAdherents, taillePhysique);break; case 2 : RechargeCarte(cible, tabNoCarte, tabEtatCarte, tabPointCarte, nbAdherents); break;
case 3 : SupprimerAdherent(nbAdherents, tabNoCarte, tabEtatCarte, tabPointCarte);break; case 3 : actif = 0/*code temporaire à remplacer par Appel de la fontion Activation/Desactivation de la carte*/; break;
case 4 : cible = CibleAdherent(tabNoCarte, nbAdherents); break;
default : default :
clean clean
AfficheBandeauGCA();
printf("\nChoix invalide.\n"); printf("\nChoix invalide.\n");
printf("Appuyez sur entree pour continuer..."); wait
scanf("%c", &trash);
} }
} }
} }
/** /**
* @brief Récupère le numéro de carte de l'adhérent pour lequel on souhaite obtenir les informations * @brief Récupère le numéro de carte de l'adhérent à traiter
* *
* @return int Numéro de carte de l'adhérent cible * @return int Numéro de carte de l'adhérent cible
*/ */
int CibleInfosAdherent(void) int CibleAdherent(int tabNoCarte[], int nbAdherents)
{ {
int cible; int cible;
int trouve = 0;
int indice = 0;
clean clean
printf("Numero de carte de l'adherent : "); while(!trouve)
scanf("%d", &cible); {
AfficheBandeauGCA();
if(indice == -1)
{
printf("\nNumero de l'adherent inexistant.");
}
printf("\nNumero de carte de l'adherent a traiter : ");
scanf("%d", &cible);
indice = TrouverAdherent(tabNoCarte, nbAdherents, cible, &trouve);
clean
}
return cible; return cible;
}
/**
* @brief Affichage du bandeau du menu GestionCompteAdherent
*
*/
void AfficheBandeauGCA(void)
{
clean
printf("===============================================================\n");
printf("\t\tMENU GESTION D'UN COMPTE ADHERENT\n");
printf("===============================================================\n");
} }
Loading…
Cancel
Save