1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
| #include "TP3.h"
#include <time.h>
#include <errno.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
p_liste listePayee = (p_liste)malloc(sizeof(struct liste));
listePayee->nb = 0;
p_liste listeEnCours = (p_liste)malloc(sizeof(struct liste));
listeEnCours->nb = 0;
int nom;
p_operation tmp_operation = creeNoeud();
char tmpReponse[1000], sDateMin[20], sDateMax[20];
struct tm tmDate;
time_t minDate, maxDate;
p_liste en_cours = (p_liste)malloc(sizeof(struct liste));
en_cours->tete = NULL;
en_cours->nb = 0;
p_liste reglee = (p_liste)malloc(sizeof(struct liste));
reglee->tete = NULL;
reglee->nb = 0;
while(nom != 11){
printf("1 Afficher la liste des transactions réglées.\n");
printf("2 Afficher la liste des transactions en cours de paiement.\n");
printf("3 Insertion d'un élément à partir du clavier\n");
printf("4 Lecture des données à partir d'un fichier\n");
printf("5 Régler une opération\n");
printf("6 Supprimer une liste\n");
printf("7 Recherche par date\n");
printf("8 Recherche par montant\n");
printf("9 Afficher la liste de vente\n");
printf("10 Afficher la liste dachat\n");
printf("11 Quitter\n");
printf("\n\n\nEntrez un choix");
scanf("%d", &nom);
switch(nom){
case 1: {
if(reglee->nb == 0)
printf("Aucune information connue.\n");
else
afficheListe(reglee);
break;
}
case 2: {
if(en_cours->nb == 0)
printf("Aucune information connue.\n");
else
afficheListe(en_cours);
break;
}
case 3: {
p_operation noeud2 = creeNoeud();
printf("Entrez le nom de l'objet:\n");
scanf("%s",tmpReponse);
tmp_operation->objet = strdup(tmpReponse);
printf("Entrez le montant:\n");
scanf("%s", tmpReponse);
printf("%s", tmpReponse);
printf("%f", atof(tmpReponse));
tmp_operation->montant = atof(tmpReponse);
printf("Entrez la date:(format jj-mm-aaaa)\n");
scanf("%s",tmpReponse);
tmDate.tm_mday = atoi(StrSub(tmpReponse, 0, 2));
tmDate.tm_mon = atoi(StrSub(tmpReponse, 3, 2)) - 1;
tmDate.tm_year = atoi(StrSub(tmpReponse, 6, 4)) - 1900;
tmDate.tm_sec = 0;
tmDate.tm_min = 0;
tmDate.tm_hour = 0;
tmDate.tm_isdst = -1;
tmp_operation->date = mktime(&tmDate);
printf("Vente ou achat ?(V/A)\n");
scanf("%s",tmpReponse);
if(strcmp(tmpReponse,"V"))
tmp_operation->t_d_t=0;
else
tmp_operation->t_d_t=1;
printf("En cours ou Payée ? (E/P)\n");
scanf("%s",tmpReponse);
printf("\n%s", tmp_operation->objet);
printf("\n%2.f", tmp_operation->montant);
printf("\n%s", ctime(&tmp_operation->date));
printf("\n%d", tmp_operation->t_d_t);
if(strcmp(tmpReponse,"E")){
tmp_operation->statut=1;
insertionNoeud(tmp_operation,reglee);
}
else {
tmp_operation->statut=0;
insertionNoeud(tmp_operation,en_cours);
}
break;
}
case 4:{
printf("Entrez un nom de fichier:\n");
scanf("%s",tmpReponse);
LireFicher(en_cours, reglee, tmpReponse);
break;
}
case 5: {
afficheListe(en_cours);
printf("Entrez le numéro de l'objet à régler\n");
scanf("%s",tmpReponse);
tmp_operation = rechercheObjet(reglee, atoi(tmpReponse));
reglerOperation(en_cours, reglee, tmp_operation);
break;
}
case 6: {
printf("Quelle liste voulez-vous effacer ? (En Cours (E) ou Payée (P))\n");
scanf("%s",tmpReponse);
if(tmpReponse == "E")
supprimeListe(en_cours);
else
supprimeListe(reglee);
break;
}
case 7: {
printf("Entrez la date minimum et la date maximum séparées par un espace (format : jj-mm-aaaa jj-mm-aaaa):\n");
scanf("%s %s",sDateMin,sDateMax);
tmDate.tm_mday = atoi(StrSub(sDateMin, 0, 2));
tmDate.tm_mon = atoi(StrSub(sDateMin, 3, 2)) - 1;
tmDate.tm_year = atoi(StrSub(sDateMin, 6, 4)) - 1900;
tmDate.tm_sec = 0;
tmDate.tm_min = 0;
tmDate.tm_hour = 0;
tmDate.tm_isdst = -1;
minDate = mktime(&tmDate);
tmDate.tm_mday = atoi(StrSub(sDateMax, 0, 2));
tmDate.tm_mon = atoi(StrSub(sDateMax, 3, 2)) - 1;
tmDate.tm_year = atoi(StrSub(sDateMax, 6, 4)) - 1900;
tmDate.tm_sec = 0;
tmDate.tm_min = 0;
tmDate.tm_hour = 0;
tmDate.tm_isdst = -1;
maxDate = mktime(&tmDate);
printf("\nObjets non réglés :\n");
afficheListe(rechercheDate(en_cours, minDate, maxDate));
printf("\nObjets réglés :\n");
afficheListe(rechercheDate(reglee, minDate, maxDate));
break;
}
case 8: {
int minMontant,maxMontant;
printf("Entre minMontant et maxMontant:\n");
scanf("%d %d",&minMontant,&maxMontant);
afficheListe(rechercheMontant(en_cours, minMontant,maxMontant));
afficheListe(rechercheMontant(reglee, minMontant,maxMontant));
break;
}
case 9: {
afficheListe(rechercheVente(en_cours));
afficheListe(rechercheVente(reglee));
break;
}
case 10: {
afficheListe(rechercheAchat(en_cours));
afficheListe(rechercheAchat(reglee));
break;
}
case 11: {printf("Bye");break;}
default: {printf("Mauvais Choix");}
}
};
supprimeListe(en_cours);
supprimeListe(reglee);
free(en_cours);
free(reglee);
return 0;
} |
Partager