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.
110 lines
2.7 KiB
110 lines
2.7 KiB
#include <stdio.h>
|
|
#include "fRox.h"
|
|
|
|
|
|
|
|
//Fonction de chargement depuis le dossier client. Return 0 si dossier introuvable ou tableau plein, return i nombre d'éléments chargés
|
|
int fchargement(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, int *tCActiv, int *tActivite, int *tPasseouPas,int *tPtsBought, int *tPtsBonus, char *tCat, int tmax)
|
|
{
|
|
int noC, age, carte, activite, passage, ptsA, ptsB, i=0;
|
|
char prenom, nom, categorie;
|
|
FILE *fe;
|
|
|
|
fe = fopen ("donneeClient.don", "r");
|
|
if (fe == NULL)
|
|
{
|
|
printf("Le fichier est introuvable\n");
|
|
return 0;
|
|
|
|
fscanf(fe,"%d%c%c%d%d%d%d%d%c", &noC, &nom, &prenom, &age, &carte, &activite, &passage, &ptsA, &ptsB, &categorie);
|
|
|
|
while(!feof(fe))
|
|
{
|
|
if (i == tmax)
|
|
{
|
|
printf("Les tableaux sont pleins");
|
|
return 0;
|
|
}
|
|
|
|
tNoClient[i] = noC;
|
|
tNomClient[i] = nom;
|
|
tPreClient[i] = prenom;
|
|
tAge[i] = age;
|
|
tCat[i] = categorie;
|
|
tCActiv[i] = carte;
|
|
tActivite[i] = activite;
|
|
tPasseouPas[i] = passage;
|
|
tPtsBought[i] = ptsA;
|
|
tPtsBonus[i] = ptsB;
|
|
i++;
|
|
fscanf(fe,"%d%c%c%d%d%d%d%d%c", &noC, &nom, &prenom, &age, &carte, &activite, &passage, &ptsA, &ptsB, &categorie);
|
|
}
|
|
}
|
|
fclose(fe);
|
|
return i;
|
|
}
|
|
|
|
|
|
//Fonction recherche, (*coderet = 1 si trouvé, = 0 si pas trouvé.) (*rang = rang a laquel se trouve ou doit se trouver la valeur)
|
|
void fRecherche(int *tNoClient, int n, int noClient, int *coderet, int *rang)
|
|
{
|
|
int i;
|
|
|
|
for(i = 0; i < n; i++)
|
|
{
|
|
if(tNoClient[i] == noClient)
|
|
{
|
|
*coderet = 1;
|
|
*rang = i;
|
|
return;
|
|
}
|
|
if(tNoClient[i] > noClient)
|
|
|
|
*rang = i;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
//Affichage D'UN client avec toutes ses données.
|
|
void fAffichage1Client(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient )
|
|
{
|
|
int i, coderet, rang, trouve, NonTrouve;
|
|
|
|
|
|
fRecherche(tNoClient, n, noClient, &coderet, &rang);
|
|
|
|
trouve = coderet;
|
|
|
|
while (trouve == 0)
|
|
{
|
|
if(coderet == 0)
|
|
{
|
|
printf("Le numero client n'a pas été trouvé \n");
|
|
printf("Veuillez entrer a nouveau le N° Client ou taper -1 pour annuler\n");
|
|
scanf("%d", &NonTrouve);
|
|
}
|
|
if(NonTrouve==-1)
|
|
return;
|
|
else
|
|
fRecherche(tNoClient, n, noClient, &coderet, &rang);
|
|
trouve=coderet;
|
|
}
|
|
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
|
printf("%d\t %c%*c \t %c%*c\t %d\t %c\n", tNoClient[rang], tNomClient[rang], tPreClient[rang], tAge[rang], tStatut[rang]);
|
|
|
|
}
|
|
|
|
|
|
//Affichage plusieurs client avec toutes les données
|
|
int afficheTous(int *tNoClient, char *tNomClient, char *tPreClient, int *tAge, char *tStatut, int n, int noClient )
|
|
{
|
|
int i;
|
|
printf(" N° Client\t Nom\t Prénom\t Age\t Tarif\n");
|
|
for (int i = 0; i < n; ++i)
|
|
{
|
|
printf("%d\t %c%*c\t %c%*c\t %d\t %c%*c\n", tNoClient, tNomClient, tPreClient, tAge, tStatut);
|
|
}
|
|
}
|
|
|