Lodging Management
//*************************************************************************////-------------------------------------------------------------------------//
// -*- PROGRAM FOR HOTEL (i.e.,Lodging) MANAGEMENT. -*-
//-------------------------------------------------------------------------//
// -*- Language :- C & C++.
//-------------------------------------------------------------------------//
// -*- Compiler :- Turbo C & C++.
//-------------------------------------------------------------------------//
// -*- Designed by :- Vikrantsingh Bisen
//-------------------------------------------------------------------------//
//*************************************************************************//
/*-------------------------- Header Files -------------------------------*/
#include<iostream.h>
#include<fstream.h>
#include<graphics.h>
#include<process.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<time.h>
#include<dos.h>
void intro (void);
class Admin;
class customer;
class Staff;
class Extra;
class Room;
/*---------------------- Function using Class Object --------------------*/
void Fstaff(void);
void Fcustomer(void);
void Froom(void);
void Fextra(void);
/*------------------------- Classes -------------------------------------*/
class Admin
{
char mth_no[10],yr_no[10];
double wages,income,profit,loss,net_bill;
public:
Admin()
{
wages=income=profit=loss=net_bill=0;
}
void getS();
void putS();
friend void process();
};
void Admin::putS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(7,HORIZ_DIR,1);
outtextxy(70,222,"Income:"); gotoxy(40,15);cout<<income;
outtextxy(70,255,"Expenditure:"); gotoxy(40,17);cout<<net_bill;
outtextxy(70,285,"Wages:"); gotoxy(40,19);cout<<wages;
outtextxy(70,320,"Profit:"); gotoxy(40,21);cout<<profit;
outtextxy(70,350,"Loss:"); gotoxy(40,23);cout<<loss;
}
void Admin::getS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,190,"Enter Month no. & Year:");
gotoxy(45,14);
cin>>mth_no>>yr_no;
}
class Staff
{
private:
char cell[11],loc[20],city[21],post[10];
int age;
float sal;
public:
char name[20],surname[20];
void getS();
void putS();
friend void process(/*Admin &,Staff,customer*/);
};
void Staff::getS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(7,HORIZ_DIR,1);
outtextxy(70,222,"Name:"); gotoxy(40,15);cin>>name;
outtextxy(70,255,"Surname:"); gotoxy(40,17);cin>>surname;
outtextxy(70,285,"Age:"); gotoxy(40,19);cin>>age;
outtextxy(70,320,"Post:"); gotoxy(40,21);cin>>post;
outtextxy(70,350,"Salary:"); gotoxy(40,23);cin>>sal;
outtextxy(70,380,"Cell:"); gotoxy(40,25);cin>>cell;
outtextxy(70,410,"City:"); gotoxy(40,27);cin>>loc;
outtextxy(70,440,"State:"); gotoxy(40,29);cin>>city;
}
void Staff::putS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(7,HORIZ_DIR,1);
outtextxy(70,222,"Name:"); gotoxy(40,15);cout<<name;
outtextxy(70,255,"Surname:"); gotoxy(40,17);cout<<surname;
outtextxy(70,285,"Age:"); gotoxy(40,19);cout<<age;
outtextxy(70,320,"Post:"); gotoxy(40,21);cout<<post;
outtextxy(70,350,"Salary:"); gotoxy(40,23);cout<<sal;
outtextxy(70,380,"Cell:"); gotoxy(40,25);cout<<cell;
outtextxy(70,410,"City:"); gotoxy(40,27);cout<<loc;
outtextxy(70,440,"State:"); gotoxy(40,29);cout<<city;
}
class customer
{
private:
char cell[20],month_no[10],year[10],city[20],business[20],room_type[10],date[10],time[10];
int age,days;
float advance,balance;
public:
char room_no[10],name[20],surname[20];
void getS();
void putS();
friend void process(/*Admin &,Staff,customer*/);
};
void customer::getS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(11,HORIZ_DIR,1);
outtextxy(120,229,"Name:"); gotoxy(40,15);cin>>name;
outtextxy(120,245,"Surname:"); gotoxy(40,16);cin>>surname;
outtextxy(120,261,"Age:"); gotoxy(40,17);cin>>age;
outtextxy(120,277,"Buisness:"); gotoxy(40,18);cin>>business;
outtextxy(120,293,"Cell:"); gotoxy(40,19);cin>>cell;
outtextxy(120,309,"City:"); gotoxy(40,20);cin>>city;
outtextxy(120,325,"Room_no:"); gotoxy(40,21);cin>>room_no;
outtextxy(120,341,"Room_type:"); gotoxy(40,22);cin>>room_type;
outtextxy(120,357,"Date:"); gotoxy(40,23);cin>>date;
outtextxy(120,373,"Month no:"); gotoxy(40,24);cin>>month_no;
outtextxy(120,389,"Year:"); gotoxy(40,25);cin>>year;
outtextxy(120,405,"Time:"); gotoxy(40,26);cin>>time;
outtextxy(120,421,"No of Days:"); gotoxy(40,27);cin>>days;
outtextxy(120,437,"Advance:"); gotoxy(40,28);cin>>advance;
outtextxy(120,453,"Balance:"); gotoxy(40,29);cin>>balance;
}
void customer::putS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(11,HORIZ_DIR,1);
outtextxy(120,229,"Name:"); gotoxy(40,15);cout<<name;
outtextxy(120,245,"Surname:"); gotoxy(40,16);cout<<surname;
outtextxy(120,261,"Age:"); gotoxy(40,17);cout<<age;
outtextxy(120,277,"Buisness:"); gotoxy(40,18);cout<<business;
outtextxy(120,293,"Cell:"); gotoxy(40,19);cout<<cell;
outtextxy(120,309,"City:"); gotoxy(40,20);cout<<city;
outtextxy(120,325,"Room_no:"); gotoxy(40,21);cout<<room_no;
outtextxy(120,341,"Room_type:"); gotoxy(40,22);cout<<room_type;
outtextxy(120,357,"Date:"); gotoxy(40,23);cout<<date;
outtextxy(120,373,"Month no:"); gotoxy(40,24);cout<<month_no;
outtextxy(120,389,"Year:"); gotoxy(40,25);cout<<year;
outtextxy(120,405,"Time:"); gotoxy(40,26);cout<<time;
outtextxy(120,421,"No of Days:"); gotoxy(40,27);cout<<days;
outtextxy(120,437,"Advance:"); gotoxy(40,28);cout<<advance;
outtextxy(120,453,"Balance:"); gotoxy(40,29);cout<<balance;
}
class Extra
{
double l_bill,t_bill,ex_bill,bill;
public:
char emonth[10],eyear[10];
Extra()
{
l_bill=t_bill=ex_bill=bill=0;
}
void getS();
void putS();
friend void process();
};
void Extra::getS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(7,HORIZ_DIR,1);
outtextxy(70,222,"Month:"); gotoxy(40,15);cin>>emonth;
outtextxy(70,255,"Year:"); gotoxy(40,17);cin>>eyear;
outtextxy(70,285,"Light Bill:"); gotoxy(40,19);cin>>l_bill;
outtextxy(70,320,"Telephone Bill:"); gotoxy(40,21);cin>>t_bill;
outtextxy(70,350,"Extra Bill:"); gotoxy(40,23);cin>>ex_bill;
bill=l_bill+t_bill+ex_bill;
getch();
}
void Extra::putS()
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,180,"Record:");
setcolor(LIGHTGREEN);
settextstyle(7,HORIZ_DIR,1);
outtextxy(70,222,"Month:"); gotoxy(40,15);cout<<emonth;
outtextxy(70,255,"Year:"); gotoxy(40,17);cout<<eyear;
outtextxy(70,285,"Light Bill:"); gotoxy(40,19);cout<<l_bill;
outtextxy(70,320,"Telephone Bill:"); gotoxy(40,21);cout<<t_bill;
outtextxy(70,350,"Extra Bill:"); gotoxy(40,23);cout<<ex_bill;
outtextxy(70,380,"Net Bill:"); gotoxy(40,25);cout<<bill;
}
/*------------------- Friend Function --------------------------------*/
void process()
{
Admin a;
Staff so,sm,*sw,t;
customer *c,d;
Extra *e,ex;
fstream io;
int as,ss,cs,es,i;
/*--------- Reading Extra File------------------*/
io.open ("extra.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
es=(io.tellg()/sizeof(ex));
e=new Extra[es];
io.close();
io.open ("extra.txt",ios::in|ios::binary);
for(i=0;i<es;i++)
{
io.read((char*)&e[i],sizeof (ex));
}
io.close();
/*--------- Reading Customer File------------------*/
io.open ("customer.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
cs=(io.tellg()/sizeof(d));
c=new customer[cs];
io.close();
io.open ("customer.txt",ios::in|ios::binary);
for(i=0;i<cs;i++)
{
io.read((char*)&c[i],sizeof (d));
}
io.close();
/*--------- Reading Worker File------------------*/
io.open ("worker.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
ss=(io.tellg()/sizeof(t));
sw=new Staff[ss];
io.close();
io.open ("worker.txt",ios::in|ios::binary);
for(i=0;i<ss;i++)
{
io.read((char*)&sw[i],sizeof (t));
}
io.close();
/*------------- Reading Owner file ----------------*/
io.open ("owner.txt",ios::in|ios::binary);
io.read((char*)&so,sizeof (t));
io.close();
/*------------- Reading manager file ----------------*/
io.open ("manager.txt",ios::in|ios::binary);
io.read((char*)&sm,sizeof (t));
io.close();
/*--------------------------------------------------*/
a.getS();
a.wages=sm.sal+so.sal;
for(i=0;i<ss;i++)
{
a.wages+=sw[i].sal;
}
a.income=0;
for(i=0;i<cs;i++)
{
if(strcmp(a.mth_no,c[i].month_no)==0&&strcmp(a.yr_no,c[i].year)==0)
a.income+=c[i].advance+c[i].balance;
}
for(i=0;i<es;i++)
{
if(strcmp(a.mth_no,e[i].emonth)==0&&strcmp(a.yr_no,e[i].eyear)==0)
a.net_bill=e[i].bill;
}
a.profit=a.income-a.wages-a.net_bill;
if(a.profit<0)
{
a.loss=a.profit;
a.profit=0;
}
else
a.loss=0;
a.putS();
//delete sw;
//delete c;
//delete e;
getch();
}
/*-------------------Function for Designing Menu--------------------------*/
//void intro (void);
void enter(void);
void menu(void);
void soft(void);
void showtime()
{
char c;
char date[9],time[9];
_strdate(date);
c=date[0];
date[0]=date[3];
date[3]=c;
c=date[1];
date[1]=date[4];
date[4]=c;
_strtime(time);
gotoxy(50,2);
printf("Date:%s Time:%s",date,time);
}
/*--------------------- Function Main ------------------------------------*/
void main()
{
char pass[30];
int gd=DETECT,gm,i,j,ch;
initgraph(&gd,&gm,"c:\\tc\\bgi");
setbkcolor(BROWN);
setcolor(YELLOW);
soft();
enter();
while(1)
{
menu();
setcolor(LIGHTGREEN);
rectangle(290,425,340,450);rectangle(288,423,342,452);
while(!kbhit()){showtime();}
gotoxy(39,28);
ch=getch();
switch(ch)
{
case '1' :
process();
break;
case '2' :
Fstaff();
break;
case '3' :
Fcustomer();
break;
case '4' :
Froom();
break;
case '5' :
Fextra();
break;
case '6' :
cleardevice();
settextstyle(7,HORIZ_DIR,6);
outtextxy(50,50,"Thank");
outtextxy(50,100," You . . . ");
getch();
exit(0);
break;
default:
cout<<"Invalid";
}
} /*getch(); */
}
/*----------- Function to print Information Of Software ---------------*/
void soft()
{
int w;
settextstyle(7,HORIZ_DIR,6);
cleardevice();
setbkcolor(CYAN);
delay(1000);
outtextxy(50,100,"Loading");
delay(1000);
outtextxy(50,170," Software . . . ");
gotoxy(10,27);
cout<<"Please! Wait...";
setcolor(RED);
rectangle(199,249,501,271);rectangle(200,250,500,270);
setcolor(GREEN);
for(w=201;w<500;w++)
{
delay(20);
line(w,251,w,269);
}
setcolor(YELLOW);
cleardevice();
setbkcolor(CYAN);
delay(1000);
outtextxy(50,100,"The ");
delay(1000);
outtextxy(50,200," Data Base");
delay(1000);
outtextxy(50,300," Management");
//getch();
delay(1000);
cleardevice();
setbkcolor(CYAN);
settextstyle(7,HORIZ_DIR,6);
outtextxy(60,100,"Designed by...");
outtextxy(100,200,"Vikrantsingh Bisen");
delay(1000);
gotoxy(5,27);
cout<<"Please! Press Enter Key To Continue...";
getch();
}
/*-------------- Function For password -----------------------------------*/
void enter()
{
char pass[20];
int i=0;
while(1)
{
i++;
intro();
settextstyle(0, HORIZ_DIR, 2);
outtextxy(140,250,"Please! Enter Password");
setcolor(LIGHTGREEN);
rectangle(135,230,500,295);rectangle(134,229,501,296);
rectangle(250,330,405,360);rectangle(249,329,406,361);
gotoxy(35,22);
//scanf("%s\b",pass);
for(int j=0;j<5;j++)
{
pass[j]=getch();
printf("*");
}
pass[5]='\0';
if(strcmp(pass,"HOTEL")==0)
{
gotoxy(35,22);
cout<<"Success";
break;
}
else if(i!=3)
{
gotoxy(33,22);
cout<<"Invalid! Try Again";
getch();
}
else
exit(0);
}
}
/*------ Function To print Hotel Taj,Border And Background Color ---------*/
void intro()
{
char c[20];
//showtime();
cleardevice();
setbkcolor(BROWN);
//settextstyle(style, HORIZ_DIR, size);
setcolor(YELLOW);
settextstyle(4, HORIZ_DIR, 9);
setcolor(LIGHTGREEN);
outtextxy(130,17,"Hotel Taj");
setcolor(LIGHTRED);
settextstyle(7, HORIZ_DIR, 2);
outtextxy(456,140," V.M.Corporation.");
setcolor(LIGHTCYAN);
rectangle(454,138,634,170);
rectangle(1,2,638,174);
rectangle(5,6,634,170);
rectangle(1,174,638,474);
rectangle(5,178,634,470);
setcolor(WHITE);
rectangle(3,4,636,172);
rectangle(3,176,636,472);
setcolor(YELLOW);
showtime();
}
/*-------------------- Function of Main Menu ----------------------------*/
void menu()
{
char c;
intro();
gotoxy(100,175);
settextstyle(10, HORIZ_DIR,1);
setcolor(LIGHTCYAN);
outtextxy(220,180,"Well - Come");
setcolor(LIGHTGREEN);
rectangle(150,230,250,250);rectangle(148,228,252,252);
rectangle(380,230,480,250);rectangle(378,228,482,252);
rectangle(150,280,250,300);rectangle(148,278,252,302);
rectangle(380,280,480,300);rectangle(378,278,482,302);
rectangle(150,330,250,350);rectangle(148,328,252,352);
rectangle(380,330,480,350);rectangle(378,328,482,352);
setcolor(YELLOW);
settextstyle(11, HORIZ_DIR,0);
outtextxy(152,235," 1.Admin.");
outtextxy(382,235," 2.Staff.");
outtextxy(152,285," 3.Customer.");
outtextxy(382,285," 4.Rooms.");
outtextxy(152,335," 5.Extra.");
outtextxy(382,335," 6.Exit.");
settextstyle(10,HORIZ_DIR,1);
setcolor(LIGHTMAGENTA);
outtextxy(128,370,"Please! Enter Your Choise");
}
/*------------- Function For accesing Staff Information ---------------*/
void Fstaff()
{
intro();
int ch,ch2,ch3,f=0,m,i;
Staff x,*y;
fstream io,io1;
//gotoxy(10,15);
setcolor(LIGHTCYAN);
settextstyle(7,HORIZ_DIR,7);
outtextxy(45,180,"Record Of Staff");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(62,298," 1.Owner");
outtextxy(232,298," 2.Manager");
outtextxy(402,298," 3.Worker");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(50,280,200,325); rectangle(48,278,202,327);
rectangle(220,280,370,325);rectangle(218,278,372,327);
rectangle(390,280,540,325);rectangle(388,278,542,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
cin>>ch;
switch(ch)
{
case 1 : /*------------ Owner ------------------*/
intro();
setcolor(LIGHTCYAN);
settextstyle(7,HORIZ_DIR,7);
outtextxy(45,180,"Record Of Owner");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(62,298," 1.Edit");
outtextxy(232,298," 2.View");
outtextxy(402,298," 3.Back");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(50,280,200,325); rectangle(48,278,202,327);
rectangle(220,280,370,325);rectangle(218,278,372,327);
rectangle(390,280,540,325);rectangle(388,278,542,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
cin>>ch2;
switch(ch2)
{
case 1 :
io.open ("owner.txt",ios::out|ios::binary);
x.getS();
io.write((char *)&x,sizeof(x));
io.close();
break;
case 2 :
io.open ("owner.txt",ios::in|ios::binary);
io.read((char *)&x,sizeof(x));
x.putS();
getch();
io.close();
break;
default :
cout<<"Invalid choice";
}
break;
case 2 : /*------------------ Manager --------------------------*/
intro();
setcolor(LIGHTCYAN);
settextstyle(7,HORIZ_DIR,6);
outtextxy(25,180,"Record Of Manager");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(62,298," 1.Edit");
outtextxy(232,298," 2.View");
outtextxy(402,298," 3.Back");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(50,280,200,325); rectangle(48,278,202,327);
rectangle(220,280,370,325);rectangle(218,278,372,327);
rectangle(390,280,540,325);rectangle(388,278,542,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
cin>>ch2;
switch(ch2)
{
case 1 :
io.open ("manager.txt",ios::out|ios::binary);
x.getS();
io.write((char *)&x,sizeof(x));
io.close();
break;
case 2 :
io.open ("manager.txt",ios::in|ios::binary);
io.read((char *)&x,sizeof(x));
x.putS();
getch();
io.close();
break;
default :
cout<<"Invalid choice";
}
break;
case 3 : /*---------------- Worker ---------------------------*/
intro();
setcolor(LIGHTCYAN);
settextstyle(7,HORIZ_DIR,6);
outtextxy(25,180,"Record Of Worker");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(80,298," 1.Add");
outtextxy(190,298," 2.View");
outtextxy(300,298," 3.View All");
outtextxy(410,298," 4.Delete");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(75,280,175,325);rectangle(73,278,177,327);
rectangle(185,280,285,325);rectangle(183,278,287,327);
rectangle(295,280,395,325);rectangle(293,278,397,327);
rectangle(405,280,505,325);rectangle(403,278,507,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
//cout<<"1.Add 2.Edit 3.View 4.View All 5.Delete";
cin>>ch2;
char nm[20],sr[20];
if(ch2==1) // case 1 :
{
io.open ("worker.txt",ios::binary|ios::app);
io.seekp(0,ios::end);
x.getS();
io.write((char*)&x,sizeof(x));
io.close();
intro();
settextstyle(0,HORIZ_DIR,2);
outtextxy(10,280,"Record successfully Added");
getch();
//cout<<"Succesfully Added";
}
else if (ch2==2)
{
io.open ("worker.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new Staff[m];
io.close();
io.open ("worker.txt",ios::in|ios::binary);
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,190,"Enter Name & Surname:");
//cout<<"Enter name & surname";
gotoxy(45,14);
cin>>nm>>sr;
f=0;
for(i=0;i<m;++i)
{
io.read((char*)&y[i],sizeof(x));
if(strcmp(nm,y[i].name)==0&&strcmp(sr,y[i].surname)==0)
{
y[i].putS();
getch();
f=1;
break;
}
}
if(f==0)
outtextxy(10,280," Sorry! Record Not Found");
getch();
io.close();
}
else if (ch2==3)
{
io.open ("worker.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new Staff[m];
io.close();
io.open ("worker.txt",ios::in|ios::binary);
for(i=0;i<m;++i)
{
io.read((char *)&y[i],sizeof(x));
//y[i].putS();
//getch();
}
for(i=m-1;i>=0;i--)
{
y[i].putS();
getch();
//cleardevice();
}
io.close();
//exit(0);
}
else if (ch2==4)
{
io.open ("worker.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new Staff[m];
io.close();
io.open ("worker.txt",ios::in|ios::binary);
io1.open ("temp.txt",ios::out|ios::binary);
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,190,"Enter Name & Surname:");
gotoxy(45,14);
// cout<<"Enter name & surname";
cin>>nm>>sr;
f=0;
for(i=0;i<m;i++)
{
io.read((char *)&y[i],sizeof(x));
if(strcmp(nm,y[i].name)!=0&&strcmp(sr,y[i].surname)!=0)
io1.write((char *)&y[i],sizeof(x));
else
f++;
}
io.close();
io1.close();
io.open ("worker.txt",ios::out|ios::binary);
io1.open ("temp.txt",ios::in|ios::binary);
for(i=0;i<m-f;i++)
{
io1.read((char *)&y[i],sizeof(x));
io.write((char *)&y[i],sizeof(x));
}
if(f==0)
outtextxy(10,280," Sorry! Record Not Found");
else
outtextxy(10,280,"Record successfully deleted");
getch();
io.close();
io1.close();
}
else
cout<<"Invalid choice";
break;
default:
cout<<"Invalid choice";
}
////delete y;
}
void Fcustomer(void)
{
int ch2,i,f=0,f2,m;
fstream io,io1;
customer x,*y;
intro();
setcolor(LIGHTCYAN);
settextstyle(7,HORIZ_DIR,6);
outtextxy(25,180,"Record Of Customer");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(80,298," 1.Add");
outtextxy(190,298," 2.View");
outtextxy(300,298," 3.View All");
outtextxy(410,298," 4.Delete");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(75,280,175,325);rectangle(73,278,177,327);
rectangle(185,280,285,325);rectangle(183,278,287,327);
rectangle(295,280,395,325);rectangle(293,278,397,327);
rectangle(405,280,505,325);rectangle(403,278,507,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
cin>>ch2;
char nm[20],sr[20],rn[10];
if(ch2==1)
{
io.open ("customer.txt",ios::binary|ios::app);
io.seekp(0,ios::end);
x.getS();
io.write((char*)&x,sizeof(x));
io.close();
getch();
// cout<<"Succesfully Added";
}
else if (ch2==2)
{
io.open ("customer.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new customer[m];
io.close();
io.open ("customer.txt",ios::in|ios::binary);
intro();
settextstyle(10,HORIZ_DIR,1);
setcolor(LIGHTCYAN);
outtextxy(10,200,"Enter Your Choise For Search");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(62,298," 1.Name");
outtextxy(232,298," 2.Room no");
outtextxy(402,298," 3.Back");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(50,280,200,325); rectangle(48,278,202,327);
rectangle(220,280,370,325);rectangle(218,278,372,327);
rectangle(390,280,540,325);rectangle(388,278,542,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
cin>>f2;
//cout<<"What u wanna Enter 1.Name&surname or 2.Room no";
//cin>>f2;
if(f2==1)
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,200,"Enter Name & Surname:");
gotoxy(45,15);
cin>>nm>>sr;
}
else
{
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,200,"Enter Room no:");
gotoxy(35,15);
cin>>rn;
}
f=0;
for(i=0;i<m;i++)
{
io.read((char*)&y[i],sizeof(x));
}
for(i=m-1;i>=0;i--)
{
if(f2==1)
{
if(strcmp(nm,y[i].name)==0&&strcmp(sr,y[i].surname)==0)
{
y[i].putS();
f=1;
break;
}
}
else
{
if(strcmp(y[i].room_no,rn)==0)
{
y[i].putS();
f=1;
break;
}
}
}
if(f==0)
outtextxy(10,300,"SORRY! Record Not Found");
io.close();
getch();
}
else if (ch2==3)
{
io.open ("customer.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new customer[m];
io.close();
io.open("customer.txt",ios::in|ios::binary);
for(i=0;i<m;i++)
{
io.read((char *)&y[i],sizeof(x));
}
for(i=m-1;i>=0;i--)
{
y[i].putS();
getch();
}
io.close();
getch();
}
else if (ch2==4)
{
io.open ("customer.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new customer[m];
io.close();
io.open ("customer.txt",ios::in|ios::binary);
io1.open ("temp.txt",ios::out|ios::binary);
intro();
settextstyle(10,HORIZ_DIR,1);
setcolor(LIGHTCYAN);
outtextxy(10,200,"Enter name & surname:");
gotoxy(45,15);
cin>>nm>>sr;
f=0;
for(i=0;i<m;i++)
{
io.read((char *)&y[i],sizeof(x));
if(strcmp(nm,y[i].name)!=0&&strcmp(sr,y[i].surname)!=0)
io1.write((char *)&y[i],sizeof(x));
else
f++;
}
io.close();
io1.close();
io.open ("customer.txt",ios::out|ios::binary);
io1.open ("temp.txt",ios::in|ios::binary);
for(i=0;i<m-f;i++)
{
io1.read((char *)&y[i],sizeof(x));
io.write((char *)&y[i],sizeof(x));
}
if(f==0)
outtextxy(10,380,"SORRY! Record Not Found");
else
outtextxy(10,380,"Record Successfully Deleted");
getch();
io.close();
io1.close();
}
else
cout<<"Invalid choice";
//delete y;
}
void Froom(void)
{
int ch2,i,f=0,f2,m;
fstream io,io1;
customer x,*y;
char rn[10];
io.open ("customer.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(x));
y=new customer[m];
io.close();
io.open ("customer.txt",ios::in|ios::binary);
intro();
setcolor(LIGHTCYAN);
settextstyle(10,HORIZ_DIR,1);
outtextxy(10,183,"Enter Room no:");
while(!kbhit()){showtime();}
gotoxy(30,14);
cin>>rn;
f=0;
for(i=0;i<m;i++)
{
io.read((char*)&y[i],sizeof(x));
}
for(i=m-1;i>=0;i--)
{
if(strcmp(y[i].room_no,rn)==0)
{
y[i].putS();
f=1;
break;
}
}
if(f==0)
outtextxy(10,300,"SORRY! Record Not Found");
while(!kbhit()){showtime();}
getch();
io.close();
//delete y;
}
void Fextra()
{
fstream io;
Extra *e,f;
int m,i,ch,p=0;
char mn[10],yr[10];
//cout<<"1.Add 2.Veiw 3.Veiw All 4.Delete";
intro();
setcolor(LIGHTCYAN);
settextstyle(7,HORIZ_DIR,5);
outtextxy(35,195,"Record Of Various Bills");
setcolor(YELLOW);
settextstyle(11,HORIZ_DIR,25);
outtextxy(80,298," 1.Add");
outtextxy(190,298," 2.View");
outtextxy(300,298," 3.View All");
outtextxy(410,298," 4.Delete");
setcolor(YELLOW);
settextstyle(0,HORIZ_DIR,2);
outtextxy(150,350,"Enter your choice");
setcolor(LIGHTGREEN);
rectangle(75,280,175,325);rectangle(73,278,177,327);
rectangle(185,280,285,325);rectangle(183,278,287,327);
rectangle(295,280,395,325);rectangle(293,278,397,327);
rectangle(405,280,505,325);rectangle(403,278,507,327);
rectangle(270,395,320,420);rectangle(268,393,322,422);
while(!kbhit()){showtime();}
gotoxy(37,26);
cin>>ch;
switch(ch)
{
case 1 :
io.open("extra.txt",ios::app|ios::binary);
f.getS();
io.write((char*)&f,sizeof(f));
io.close();
break;
case 2 :
io.open("extra.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(f));
io.close();
e=new Extra[m];
io.open("extra.txt",ios::in|ios::binary);
for(i=0;i<m;i++)
{
io.read((char*)&e[i],sizeof(f));
}
intro();
settextstyle(10,HORIZ_DIR,1);
setcolor(LIGHTCYAN);
outtextxy(10,200,"Enter Month no & Year:");
while(!kbhit()){showtime();}
gotoxy(45,15);
cin>>mn>>yr;
for(i=0;i<m;i++)
{
if(strcmp(mn,e[i].emonth)==0&&strcmp(yr,e[i].eyear)==0)
{
e[i].putS();
getch(); p=1;
break;
}
}
if(p==0)
outtextxy(10,300,"SORRY! Record Not Found");
io.close();
break;
case 3 :
io.open("extra.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(f));
io.close();
e=new Extra[m];
io.open("extra.txt",ios::in|ios::binary);
for(i=0;i<m;i++)
{
io.read((char*)&e[i],sizeof(f));
e[i].putS();
getch();
}
io.close();
break;
case 4 :
io.open("extra.txt",ios::app|ios::binary);
io.seekg(0,ios::end);
m=(io.tellg()/sizeof(f));
io.close();
e=new Extra[m];
io.open("extra.txt",ios::in|ios::binary);
for(i=0;i<m;i++)
{
io.read((char*)&e[i],sizeof(f));
}
io.close();
io.open("extra.txt",ios::out|ios::binary);
intro();
settextstyle(10,HORIZ_DIR,1);
setcolor(LIGHTCYAN);
while(!kbhit()){showtime();}
outtextxy(10,200,"Enter Month no & Year:");
gotoxy(45,15);
cin>>mn>>yr;
p=0;
for(i=0;i<m;i++)
{
if(strcmp(mn,e[i].emonth)!=0&&strcmp(yr,e[i].eyear)!=0)
{
io.write((char*)&e[i],sizeof(f));
}
else
p=1;
}
if(p==0)
outtextxy(10,300,"SORRY! Record Not Found");
io.close();
break;
default:
outtextxy(10,300,"SORRY! Invalid choice");
}
//delete e;
}
No comments:
Post a Comment