parent
02686a098f
commit
be878f97cb
@ -0,0 +1,256 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "salle.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int global(){
|
||||
int choix=1;
|
||||
char term;
|
||||
printf("\n");
|
||||
printf("\033[1;35m ██████ ██ ███████ ███ ██ ██ ██ ███████ ███ ██ ██ ██ ███████ \033[0m\n");
|
||||
printf("\033[1;35m ██ ██ ██ ██ ████ ██ ██ ██ ██ ████ ██ ██ ██ ██ \033[0m\n");
|
||||
printf("\033[1;35m ██████ ██ █████ ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ █████ \033[0m\n");
|
||||
printf("\033[1;35m ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ \033[0m\n");
|
||||
printf("\033[1;35m ██████ ██ ███████ ██ ████ ████ ███████ ██ ████ ██████ ███████ \033[0m\n");
|
||||
while (choix!=0){
|
||||
printf("\n\n\033[1;32mQue souhaitez-vous faire?\033[0m");
|
||||
printf("\n\n\033[1;36m1- Créer un adhérent\n2- Alimenter une carte\n3- Gérer l'activation d'une carte\n4- Supprimer un ahdérent\n5- Afficher les infos d'un adhérent\n6- Afficher tout les adhérents\n7- Afficher le nombre d'entrée par activité dans la journée\n0- Sortir\033[0m\n\n");
|
||||
if (scanf("%d%c",&choix,&term)!=2 || term!= '\n'){
|
||||
printf("\033[1;31mVeuillez bien tapez l'une des possibilités proposées ci-dessus.\033[0m\n");
|
||||
exit(1);
|
||||
}
|
||||
if (choix>7){
|
||||
printf("\033[1;31mVeuillez bien tapez l'une des possibilités proposées ci-dessus.\033[0m\n");
|
||||
sleep(5);
|
||||
}else if (choix==1){
|
||||
addAd();
|
||||
}else if (choix==2){
|
||||
modifPoint();
|
||||
}else if (choix==3){
|
||||
compteStatut();
|
||||
}else if (choix==4){
|
||||
// supp adhérent
|
||||
}else if (choix==5){
|
||||
// info 1 adhérent
|
||||
}else if (choix==6){
|
||||
afficheAd();
|
||||
}else if (choix==7){
|
||||
// nbentrée
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addAd (){
|
||||
FILE* fic;
|
||||
int rep,tmp,i;
|
||||
fic=fopen("numadherent.don", "r+");
|
||||
if (fic==NULL){
|
||||
printf("\033[1;31mLe fichier n'existe pas !\033[0m\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("\033[1;36mVoulez vous vraiment créer un adhérent ? \n0- Oui \n1- Non\033[0m\n");
|
||||
scanf("%d",&rep);
|
||||
if (rep==0){
|
||||
for (i=0; feof(fic)==0; i++){
|
||||
fscanf(fic, "%d, %d, %d, %d, %d, %d, %d, %d", &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp);
|
||||
}
|
||||
fprintf(fic,"%d, %d, %d, %d, %d, %d, %d, %d\n", i-1, 0, 1, 0, 0, 0, 0, 0);
|
||||
fclose(fic);
|
||||
printf("\033[1;32mVous êtes maintenant adhérent, votre numéro id est : ");
|
||||
printf("%d\n\033[0m", i-1);
|
||||
sleep(5);
|
||||
}
|
||||
if (rep==1){
|
||||
printf("\033[1;31mVous n'avez pas crée d'adhérent\033[0m\n");
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
void modifPoint(){
|
||||
int tab[100][10] = {0};
|
||||
char c;
|
||||
int id, idtemp, nbrpnt, ptstemp, statemp, statut, foot=0, hand=0, volley=0, bad=0, muscu=0, conteur=0;
|
||||
FILE *fichier;
|
||||
fichier=fopen("numadherent.don", "r");
|
||||
printf("Quel id de compte voulez-vous modifier ? \n");
|
||||
scanf("%d", &id);
|
||||
printf("Voulez-vous enlever ou ajouter des points sur un compte ? \n \t 0 - Ajouter.\n \t 1 - Enlever. \n");
|
||||
scanf("%d", &statut);
|
||||
while(feof(fichier)==0){
|
||||
fscanf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d", &tab[conteur][0], &tab[conteur][1], &tab[conteur][2], &tab[conteur][3], &tab[conteur][4], &tab[conteur][5], &tab[conteur][6], &tab[conteur][7]);
|
||||
conteur=conteur+1;
|
||||
}
|
||||
fclose(fichier);
|
||||
fichier=fopen("numadherent.don","r+");
|
||||
while((c=fgetc(fichier))!=EOF){
|
||||
fscanf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d", &idtemp, &ptstemp, &statemp, &foot, &hand, &volley, &bad, &muscu);
|
||||
if(idtemp==id){
|
||||
conteur=0;
|
||||
fclose(fichier);
|
||||
fichier=fopen("numadherent.don","w");
|
||||
while (tab[conteur][0]!=id){
|
||||
conteur=conteur+1;
|
||||
}
|
||||
printf("%d\n",statut);
|
||||
if (statut == 0){
|
||||
printf("Combien de points voulez-vous ajouter :\n");
|
||||
scanf("%d", &nbrpnt);
|
||||
if(tab[conteur][1] > 0 || tab[conteur][1] < 0){
|
||||
tab[conteur][1]+= nbrpnt;
|
||||
}
|
||||
if(tab[conteur][1] == 0){
|
||||
tab[conteur][1]= nbrpnt;
|
||||
}
|
||||
}else if (statut == 1){
|
||||
printf("Combien de points voulez-vous enlever :\n");
|
||||
scanf("%d", &nbrpnt);
|
||||
if(tab[conteur][1] > 0){
|
||||
tab[conteur][1]-= nbrpnt;
|
||||
}
|
||||
}
|
||||
conteur=0;
|
||||
|
||||
while(tab[conteur][0]!=0){
|
||||
fprintf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d\n", tab[conteur][0], tab[conteur][1], tab[conteur][2], tab[conteur][3], tab[conteur][4], tab[conteur][5], tab[conteur][6], tab[conteur][7]);
|
||||
conteur=conteur+1;
|
||||
}
|
||||
fclose(fichier);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void afficheAd (){
|
||||
int id, pts, statut, foot=0, hand=0, volley=0, bad=0, muscu=0;
|
||||
FILE* fichier;
|
||||
|
||||
fichier=fopen("numadherent.don", "r");
|
||||
|
||||
if (fichier==NULL){
|
||||
printf("Le fichier est vide");
|
||||
fclose(fichier);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("id :\t actif :\tnbrpoint :\t\tfoot :\t\thand :\t\tvolley :\tbad :\t\tmuscu :\n");
|
||||
fscanf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d", &id, &statut, &pts, &foot, &hand, &volley, &bad, &muscu);
|
||||
while (feof(fichier)==0){
|
||||
printf("%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\t\t%d\n", id, statut , pts, foot, hand, volley, bad, muscu);
|
||||
fscanf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d", &id, &statut, &pts, &foot, &hand, &volley, &bad, &muscu);
|
||||
}
|
||||
fclose(fichier);
|
||||
|
||||
}
|
||||
|
||||
void compteStatut(){
|
||||
int tab[100][10] = {0};
|
||||
char c;
|
||||
int id, idtemp, ptstemp, statemp, statut, foot=0, hand=0, volley=0, bad=0, muscu=0, conteur=0;
|
||||
FILE *fichier;
|
||||
fichier=fopen("numadherent.don", "r");
|
||||
printf("Quel id de compte voulez-vous modifier ? \n");
|
||||
scanf("%d", &id);
|
||||
printf("Voulez-vous désactiver ou activer un compte ? \n \t 0 - Désactiver un compte.\n \t 1 - Activer un compte. \n");
|
||||
scanf("%d", &statut);
|
||||
while(feof(fichier)==0){
|
||||
fscanf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d", &tab[conteur][0], &tab[conteur][1], &tab[conteur][2], &tab[conteur][3], &tab[conteur][4], &tab[conteur][5], &tab[conteur][6], &tab[conteur][7]);
|
||||
conteur=conteur+1;
|
||||
}
|
||||
fclose(fichier);
|
||||
fichier=fopen("numadherent.don","r+");
|
||||
while((c=fgetc(fichier))!=EOF){
|
||||
fscanf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d", &idtemp, &ptstemp, &statemp, &foot, &hand, &volley, &bad, &muscu);
|
||||
if(idtemp==id){
|
||||
conteur=0;
|
||||
fclose(fichier);
|
||||
fichier=fopen("numadherent.don","w");
|
||||
while (tab[conteur][0]!=id){
|
||||
conteur=conteur+1;
|
||||
}
|
||||
printf("%d\n",statut);
|
||||
if (statut == 0){
|
||||
tab[conteur][2]=0;
|
||||
}else if (statut == 1){
|
||||
tab[conteur][2]=1;
|
||||
}
|
||||
conteur=0;
|
||||
|
||||
while(tab[conteur][0]!=0){
|
||||
fprintf(fichier,"%d, %d, %d, %d, %d, %d, %d, %d\n", tab[conteur][0], tab[conteur][1], tab[conteur][2], tab[conteur][3], tab[conteur][4], tab[conteur][5], tab[conteur][6], tab[conteur][7]);
|
||||
conteur=conteur+1;
|
||||
}
|
||||
fclose(fichier);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void afficheAdSport() {
|
||||
int rep, rep2, id, pts, statut, foot, hand, volley, bad, muscu, f, h, v, b, m, t;
|
||||
FILE *fichier;
|
||||
|
||||
fichier = fopen("numadherent.don", "r");
|
||||
|
||||
if (fichier == NULL) {
|
||||
printf("Le fichier est vide");
|
||||
fclose(fichier);
|
||||
return;
|
||||
}
|
||||
printf("\033[1;36mVoulez-vous afficher le nombre d'adhérent d'un sport ? "
|
||||
"\n0- Oui \n1- Non\033[0m\n");
|
||||
scanf("%d", &rep);
|
||||
if (rep == 0) {
|
||||
while (feof(fichier) == 0) {
|
||||
fscanf(fichier, "%d, %d, %d, %d, %d, %d, %d, %d", &id, &statut, &pts,
|
||||
&foot, &hand, &volley, &bad, &muscu);
|
||||
if (foot == 1) {
|
||||
++f;
|
||||
++t;
|
||||
}
|
||||
if (hand == 1) {
|
||||
++h;
|
||||
++t;
|
||||
}
|
||||
if (volley == 1) {
|
||||
++v;
|
||||
++t;
|
||||
}
|
||||
if (bad == 1) {
|
||||
++b;
|
||||
++t;
|
||||
}
|
||||
if (muscu == 1) {
|
||||
++m;
|
||||
++t;
|
||||
}
|
||||
}
|
||||
fclose(fichier);
|
||||
printf ("\033[1;36mQuel sport avez-vous choisi ? "
|
||||
"\n0- Football \n1- Handball \n2- Volleyball \n3- Badminton \n4- "
|
||||
"Musculation \n5- Tous\033[0m\n");
|
||||
scanf("%d", &rep2);
|
||||
if (rep2 == 0) {
|
||||
printf("Football :\t%d\n", f);
|
||||
} else if (rep2 == 1) {
|
||||
printf("Handball :\t%d\n", h);
|
||||
} else if (rep2 == 2) {
|
||||
printf("Volleball :\t%d\n", v);
|
||||
} else if (rep2 == 3) {
|
||||
printf("Badminton :\t%d\n", b);
|
||||
} else if (rep2 == 4) {
|
||||
printf("Musculation :\t%d\n", m);
|
||||
} else if (rep2 == 5) {
|
||||
printf("Tous :\t%d\n", t);
|
||||
}
|
||||
}
|
||||
if (rep == 1) {
|
||||
printf("\033[1;31mVous ne souhaitez pas afficher de sport\033[0m\n");
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue