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 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
|
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "structs.c"
#include "libb.c"
#define KEY_DOWN 80
#define KEY_UP 72
/******************************************************************************/
void main()
{
textmode(C4350);
textbackground(7);
clrscr();
menu_principal();
}
void menu_principal()
{
char vec[6][11]={"Car Search","Clients","Parc Auto","Equipier","Facture","Quitter"};
int n=6, rep;
int l=11;
int PosX=5,PosY=42;
do
{
clrscr();
rep=deroulant(&vec[0][0],l,PosX,PosY,n);
switch(rep)
{
case 0 : clrscr();
car_search();
break; //rechercher une auto
case 1 : clrscr();
client();
break; //operation sur client
case 2 : clrscr();
parc_auto();
break; //operation sur les autos.
case 3 : clrscr();
equipier();
break; //operation sur les vendeurs
case 4 : break; //operation sur les options (indeterminé)
case 5 : break; //quitter
}
}
while(rep!=5);
}//pas de prob !
/******************************************************************************/
void parc_auto()
{
int i,j;
int rslt; //var qui accueillera le rslt du menu deroulant.
int l=11; //longueur de la plus longue chaine
int PosX=4,PosY=44; //le positionnement du menu deroulant
int n=4; //nbre de chaine
char fichier[9]={"auto.dat"};
char index[15]={"index_auto.dat"};
char fichier_temporaire[10]={"auto2.dat"};
char vec[4][11]={"Visualiser","Ajouter","Modifier","Retour"};
do
{
clrscr();
ecran();
gotoxy(4,4);
textcolor(0);cprintf(" P A R C A U T O");
gotoxy(2,6);cprintf("%c",204);
for(i=3,j=6;i<79;i++)
{
gotoxy(i,j);cprintf("%c",205);
}
gotoxy(i,j);cprintf("%c",185);
rslt=deroulant(&vec[0][0],l,PosX,PosY,n);
switch(rslt)
{
case 0 :
clrscr();
visualiser(&index[0],9);
break;
case 1 :
clrscr();
ajout_auto(&fichier[0]);
creation_index_auto(&fichier[0],&index[0]);
//renommer les fichier ici ?
break; //ajout
case 2 : clrscr();
modif_auto(&fichier[0],&fichier_temporaire[0]);
creation_index_auto(&fichier[0],&index[0]);
//renommer les fichier ici ?
break; //modif
case 3 :
break; //retour
}
}
while(rslt!=3);
}
/******************************************************************************/
void client()
{
int rslt=0; //var qui accueillera le rslt du menu deroulant.
int l=11; //longueur de la plus longue chaine
int PosX=2,PosY=44; //le positionnement du menu deroulant
int n=4;
char fichier[11]={"client.dat"};
char index[17]={"index_client.dat"};
char new_name[]={"indextrieclient.dat"},ancien_name[]={"index_client.dat"};
char vec[4][11]={"Rechercher","Ajout","Suppr","Retour"};
do
{
rslt=deroulant(&vec[0][0],l,PosX,PosY,n);
switch(rslt)
{
case 0 : ecran(); //je fait la gestion pour rechercher mtn
ax_dir_client(&fichier[0],&index[0]);
creation_index_client(&fichier[0],&index[0]);
trier_index_client(&index[0]);
renomfich(new_name,ancien_name);
break; //rechercher un client et eventuellement modifier ou supprimer le rec
case 1 : ajout_client(&fichier[0]);
creation_index_client(&fichier[0],&index[0]);
trier_index_client(&index[0]);
renomfich(new_name,ancien_name);
break; //ajouter un client
case 2 : clrscr();
suppr_client("client.dat");
creation_index_client(&fichier[0],&index[0]);
trier_index_client(&index[0]);
renomfich(new_name,ancien_name);
break;//suppression client
case 3 :
break; //retour
}
}
while(rslt!=3);
}
/******************************************************************************/
void equipier()
{
int rslt=0; //var qui accueillera le rslt du menu deroulant.
int l=9; //longueur de la plus longue chaine
int PosX=2,PosY=44; //le positionnement du menu deroulant
int n=3;
char fichier[13]={"equipier.dat"};
char vec[3][9]={"Ajout","Modifier","Retour"};
do
{
printf("\n equipier :");
rslt=deroulant(&vec[0][0],l,PosX,PosY,n);
switch(rslt)
{
case 0 : ajout_equipier(&fichier[0]);
break;
case 1 : modifier_equipier();
break;
case 2 :
break;
}
}
while(rslt!=2);
}
/******************************************************************************/
int deroulant(char* tab,int c,int col,int lig,int n)
{
int ancpos, anci,pos,i,touche,max=n;//max=nbre d'element
_setcursortype(_NOCURSOR);
for(i=0;i<max;i++)
{
gotoxy(col,lig+i);
textcolor(0);cprintf("%s\n",(tab+i*c));
}
pos=lig;i=0;
do
{
if(strcmp(tab,"Car Search")==0)
{
Logo();Cadre_Logo();Cadre_Deroulant();
}
else if (strcmp(tab,"Rechercher")==0)
{
Logo();Cadre_Logo();
}
gotoxy(col,pos);textcolor(2);
cprintf("%s",(tab+i*c)); textcolor(0);
touche=getch();
ancpos=pos;
anci=i;
if(touche==0)
{
touche=getch();
if(touche==KEY_DOWN)
{
if(i==max-1)
{
pos=lig;
i=0;
}
else
{
++pos;
++i;
}
}
if(touche==KEY_UP)
{
if(i==0)
{
pos=lig+(n-1);
i=max-1;
}
else
{
--pos;
--i;
}
}// fin if touche KEY_UP
gotoxy(col,ancpos);
textbackground(7);
cprintf("%s",(tab+anci*c));
}
}
while(touche != 13);
_setcursortype(_NORMALCURSOR);
return i;
} |
Partager