You are on page 1of 24

#include<graphics.

h>
#include"math.h"
#include<fstream.h>
#include<ctype.h>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<dos.h>
#include<stdlib.h>
#include<process.h>
void desd();
void clist();
void dclist();
void tlist();
void dtlist();
struct traininfo
{ char t_name[50],type[10]; int t_no; float arr,dep; char days[20],de
st[30],src[30]; }p;
struct trstn
{ char s_name[30]; int no,st_no; }t;
struct stncode
{
char stn[30],code[5]; int no; }s;
class design
{
public :
void rninfo();
void listinfo();
void codeinfo();
};
class IR
{
public:
void trinfo();
void new_trinfo();
void clear(int,int);
void search();
void searchstn(int );
int checking(int);
void display_list(void);
void transaction(void);
int last_accno(int);
void display_account(void);
void modify();
int recordno(int t_accno);
void pnrecord();
void close_account(void);
void codes();
int last_accno(void);
void enqinfo();
};
void design::rninfo()
{
rectangle(10,3,630,65);
line(10,40,630,40);
settextstyle(4,0,1);
outtextxy(170,5,"I N D I A N R A I L W A Y S");
settextstyle(0,0,0);
outtextxy(110,30,"|| R U N N I N G T R A I N S I N F O M A T I O N ||");
outtextxy(30,50,"INFORMATION CENTER..");outtextxy(325,50,"ENTER TRAIN NO : ");

rectangle(10,70,630,410);line(35,70,35,410);rectangle(10,410,630,470);
line(320,70,320,410);
line(345,70,345,410);
outtextxy(12,75,"SNo
Station Name");
outtextxy(322,75,"SNo
Station Name");
line(10,85,630,85);
}
void design::listinfo()
{
gotoxy(25,2);cout<<"LIST OF TRAINS OF INDIAN RAILWAYS";
rectangle(10,10,630,470);
rectangle(10,40,630,440);
rectangle(60,40,205,440);
rectangle(250,40,288,440);
rectangle(410,40,459,440);
line(580,40,580,440);
line(10,70,630,70);
gotoxy(3,4);cout<<"TRNO";
gotoxy(10,4);cout<<"NAME OF TRAIN";
gotoxy(27,4);cout<<"TYPE";
gotoxy(33,4);cout<<"DAYS";
gotoxy(38,4);cout<<"STARTSTN";
gotoxy(53,4);cout<<"DEP";
gotoxy(59,4);cout<<"ENDSTN";gotoxy(74,4);cout<<"ARRIV";
}
void design::codeinfo()
{
gotoxy(25,2); cout<<"LIST OF CODE OF INDIAN STATION";
rectangle(10,10,630,470);
rectangle(10,40,630,440);
gotoxy(3,4); cout<<"STNO";
gotoxy(5,4); cout<<"CODE";
gotoxy(11,4); cout<<"NAME OF STATN";
gotoxy(29,4); cout<<"STNO";
gotoxy(31,4);cout<<"CODE";
gotoxy(37,4);cout<<"NAME OF STATN";
gotoxy(55,4);cout<<"STNO";
gotoxy(57,4);cout<<"CODE";
gotoxy(63,4);cout<<"NAME OF STATN";
}
void IR::trinfo()
{
clrscr();
cleardevice();
char name[10] ;
int no,accno,y,row=7, flag = 0,st1,st2;
fstream file ,result;
design d;
d.rninfo();
gotoxy(58,4) ; cin>>no;
accno = no;
if(accno == 0)
return ;
file.open("station.dat", ios::in|ios::binary) ;
while(file.read((char*)&t,sizeof(t)))
{
top1:
if(t.no == accno)
{

flag = 1 ;
delay(10) ;
gotoxy(3,row) ;
cout <<t.st_no;
gotoxy(7,row) ;
cout <<t.s_name ;
row++ ;
if(row == 25)
{
row=7;
while(file.read((char*)&t,sizeof(t)))
{
if(t.no == accno)
{
gotoxy(42,row) ;
cout <<t.st_no;
gotoxy(46,row) ;
cout <<t.s_name ;
row++ ;
if(row==24)
{
gotoxy(46,25);
cout<<"press any key to continue";
getch();
clrscr();
cleardevice();
d.rninfo();
if(!kbhit())
row=7;
goto top1;
}
}
}
flag = 1 ;
outtextxy(25,430,"NOTE: Note the station no you search for..... ");
outtextxy(25,450,"Press a key to continue... List represented");
}
flag = 1 ;
outtextxy(25,430,"NOTE: Note the station no you search for..... ");
outtextxy(25,450,"Press a key to continue... List represented");
}
}
file.close() ;
if(flag==0)
{
outtextxy(25,430,"No Stations or Train No Incorrect");
outtextxy(25,450,"press a key to continue...");
getch() ;
return;
}
getch();
searchstn(accno);
}
void IR::new_trinfo()
{
IR ini;
int valid=0,ch,no,kar,ex;
char con;
clrscr();
cleardevice();
do
{
gotoxy(1,1);cout<<" Enter (0) to exit. ";

gotoxy(17,3);
printf("E N T E R N E W T R A I N I N F O R M A T I O N");
clear(5,19);clear(5,17);
fstream result;
result.open("Trsinfo.dat",ios::app|ios::binary);
rectangle(90,60,550,410);
rectangle(90,100,550,370);
gotoxy(23,6); printf("R U N N I N G T R A I N S I N F O");
gotoxy(15,8); cout<<"Train No : ";
gotoxy(15,10); cout<<"Train Name: ";
gotoxy(15,12); cout<<"Train Type:";
gotoxy(15,14); cout<<"Days(Mon-Sun):";
gotoxy(15,16); cout<<"Source:";
gotoxy(45,16); cout<<"Departure:";
gotoxy(15,18); cout<<"Destination:";
gotoxy(45,18); cout<<"Arrival:";
top:
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER TRAIN NO:" ;
valid = 1 ;
gotoxy(30,8) ;
cin>>no;
if(no=='0')
return;
kar=checking(no);
if(kar==0)
{
p.t_no=no;
if(p.t_no =='0' || p.t_no < 0)
{
valid=0;
gotoxy(5,23) ;
cprintf("SHOULD NOT LESS THAN 500 ") ;
getch() ;
}
}
else
goto top;
fflush(stdin);
}while (!valid) ;
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER NAME OF THE TRAIN:" ;
valid = 1 ;
gotoxy(30,10) ;
gets(p.t_name) ;
strupr(p.t_name) ;
if (p.t_name[0] == '0')
return ;
if (strlen(p.t_name) == 0 || strlen(p.t_name) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);

}while (!valid) ;
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER TRAIN TYPE:" ;
valid = 1 ;
gotoxy(30,12) ;
gets(p.type) ;
strupr(p.type) ;
if (p.type[0] == '0')
return ;
if (strlen(p.t_name) == 0 || strlen(p.t_name) > 100)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);
}while (!valid) ;
do
{
int i;
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER TRAIN RUNNING DAYS:" ;
valid = 1 ;
gotoxy(30,14) ;
cin>>p.days;
strupr(p.days) ;
if (p.days[0] == '0')
return ;
fflush(stdin);
}while (!valid) ;
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER SOURCE STATION NAME:" ;
valid = 1 ;
gotoxy(30,16) ;
gets(p.src) ;
strupr(p.src) ;
if (p.src[0] == '0')
return ;
if (strlen(p.src) == 0 || strlen(p.src) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);
}while (!valid) ;
do
{
int i;
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER DEPARTURE TIME:" ;
valid = 1 ;
gotoxy(60,16) ;
cin>>p.dep;

if (p.dep== '0')
return ;
fflush(stdin);
}while (!valid) ;
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER DEST STATION NAME:" ;
valid = 1 ;
gotoxy(30,18) ;
gets(p.dest) ;
strupr(p.dest) ;
if (p.dest[0] == '0')
return ;
if (strlen(p.dest) == 0 || strlen(p.dest) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);
}while (!valid) ;
do
{
int i;
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER ARRIVAL TIME:" ;
valid = 1 ;
gotoxy(60,18) ;
cin>>p.arr;
if (p.arr== '0')
return ;
fflush(stdin);
}while (!valid) ;
do
{
valid = 1 ;
gotoxy(15,20) ;
cout <<"Do you want to save the record (y/n) : " ;
ch = getche() ;
if(ch == '0')
return ;
ch = toupper(ch) ;
}while (!valid) ;
if(ch=='Y' || ch=='y')
{
result.write((char*)&p,sizeof(p));
result.close();
}
gotoxy(15,22) ;
printf("Want to continue (y/n): ");
con = getche() ;
con = toupper(con) ;
clear(30,8);clear(30,10);clear(30,12);
clear(30,14);clear(30,16);clear(30,18);
clear(15,20);clear(15,22);clear(60,16);
}while(con=='y'|| con=='Y');
}

void IR :: clear(int col, int row)


{
for (int i=col; i<65; i++)
{
gotoxy(i,row) ;
cout <<" " ;
}
}
void IR::search()
{
int roll,flag=0;
char ch;
clrscr();
cleardevice();
settextstyle(2,0,0);
gotoxy(1,1);
cout<<"Enter (0) to exit.";
rectangle(90,60,550,410);
rectangle(90,100,550,370);
gotoxy(21,6); printf("R U N N I N G T R A I N S I N F O");
gotoxy(15,8); cout<<"Train No : ";
gotoxy(15,10); cout<<"Train Name: ";
gotoxy(15,12); cout<<"Train Type:";
gotoxy(15,14); cout<<"Days(Mon-Sun):";
gotoxy(15,16); cout<<"Source :";
gotoxy(15,18); cout<<"Destination:";
gotoxy(45,16); cout<<"Departure: ";
gotoxy(45,18); cout<<"Arrival: ";
gotoxy(15,25); cout<<"Enter the Train No";
gotoxy(30,8); cin>>roll;
fstream result;
result.open("Trsinfo.dat",ios::in|ios::binary);
result.read((char*)&p,sizeof(p));
while(result)
{
if(p.t_no==roll)
{
flag=1;
clear(15,25);
gotoxy(15,25); cout<<"RECORD FOUND";
gotoxy(30,8); cout<<p.t_no;
gotoxy(30,10); cout<<p.t_name;
gotoxy(30,12); cout<<p.type;
gotoxy(30,14); cout<<p.days;
gotoxy(30,16); cout<<p.src;
gotoxy(30,18); cout<<p.dest;
gotoxy(60,16); cout<<p.dep;
gotoxy(60,18); cout<<p.arr;
fflush(stdout);
result.close();
getch();
}
else
result.read((char*)&p,sizeof(p));
}
if(flag==0)
{
clear(15,25);

gotoxy(15,25);
cout<<"SORRY! The Train No."<<roll<<" does not exist.";
result.close();
getch();
}
}
int IR::checking(int z)
{
int suansh=0;
fstream result;
result.open("Trsinfo.dat",ios::in|ios::binary);
result.read((char*)&p,sizeof(p));
while(result)
{
if(p.t_no==z)
{
gotoxy(15,25);
cout<<"ENTRY ALREADY EXISTS";
getch();
suansh=1;
break;
}
result.read((char*)&p,sizeof(p));
}
return(suansh);
}
void IR :: display_list(void)
{
int ch;
while(1)
{
clrscr(); cleardevice();
settextstyle(2,0,5);
rectangle(200,150,440,330);
rectangle(200,200,440,290);
outtextxy(270,170,"DISPLAY MENU");
outtextxy(270,210,"1. CODE LIST");
outtextxy(270,230,"2. TRAIN LIST");
outtextxy(270,250,"0. EXIT MENU");
outtextxy(250,303,"ENTER CHOICE:");
gotoxy(47,20);
cin>>ch;
switch(ch)
{
case 1: clist(); break;
case 2: tlist(); break;
case 0: return; break;
}
}
getch();
}
void clist()
{
clrscr(); cleardevice();
int row=6, flag;
design d; d.codeinfo();
fstream result;
result.open("codestn.txt", ios::in|ios::binary) ;

top1:
while (result.read((char*)&s,sizeof(s)))
{
flag = 0; delay(100);
gotoxy(3,row); cout <<s.no; delay(5) ;
gotoxy(7,row); cout <<s.code; delay(5) ;
gotoxy(13,row); cout <<s.stn; delay(5) ;
row++ ;
if(row==25)
{
row=6;
while (result.read((char*)&s,sizeof(s)))
{
flag = 0; delay(100);
gotoxy(31,row); cout <<s.no; delay(5) ;
gotoxy(35,row); cout <<s.code; delay(5) ;
gotoxy(40,row); cout <<s.stn; delay(5) ;
row++ ;
if(row==25)
{
row=6;
while (result.read((char*)&s,sizeof(s)))
{
flag = 0; delay(100);
gotoxy(55,row); cout <<s.no; delay(5) ;
gotoxy(59,row); cout <<s.code; delay(5) ;
gotoxy(65,row); cout <<s.stn; delay(5) ;
row++ ;
if(row==25)
{
outtextxy(20,450,"press any key to continue");
getch(); clrscr();
cleardevice();
design d; d.codeinfo();
if(!kbhit())
row=6;
goto top1;
}
}
}
}
}
}
result.close() ;
if(!flag)
{
outtextxy(20,450,"Press any key to continue...");
}
getch();
}
void tlist()
{
clrscr() ;
cleardevice();
int row=6, flag;
design d;
d.listinfo();
fstream result;
result.open("Trsinfo.dat", ios::in|ios::binary) ;
top1:

while (result.read((char*)&p,sizeof(p)))
{
flag = 0; delay(100);
gotoxy(3,row); cout <<p.t_no;
delay(10) ;
gotoxy(9,row); cout <<p.t_name; delay(10) ;
gotoxy(27,row); cout <<p.type;
delay(10) ;
gotoxy(33,row); cout <<p.days;
delay(10) ;
gotoxy(38,row); cout <<p.src;
delay(10) ;
gotoxy(53,row); cout <<p.dep;
delay(10) ;
gotoxy(59,row); cout <<p.dest;
delay(10) ;
gotoxy(74,row); cout <<p.arr;
delay(10) ;
row++ ;
if(row==25)
{
outtextxy(20,450,"press any key to continue");
getch(); clrscr();
cleardevice();
design d; d.listinfo();
if(!kbhit())
row=6;
goto top1;
}
}
result.close() ;
if(!flag)
{
outtextxy(20,450,"Press any key to continue...");
}
getch();
}
void IR :: transaction(void)
{
IR ini;
int i,valid=0,ch,no,kar,ex,sno;char con;
clrscr(); cleardevice();
gotoxy(5,5);
cout<<"No of Station : ";
gotoxy(5,7);
cout<<"Enter Train No : ";
top:
gotoxy(5,23);
cout<<"Enter no of station ";
gotoxy(30,5);
cin>>sno;
clear(5,23);
gotoxy(5,23);
cout<<"Enter train no ";
gotoxy(30,7);
cin>>no;
do
{
valid = 1 ;
kar=checking(no);
if(kar==1)
{
t.no=no;
if(t.no =='0' || t.no < 0)
{
valid=0;

gotoxy(15,25) ;
cprintf("SHOULD NOT LESS THAN 500 ") ;
getch() ;
}
}
else
goto top;
}while (!valid);
top1:
i=1;
do
{
clrscr();
cleardevice();
gotoxy(1,1);cout<<" Enter (0) to exit. ";
gotoxy(17,3);
printf("N E W T R A I N S T A T I O N I N F O R M A T I O N");
clear(5,19);clear(5,17);
fstream result;
result.open("station.dat",ios::app|ios::binary);
t.st_no=i;
gotoxy(15,8); cout<<"Train No :
"<<t.no;
gotoxy(15,10); cout<<"Station No: "<<t.st_no;
gotoxy(15,12); cout<<"Station Name: ";
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER NAME OF THE STATION:" ;
valid = 1 ;
gotoxy(30,12) ;
gets(t.s_name) ;
strupr(t.s_name) ;
if (t.s_name[0] == '0')
return ;
if (strlen(t.s_name) == 0 || strlen(t.s_name) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);
}while (!valid) ;
do
{
valid = 1 ;
gotoxy(15,20) ;
cout <<"Do you want to save the record (y/n) : " ;
ch = getche() ;
if(ch == '0')
return ;
ch = toupper(ch) ;
}while (!valid) ;
if(ch=='Y' || ch=='y')
{
result.write((char*)&t,sizeof(t));
result.close();
i++;
}
clear(30,8);clear(30,10);

clear(30,14);clear(30,16);
clear(15,20);clear(15,22);
if(i==sno)
{
gotoxy(15,20);
cout<<"Station information completed";
delay(100);
}
}while(i<=sno);
}
void IR::searchstn(int accno)
{
int roll,flag=0,flag1=0,troll,st1,st2,valid=0;
char ch,str1[30],str2[30];
clrscr();
cleardevice();
top:
gotoxy(5,5);cout<<"Enter station nos : ";
gotoxy(5,7);cout<<"Station From : ";
gotoxy(5,9);cout<<"Station To : ";
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER FROM NO:" ;
valid = 1 ;
gotoxy(20,7) ;
cin>>st1;
if (st1== '0')
return ;
}while (!valid) ;
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER TO NO:" ;
valid = 1 ;
gotoxy(20,9) ;
cin>>st2;
if (st2== '0')
return ;
}while (!valid) ;
fstream result;
result.open("station.dat",ios::in|ios::binary);
result.read((char*)&t,sizeof(t));
while(result)
{
if(t.no==accno&&t.st_no==st1)
{
flag=1;
gotoxy(15,23); cout<<"RECORD FOUND";
strcpy(str1,t.s_name);
fflush(stdout);
result.close();
}
else
result.read((char*)&t,sizeof(t));
}
if(flag==0)
{
clear(15,23);

gotoxy(15,23);
cout<<"SORRY! The Train No."<<accno<<" or station no "<<st2<< "does not exi
st.";
delay(500);
result.close();
return;
}
result.open("station.dat",ios::in|ios::binary);
result.read((char*)&t,sizeof(t));
while(result)
{
if(t.no==accno&&t.st_no==st2)
{
flag1=1;
gotoxy(15,24); cout<<"RECORD FOUND";
strcpy(str2,t.s_name);
fflush(stdout);
result.close();
}
else
result.read((char*)&t,sizeof(t));
}
if(flag1==0)
{
clear(15,24);
gotoxy(15,24);
cout<<"SORRY! The Train No."<<accno<<" or station no "<<st2<< "does not exi
st.";
delay(500);
result.close();
return;
}
getch();
clrscr();
cleardevice();
rectangle(10,10,630,470);
rectangle(10,70,630,410);
line(10,35,630,35);
settextstyle(0,0,0);
outtextxy(35,20," S E A T A V A I L A B I L I T Y B E T W E E N T W O S T A
T I O N ");
settextstyle(0,0,0);
outtextxy(35,52,"FROM :");
outtextxy(215,52,"TO :");
outtextxy(375,52,"DATE(DD/MM/YY) :");
gotoxy(68,4);cout<<"/";
gotoxy(73,4);cout<<"/";
settextstyle(0,0,0);
gotoxy(12,4);cout<<str1;
gotoxy(34,4);cout<<str2;
getch();
}
void IR:: modify()
{
clrscr() ;
cleardevice();
char t_name[50],type[10];
int t,t_accno,flag=0,ch,modified=0,valid;
float arr,dep;

char days[20],dest[30],src[30];
gotoxy(1,1) ; cout <<"PRESS (0) TO EXIT" ;
gotoxy(5,5) ; cout <<"Enter the train no. " ;
cin>>t_accno;
if(t_accno == 0)
return ;
fstream result;
result.open("Trsinfo.dat",ios::in|ios::binary);
result.read((char*)&p,sizeof(p));
while(result)
{
if(p.t_no==t_accno)
{
flag=1;
clear(15,25);
gotoxy(15,25); cout<<"RECORD FOUND";
gotoxy(30,8); cout<<p.t_no;
gotoxy(30,10); cout<<p.t_name;
gotoxy(30,12); cout<<p.type;
gotoxy(30,14); cout<<p.days;
gotoxy(30,16); cout<<p.src;
gotoxy(30,18); cout<<p.dest;
gotoxy(60,16); cout<<p.dep;
gotoxy(60,18); cout<<p.arr;
fflush(stdout);
result.close();
getch();
}
else
result.read((char*)&p,sizeof(p));
}
if(flag==0)
{
clear(15,25);
gotoxy(15,25);
cout<<"SORRY! The Train No."<<t_accno<<" does not exist.";
result.close();
getch();
return ;
}
gotoxy(15,5);
printf("MODIFY ACCOUNT SCREEN") ;
do
{
clear(5,13) ;
gotoxy(5,13) ;
cout <<"Modify this account (y/n): " ;
ch = getche() ;
if (ch == '0')
return ;
ch = toupper(ch) ;
}while(ch!='N' && ch!='Y');
if(ch == 'N')
return ;
gotoxy(5,15) ; cout <<"No : " ;
gotoxy(5,16) ; cout <<"Name : " ;
gotoxy(5,17) ; cout <<"type : " ;
gotoxy(5,18) ; cout <<"days : " ;
gotoxy(5,19) ; cout <<"start: " ;
gotoxy(5,20) ; cout <<"dest : " ;
gotoxy(5,21) ; cout <<"dep : " ;
gotoxy(5,22) ; cout <<"arr : " ;/*
do

{
valid = 1 ; clear(5,23); gotoxy(5,23) ;
cout <<"ENTER NO or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,15) ; cin>>t;
if(t == '0')
return ;
if(t < 0)
{
valid = 0 ; gotoxy(5,23) ;
cprintf("7NAME SHOULD NOT BE GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
if(t > 0)
modified = 1 ;
do
{
valid = 1 ; clear(5,23); gotoxy(5,23) ;
cout <<"ENTER NAME or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,16) ; gets(t_name) ; strupr(t_name) ;
if(t_name[0] == '0')
return ;
if(strlen(t_name) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7NAME SHOULD NOT BE GREATER THAN 25") ;
getch() ;
}
} while (!valid) ;
if(strlen(t_name) > 0)
modified = 1 ;
do
{
valid = 1; clear(5,23) ; gotoxy(5,23) ;
cout <<"ENTER TYPE or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,17) ; gets(type) ; strupr(type) ;
if(type[0] == '0')
return ;
if(strlen(type) > 55)
{
valid = 0 ; gotoxy(5,23) ;
cprintf("7SHOULD NOT BE BLANK OR GREATER THAN 55") ;
getch() ;
}
} while (!valid) ;
if(strlen(type) > 0)
modified = 1 ;
do
{
valid = 1; clear(5,23) ; gotoxy(5,23) ;
cout <<"ENTER DAYS or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,18) ; gets(days) ; strupr(days) ;
if(days[0] == '0')
return ;
if(strlen(days) > 55)
{
valid = 0 ; gotoxy(5,23) ;

cprintf("7SHOULD NOT BE BLANK OR GREATER THAN 55") ;


getch() ;
}
} while (!valid) ;
if(strlen(days) > 0)
modified = 1 ;
do
{
valid = 1; clear(5,23) ; gotoxy(5,23) ;
cout <<"ENTER SOURCE or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,19) ; gets(src) ; strupr(src) ;
if(src[0] == '0')
return ;
if(strlen(src) > 55)
{
valid = 0 ; gotoxy(5,23) ;
cprintf("7SHOULD NOT BE BLANK OR GREATER THAN 55") ;
getch() ;
}
} while (!valid) ;
if(strlen(src) > 0)
modified = 1 ;
do
{
valid = 1; clear(5,23) ; gotoxy(5,23) ;
cout <<"ENTER DEPART or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,20) ; cin>>dep;
if(dep == '0')
return ;
if(dep > 24)
{
valid=0;
gotoxy(15,25);
cout<<"Enter the correct time:";
getch();
}
} while (!valid) ;
if(dep > 0 && dep < 24)
modified = 1 ;
do
{
valid = 1; clear(5,23) ; gotoxy(5,23) ;
cout <<"ENTER DEST or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,21) ; gets(dest) ; strupr(dest) ;
if(dest[0] == '0')
return ;
if(strlen(dest) > 55)
{
valid = 0 ;
gotoxy(5,23) ;
cprintf("7SHOULD NOT BE BLANK OR GREATER THAN 55") ;
getch() ;
}
} while (!valid) ;
if(strlen(dest) > 0)
modified = 1 ;
do
{

valid = 1; clear(5,23) ; gotoxy(5,23) ;


cout <<"ENTER ARR or PRESS <ENTER> FOR NO CHANGE" ;
gotoxy(15,22) ; cin>>arr;
if(arr == '0')
return ;
if(arr > 24)
{
valid=0; gotoxy(5,23);
cout<<"Enter the correct time:";
getch();
}
}while (!valid) ;
if(arr > 0 && arr>24)
*/
modified = 1 ;
if(!modified)
return ;
/*do
{
clear(5,18) ; gotoxy(5,18) ;
cout <<"Do you want to save changes (y/n): " ;
ch = getche() ;
if(ch == '0')
return ;
ch = toupper(ch) ;
}while (ch != 'N' && ch != 'Y');
if(ch == 'N')
return ;
clrscr();
cleardevice();
*/
int location ,recno ;
recno = recordno(t_accno) ;
result.open("Trsinfo.dat", ios::in|ios::binary) ;
if(modified==1)
{
location = (recno-1) * sizeof(p) ;
// int a=sizeof(p);
result.seekp(location,ios::beg);
cin>>p.t_no;
cin>>p.t_name;
cin>>p.type;
cin>>p.days;
cin>>p.src;
cin>>p.dep;
cin>>p.dest;
cin>>p.arr;
result.write((char*)&p,sizeof(p));
result.close() ;
gotoxy(5,21) ;
cout <<"7Record Modified" ;
getch() ;
}
else
{
gotoxy(5,21) ;
cout <<" not Record Modified" ;
getch() ;
}
}

int IR :: recordno(int t_accno)


{
fstream file ;
file.open("Trsinfo.dat", ios::in|ios::binary) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char*)&p,sizeof(p)))
{
count++ ;
if (p.t_no == t_accno)
break ;
}
file.close() ;
return count;
}
void IR::pnrecord()
{
clrscr();
cleardevice();
long int pnr;
rectangle(168,308,471,322);
gotoxy(20,10);
cout<<"Enter the 8-Digits PNR number : ";
gotoxy(52,10);
cin>>pnr;
gotoxy(27,14);
cout<<"Entered PNR no : "<<pnr;
if(pnr)
{
desd();
}
else
return;
setcolor(15);
getch();
}
void IR :: close_account(void)
{
int ch;
while(1)
{
clrscr(); cleardevice();
settextstyle(2,0,5);
rectangle(200,150,440,330);
rectangle(200,200,440,290);
outtextxy(250,170,"REMOVE DISPLAY MENU");
outtextxy(250,210,"1. REMOVE CODE LIST");
outtextxy(250,230,"2. REMOVE TRAIN LIST");
outtextxy(250,250,"0. EXIT MENU");
outtextxy(250,303,"ENTER CHOICE:");
gotoxy(47,20);
cin>>ch;
switch(ch)
{
case 1: dclist(); break;
case 2: dtlist(); break;
case 0: return; break;

}
}
getch();
}
void dtlist()
{
clrscr();
cleardevice();
IR s;
int tno; char ch ;
gotoxy(1,1) ; cout <<"PRESS (0) TO EXIT" ;
gotoxy(30,3) ; printf("CLOSE ACCOUNT SCREEN") ;
gotoxy(5,5) ; cout <<"Enter the train no. " ; cin>>tno;
if (tno == 0)
return ;
int a=s.checking(tno);
if(a==1)
{
gotoxy(5,7) ; cout <<"Account found" ;
gotoxy(30,8); cout<<p.t_no;
gotoxy(30,10); cout<<p.t_name;
gotoxy(30,12); cout<<p.type;
gotoxy(30,14); cout<<p.days;
gotoxy(30,16); cout<<p.src;
gotoxy(30,18); cout<<p.dest;
gotoxy(60,16); cout<<p.dep;
gotoxy(60,18); cout<<p.arr;
fflush(stdout);
getch() ;
}
else
{
gotoxy(5,7) ; cout <<"Account not found" ; getch() ;
return;
}
do
{
s.clear(5,15) ; gotoxy(5,15) ; cout <<"Close this account (y/n): " ;
ch = getche() ;
if(ch == '0')
return ;
ch = toupper(ch) ;
}while(ch!='N' && ch!= 'Y') ;
if(ch == 'N')
return ;
fstream file ,temp ;
file.open("Trsinfo.DAT", ios::in|ios::binary) ;
temp.open("temp.dat", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while( !file.eof() )
{
file.read((char*)&p,sizeof(p));
if( file.eof() )
break ;
if( p.t_no != tno )
temp.write((char*)&p,sizeof(p));
}
file.close() ; temp.close() ;
file.open("Trsinfo.DAT", ios::out|ios::binary) ;

temp.open("temp.dat", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while( !temp.eof() )
{
temp.read((char *)&p, sizeof(p)) ;
if( temp.eof() )
break ;
file.write((char *)&p, sizeof(p)) ;
}
file.close() ;temp.close() ;
gotoxy(5,20) ; cout <<"Record Deleted" ;
gotoxy(5,23) ; cout <<"press a key to continue..." ;
getch() ;
}
void dclist()
{
clrscr();
cleardevice();
IR d;
fstream result;
int tno,a=0;char ch , cd[10];
gotoxy(1,1) ; cout <<"PRESS (0) TO EXIT" ;
gotoxy(30,3) ; printf("CLOSE ACCOUNT SCREEN") ;
gotoxy(5,5) ; cout <<"Enter the train no. " ; cin>>tno;
if(tno == 0)
return ;
result.open("codestn.txt",ios::in|ios::binary);
result.read((char*)&s,sizeof(s));
while(result)
{
if(s.no==tno)
{
gotoxy(15,25);
cout<<"ENTRY ALREADY EXISTS";
getch();
a=1;
break;
}
result.read((char*)&s,sizeof(s));
}
if(a==1)
{
gotoxy(5,7) ; cout <<"Account found" ;
gotoxy(30,8); cout<<s.no;
gotoxy(30,10); cout<<s.code;
gotoxy(30,12); cout<<s.stn;
fflush(stdout);
getch();
}
else
{
gotoxy(5,7) ; cout <<"Account not found" ; getch() ;
return;
}
do
{
d.clear(5,15) ; gotoxy(5,15) ; cout <<"Close this account (y/n): " ;
ch = getche() ;
if(ch == '0')

return ;
ch = toupper(ch) ;
}while(ch!='N' && ch!= 'Y') ;
if(ch == 'N')
return ;
fstream file ,temp ;
file.open("codestn.txt", ios::in|ios::binary) ;
temp.open("temp1.txt", ios::out|ios::binary) ;
file.seekg(0,ios::beg) ;
while( !file.eof() )
{
file.read((char*)&s,sizeof(s));
if( file.eof() )
break ;
if( s.no != tno )
temp.write((char*)&s,sizeof(s));
}
file.close() ; temp.close() ;
file.open("codestn.txt", ios::out|ios::binary) ;
temp.open("temp1.txt", ios::in|ios::binary) ;
temp.seekg(0,ios::beg) ;
while( !temp.eof() )
{
temp.read((char *)&s, sizeof(s)) ;
if( temp.eof() )
break ;
file.write((char *)&s, sizeof(s)) ;
}
file.close() ;temp.close() ;
gotoxy(5,20) ; cout <<"Record Deleted" ;
gotoxy(5,23) ; cout <<"press a key to continue..." ;
getch() ;
}
void main()
{
int gd=DETECT,gm,i,ch;
initgraph(&gd,&gm,"E:\\TC\\BGI");
IR s; design d;
while(1)
{
clrscr();
cleardevice();
rectangle(200,50,490,405);
rectangle(200,80,490,375);
line(230,80,230,375);
settextstyle(0,1,0);
outtextxy(540,130,"INDIAN RAILWAY");
settextstyle(0,1,0);
outtextxy(100,130,"INDIAN RAILWAY");
settextstyle(2,0,5);
outtextxy(300,30,"INDIAN RAILWAY");
outtextxy(260,60,"TRAINS OPTIONS AND MENU");
outtextxy(210, 95," 1 TRAINS INFORMATION");
outtextxy(210,110," 2 APPEND NEW TRAIN INFO");
outtextxy(210,125," 3 SEARCH EXSTNG TRAIN INFO");
outtextxy(210,140," 4 LIST OF RUNNING TRAINS");
outtextxy(210,155," 5 STATIONS INFORMATION ");
outtextxy(210,170," 6 TATKAL INFORMATION");
outtextxy(210,185," 7 PNR-ENQUIRY OF TICKET");

outtextxy(210,200," 8 DELETE TRAIN ENRTY");


outtextxy(210,215," 9 STATION CODES ON");
outtextxy(210,230,"10 ENQIURY OF RUNNING TRAINS ");
outtextxy(210,245," 0 EXIT APPLICATION");
outtextxy(230,383,"Enter Menu Option No: ");
gotoxy(52,25);cin>>ch;
switch(ch)
{
case 1: s.trinfo(); break;
case 2: s.new_trinfo(); break;
case 3: s.search(); break;
case 4: s.display_list(); break;
case 5: s.transaction(); break;
case 6: s.modify(); break;
case 7: s.pnrecord(); break;
case 8: s.close_account(); break;
case 9: s.codes(); break;
case 10: s.enqinfo(); break;
case 0: exit(0); break;
}
}
getch();
closegraph();
}
void desd()
{
getch();
setcolor(15);
gotoxy(20,23); cout<<"LOADING . . .";
for(int x1=170,x2=170,y1=310,y2=320,y=1,S=0;x1<470;x1++,x2++,y++,S++)
{
setcolor(4);
line (x1,y1,x2,y2);
int w=(x1-169)/3;
gotoxy(34,23); cout<<w<<"%";
delay(15);
}
gotoxy(28,23);
cout<<"COMPLETE "; gotoxy(20,25);
cout<<"PRESS ANY KEY TO CONTINUE ";
}
void IR:: codes()
{
IR ini;
int valid=0,ch,t;
char con;
clrscr();
cleardevice();
do
{
gotoxy(1,1);cout<<" Enter (0) to exit. ";
gotoxy(12,3);
printf("E N T E R S T A T I O N C O D E S I N F O R M A T I O N");
clear(5,19);clear(5,17);
fstream result,file;
result.open("codestn.txt",ios::app|ios::binary);
rectangle(90,60,550,410);

rectangle(90,100,550,370);
gotoxy(23,6); printf("C U R R E N T S T A T I O N I N F O");
t=last_accno();
t=t+1;
s.no=t;
gotoxy(15,8); cout<<"Serial No Code : "<<s.no;
gotoxy(15,10); cout<<"Station Code : ";
gotoxy(15,12); cout<<"Station Name: ";
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER CODE OF STATION:" ;
valid = 1 ;
gotoxy(30,10) ;
gets(s.code) ;
strupr(s.code) ;
if (s.code[0] == '0')
return ;
if (strlen(s.code) == 0 || strlen(s.code) > 25)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);
}while (!valid) ;
do
{
clear(15,25) ;
gotoxy(15,25) ;
cout <<"ENTER STATION NAME:";
valid = 1 ;
gotoxy(30,12) ;
gets(s.stn) ;
strupr(s.stn) ;
if (s.stn[0] == '0')
return ;
if (strlen(s.stn) == 0 || strlen(s.stn) > 100)
{
valid = 0 ;
gotoxy(5,23) ;
printf("NAME SHOULD NOT BE BLANK OR GREATER THAN 25") ;
getch() ;
}
fflush(stdin);
}while (!valid) ;
do
{
valid = 1 ;
gotoxy(15,20) ;
cout <<"Do you want to save the record (y/n) : " ;
ch = getche() ;
if(ch == '0')
return ;
ch = toupper(ch) ;
}while (!valid) ;
if(ch=='Y' || ch=='y')
{
result.write((char*)&s,sizeof(s));
result.close();

}
gotoxy(15,22) ;
printf("Want to continue (y/n): ");
con = getche() ;
con = toupper(con) ;
clear(15,20);clear(15,22);
clear(30,8);clear(30,10);clear(30,12);
}while(con=='y'|| con=='Y');
}
int IR :: last_accno(void)
{
fstream file ;
file.open("codestn.txt", ios::in|ios::binary);
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) &s, sizeof(s)))
count = s.no;
file.close();
return count;
}
void IR::enqinfo()
{
}

You might also like