Beruflich Dokumente
Kultur Dokumente
h>
struct record {
//
char name[30]; char type[15]; char dday[10]; char dtime[10]; char aday[10]; char atime[10]; char des[30]; int capa; } rail; // WITH THEIR ELEMENTS
struct record1 {
//
char name[20]; char addr[40]; char dest[30]; char rail[20]; char dod[10]; char time[10];
} customer;
void printTitle(void); void showMenu(void); void customerf(void); void railf(void); void start(void); void menu(void); void add_rail(void); void edit_rail(); void delete_rail(void); void add_customer(void); void edit_customer(void); void delete_customer(void); void end(void); void view_rail(void); void view_customer(void); void option(void); void option1(void); // IN THE PROGRAMS // MADE AND USED // FUNCTIONS
void option2(void);
int driver=DETECT,mode;
initgraph(&driver,&mode,"c:\\tc\\bgi");
randomize();
cleardevice(); start(); menu(); getch(); closegraph(); } void start(void) { setcolor(RED); setlinestyle(SOLID_LINE,1,3); rectangle(0,0,639,479); // RECTANGLE WHICH IS THE BORDER // FUNTION USED FOR MAKING THE // THE VALUE RETURNED... // AND THEM CHECK
setcolor(BLUE);
setlinestyle(SOLID_LINE,1,2); rectangle(10,10,629,469); }
//
void showMenu(void) { settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); setcolor(WHITE); outtextxy(60,150,"1) RAILWAY INFORMATION"); font outtextxy(60,210,"2) CUSTOMER PROFILE"); font outtextxy(60,270,"3) EXIT"); } //setting the position and the font //setting the position and the //set text style for the options //set colour for the fonts //setting the position and the
void menu(void) { settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); setcolor(WHITE); outtextxy(60,150,"1) RAILWAY INFORMATION"); font outtextxy(60,210,"2) CUSTOMER PROFILE"); font outtextxy(60,270,"3) EXIT"); //setting the position and the font //setting the position and the //set text style for the options //set colour for the fonts //setting the position and the
while (1) {
while(!(kbhit())) { printTitle(); }
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); options setcolor(0); outtextxy(60,150,"1) RAILWAY INFORMATION"); and the font settextstyle(TRIPLEX_FONT,HORIZ_DIR,5); options setcolor(10); outtextxy(60,150,"1) RAILWAY INFORMATION"); and the font delay(500);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); options setcolor(0); outtextxy(60,210,"2) CUSTOMER PROFILE"); font settextstyle(TRIPLEX_FONT,HORIZ_DIR,5); options setcolor(10); outtextxy(60,210,"2) CUSTOMER PROFILE"); font delay(500);
//set colour for the fonts //setting the position and the
//set colour for the fonts //setting the position and the
customerf(); cleardevice(); start(); showMenu(); break; case '3': settextstyle(TRIPLEX_FONT,HORIZ_DIR,4); options setcolor(0); outtextxy(60,270,"3) EXIT"); font settextstyle(TRIPLEX_FONT,HORIZ_DIR,5); options setcolor(10); outtextxy(60,270,"3) EXIT"); font delay(500); //set colour for the fonts //setting the position and the //set text style for the //set colour for the fonts //setting the position and the //set text style for the
end(); cleardevice(); start(); showMenu(); break; default: inv(); } } } void printTitle(void) { int temp, temp2; // END FUNCTION IS CALLED AFTER
temp=(rand()% 15)+1; settextstyle(SANS_SERIF_FONT,HORIZ_DIR,4); setcolor(temp); //set tect style for the heading //set colour for the fonts
outtextxy(16,40,"WELCOME TO THE RAILWAY RESERVATION"); //setting the position and the font
temp2=(rand()%15)+1; setcolor(temp2); underline line(20,80,621,80); //set position for the line //set colour for the
delay(400);
outtextxy(60,150,"1)ADD RAILWAY INFORMATION"); outtextxy(60,210,"2)DELETE RAILWAY INFORMATION"); outtextxy(60,270,"3)VIEW RAILWAY INFORMATION"); outtextxy(60,330,"4)EDIT RAILWAY INFORMATION"); outtextxy(60,390,"5)GO BACK TO THE MAIN MENU"); switch(getch()) { case '1':
case '2': delete_rail(); cleardevice(); railf(); break; case '3': view_rail(); cleardevice(); railf(); break;
menu(); break;
} void customerf(void) { d=0,c=0; cleardevice(); start(); settextstyle(TRIPLEX_FONT,HORIZ_DIR,6); setcolor(LIGHTBLUE); outtextxy(13,40,"CUSTOMER INFORMATION"); setcolor(YELLOW); settextstyle(TRIPLEX_FONT,HORIZ_DIR,4);
outtextxy(60,150,"1)ADD CUSTOMER INFORMATION"); outtextxy(60,210,"2)DELETE CUSTOMER INFORMATION"); outtextxy(60,270,"3)VIEW CUSTOMER INFORMATION"); outtextxy(60,330,"4)EDIT CUSTOMER INFORMATION");
switch(getch()) { case '1': add_customer(); cleardevice(); customerf(); break; case '2': delete_customer(); cleardevice(); customerf(); break; case '3': view_customer(); cleardevice(); customerf(); break; case '4': edit_customer(); cleardevice(); customerf(); break; case '5':
exit(0);
break; case 'N': case 'n': break; default : inv(); getch(); end(); } }
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
if((c!=1)&&(d!=1)) { cleardevice(); start(); outtextxy(90,290,"RECORD ADDED"); outtextxy(90,310,"PRESS ANY KEY TO CONTINUE"); getch(); }
fclose(fpoin); fflush(stdin);
cleardevice(); start(); gotoxy(10,5); printf("ENTER THE NAME OF THE RAILWAY:"); gets(temp1); searchname=strupr(temp1); gotoxy(10,7); printf("ENTER THE NAME OF DESTINATION:"); gets(temp); desname=strupr(temp); fpoin=fopen("c:\\rail.txt","r"); while((fread(&rail,sizeof(rail),1,fpoin))!=NULL) {
gotoxy(9,10); printf("RAILWAY NAME"); gotoxy(26,10); puts(rail.name); gotoxy(20,11); printf("\n\tDESTINATION\t %s \ \n\tDEPARTURE DAY\t %s \n\tDEPARTURE TIME\t %s \n\tARRIVAL DAY\t %s \n\tARRIVAL TIME\t %s \ \ \ \
\n\tCAPACITY\t %d",rail.des,rail.dday,rail.dtime,rail.aday,rail.atime,rail.capa);
{ case 'D': case 'd': k=1; success=1; break; case 'F': case 'f': break;
if(success==1) break; }
if((success2==1)&&(success==1)) { rewind(fpoin);
fpoin1=fopen("c:\\temp.txt","w");
for(j=0;j<=3;j++) { cleardevice(); start(); settextstyle(TRIPLEX_FONT,HORIZ_DIR,2); setcolor(WHITE); outtextxy(100,150,"RECORD DELETING"); delay(700); setcolor(BLACK); outtextxy(100,150,"RECORD DELETING"); delay(700); setcolor(WHITE);
fread(&rail,sizeof(rail),1,fpoin);
start();
fclose(fpoin1); fclose(fpoin);
getch(); }
} void view_rail(void) { cleardevice(); setcolor(4); settextstyle(3,0,5); outtextxy(40,100,"PRESS"); setcolor(11); settextstyle(3,0,3); outtextxy(70,200,"1 - TO SEARCH BY NAME"); outtextxy(70,320,"2 - TO GO BACK");
start(); switch(getch())
{ case '1': option1(); view_rail(); break; case '2':railf(); break; default : inv(); view_rail();
} fflush(stdin); }
while((fread(&rail,sizeof(rail),1,fpoin))!=NULL) {
gotoxy(9,10); printf("RAILWAY NAME"); gotoxy(26,10); puts(rail.name); gotoxy(20,11); printf("\n\tDESTINATION\t %s \ \n\tDEPARTURE DAY\t %s \ \n\tARRIVAL DAY\t %s \n\tARRIVAL TIME\t %s \n\tDEPARTURE TIME\t \ \
%s
\n\tCAPACITY\t %d",rail.des,rail.dday,rail.dtime,rail.aday,rail.atime,rail.capa);
gets(temp1); searchname=strupr(temp1); gotoxy(10,7); printf("ENTER THE NAME OF DESTINATION:"); gets(temp); desname=strupr(temp); fpoin=fopen("c:\\rail.txt","r"); while((fread(&rail,sizeof(rail),1,fpoin))!=NULL) {
\n\tDEPARTURE TIME\t %s \
\ \
\n\tCAPACITY\t %d",rail.des,rail.dday,rail.dtime,rail.aday,rail.atime,rail.capa);
printf("\n\n\n\n\n"); start(); count++; gotoxy(20,20); printf(" (E)DIT OR (N)EXT RECORD"); switch(getch()) { case 'e': case 'E': k=1; success=1; break; case 'N': case 'n': break; default : success=2; inv(); }
if(success==1)
break; }
fread(&rail,sizeof(rail),1,fpoin);
for(j=0;j<=5;j++)
start();
fclose(fpoin1);
fclose(fpoin);
outtextxy(60,205,"DESTINATION");
getch(); }
cleardevice(); start(); gotoxy(10,5); printf("ENTER THE NAME OF CUSTOMER:"); gets(temp); searchname=strupr(temp); gotoxy(10,7); fpoin1=fopen("c:\\customer.txt","r");
while((fread(&customer,sizeof(customer),1,fpoin1))!=NULL) {
gotoxy(9,10); printf("CUSTOMER NAME"); gotoxy(34,10); puts(customer.name); gotoxy(20,11); printf("\n\tADDRESS\t\t\t %s \ \n\tDESTINATION\t\t %s \n\tRAILWAY\t\t\t %s \ \n\tDAY OF DEPARTURE\t %s \ \n\tTIME OF DEPARTURE\t %s",customer.addr,customer.dest,customer.rail,customer.dod,customer.time); \
start(); count++;
gotoxy(20,23);
printf("(E)DIT OR MOVE (F)URTHER"); switch(getch()) { case 'E': case 'e': k=1; success=1; break; case 'F': case 'f': break;
if(success==1) break; }
if((success2==1)&&(success==1))
fread(&customer,sizeof(customer),1,fpoin1);
for(j=0;j<=3;j++) {
fclose(fpoin2); fclose(fpoin1);
remove("d:\\customer.txt"); rename("d:\\temp.txt","d:\\customer.txt");
fpoin1=fopen("d:\\customer.txt","r");
cleardevice(); start(); gotoxy(10,5); printf("ENTER THE NAME OF CUSTOMER:"); gets(temp); searchname=strupr(temp); gotoxy(10,7); fpoin1=fopen("c:\\customer.txt","r"); while((fread(&customer,sizeof(customer),1,fpoin1))!=NULL) {
start(); count++;
gotoxy(10,23); printf("(D)ELETE OR MOVE (F)URTHER"); switch(getch()) { case 'D': case 'd': k=1; success=1; break; case 'F': case 'f': break;
default :
success=2; inv(); }
if(success==1) break; }
fread(&customer,sizeof(customer),1,fpoin1);
delay(1500);
fclose(fpoin2); fclose(fpoin1);
char *searchname,temp[30]; int count=0; cleardevice(); start(); gotoxy(10,5); printf("Enter the name of customer to search:"); gets(temp); searchname=strupr(temp); fpoin1=fopen("c:\\customer.txt","r");
while((fread(&customer,sizeof(customer),1,fpoin1))!=NULL) {
gotoxy(9,10); printf("CUSTOMER NAME"); gotoxy(34,10); puts(customer.name); gotoxy(20,11); printf("\n\tADDRESS\t\t\t %s \ \n\tDESTINATION\t\t %s \n\tRAILWAY\t\t\t %s \ \n\tDAY OF DEPARTURE\t %s \ \n\tTIME OF DEPARTURE\t %s",customer.addr,customer.dest,customer.rail,customer.dod,customer.time); \
void inv(void) { sound(700); outtextxy(300,430,"INVALID INPUT"); delay(500); nosound(); setcolor(0); outtextxy(300,430,"INVALID INPUT"); }