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.

243 lines
4.9 KiB

#include <stdio.h>
#include "evsae.h"
#include <stdlib.h>
void menu (void)
{
char choix, retourmenu;
int VSUIVANTE, next;
FILE *fx;
fx=fopen("x.don","r");
if (fx==NULL)
{printf("erreur");
return;}
VSUIVANTE=0;
while(!feof(fx))
{
fscanf(fx, "%d", &next);
if ( next> VSUIVANTE)
{
VSUIVANTE=next;
}
}
printf("\nQue souhaitez vous faire?\n");
printf("\n1- Créer un compte\n");
printf("2- Presenter sa carte\n");
printf("Controle C pour quitter");
printf("\nTapez h pour une aide\n");
scanf("%*c%c%*c", &choix);
while ( choix != 'h' && choix != '1' && choix != '2')
{
printf("\nEntrez soit h, soit 1, soit 2.\t");
scanf("%c", &choix);
}
if (choix == 'h')
{
printf("\n\tBienvenue dans notre application!\n");
printf("\nVous êtes arrivées dans le menu de notre incroyable salle de sport\n");
printf("Tapez le nombre au début de la liste des fonctionnalitées pour y accéder");
printf("\nSi vous êtes nouveau, nous vous conseillons de créer un compte en tapant 1 dan le menu");
printf("\nTapez O pour retourner au menu principal\n");
scanf("%c",&retourmenu);
while ( retourmenu != 'O')
{
printf("\nTapez la lettre O pour revenir au menu.\t");
scanf("%*c%c%*c", &retourmenu);
}
if (retourmenu == 'O')
menu();
}
if (choix == '1')
{
creationCompte( &VSUIVANTE);
}
if (choix == '2')
{
printf("gogogogo");
//Compte()
}
}
void creationCompte(int *VSUIVANTE)
{
char nom[15], prenom[20], categorie, gen, retour;
int age, nclient;
FILE *fe, *fx, *fn;
fe= fopen("donneClient.don", "a");
fx= fopen("x.don","a");
if (fe==NULL)
{
printf(" Erreur ouverture fichier");
}
printf("\nEntrez votre nom\n");
scanf("%s%*c", nom);
printf("\nEntrez votre prenom\n");
scanf("%s%*c", prenom);
printf("\nEntrez votre age\n");
scanf("%d%*c", &age);
printf("Avez-vous un tarif spécial: Etudiant(E), Senior(S), aucun(A)?\n");
scanf("%c%*c", &categorie);
fprintf(fe,"\n%d\t",*VSUIVANTE);
fprintf(fe,"%s\t",nom);
fprintf(fe,"%s\t",prenom);
fprintf(fe,"%d\t",age);
fprintf(fe, "0\t"); //état de la carte
fprintf(fe, "0\t"); //activité
fprintf(fe, "0\t"); //passé ou pas
fprintf(fe, "30\t"); //point acheté
fprintf(fe, "0\t"); //point cumulé
fprintf(fe,"%c",categorie);
*VSUIVANTE=*VSUIVANTE+1;
fprintf(fx,"\n%d",*VSUIVANTE);
printf("Ajoutez un contact?(O/N)\n");
scanf("%c%*c", &retour);
if (retour == 'O')
creationCompte(VSUIVANTE);
else
return;
}
void fRecherche(int *tAd, int n, int noClient, int *coderet, int *rang)
{
int i;
for(i = 0; i < n; i++)
{
if(tAd[i] == noClient)
{
*coderet = 1;
*rang = i;
return;
}
if(tAd[i] > noClient)
*rang = i;
return;
}
}
void changementEtatCarte ( int *tAd , int *tstate, int n, nclient)
{
int nchoix, coderet, pos
printf("\nNouvel état de la carte:");
printf("\nDésactiver(0)")
printf("\nActiver(1)")
scanf("%c%*c",&nchoix
if (nchoix == 0)
{
fRecherche(tAd, n, nclient, &coderet, &rang);
tAD[6]= 0
}
if (nchoix == 1)
{
fRecherche(tAd, n, nclient, &coderet, &rang);
tAD[6]= 0
}
int Fillvar(int *tAd, char tnom[][15], char tpnom[][15], int *tage, int *tstate, int *tacti, int *tpasseoupas, int *tptsbought, int *tptsbonus, char *tcateg, int tmax)//lis le fichier et met les valeurs dans les tableaux
{
FILE *f;
f = fopen("donneeClient.don", "r");
if (f == NULL)
{
printf("Problème d'ouverture du fichier Clients...");
return -1;
}
int i = 0;
int numAd, age, state, acti, passeoupas, ptsbought, ptsbonus;
char categ, fnom[15], fprenom[15];
fscanf(f, "%6d", &numAd);
fscanf(f, "%s", fnom);
fscanf(f, "%s", fprenom);
fscanf(f, "%2d", &age);
fscanf(f, "%d", &state);
fscanf(f, "%d", &acti);
fscanf(f, "%d", &passeoupas);
fscanf(f, "%2d", &ptsbought);
fscanf(f, "%2d%*c", &ptsbonus);
fscanf(f, "%c", &categ);
while (!feof(f))
{
if (i == tmax)
{
printf("Problème de gestion: trop de clients enregistrés à ce jour");
return -1;
}
tAd[i] = numAd;
strcpy(tnom[i], fnom);
strcpy(tpnom[i], fprenom);
tage[i] = age;
tstate[i] = state;
tacti[i] = acti;
tpasseoupas[i] = passeoupas;
tptsbought[i] = ptsbought;
tptsbonus[i] = ptsbonus;
tcateg[i] = categ;
i++;
fscanf(f, "%6d", &numAd);
fscanf(f, "%s", fnom);
fscanf(f, "%s", fprenom);
fscanf(f, "%2d", &age);
fscanf(f, "%d", &state);
fscanf(f, "%d", &acti);
fscanf(f, "%d", &passeoupas);
fscanf(f, "%2d", &ptsbought);
fscanf(f, "%2d%*c", &ptsbonus);
fscanf(f, "%c", &categ);
}
fclose(f);
return 0;
}