Tuesday, 3 March 2015

PROJECT ON HOTEL MANAGEMENT


#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>
#include<ctype.h>
#include<dos.h>
#include<stdlib.h>
#include<graphics.h>
#include<process.h>

fstream file;
int count=0;
struct date d;
struct time t;
int search_room(int n);
void facilities( );
int menu( );
void showbill( );
float facilitybill(int);
int see_menu( );
int res_menu( );
int del_menu( );
void booked(char ch[20]);
int empty_room(int n);
void dance(int n);
void seebill(char*,float,int,int,int,int,float,char*,long);
int cal_days(int,int,int,int,int,int,int,int);
void curtain( );
void arun(int n)
 {
  cout<<"\n";
  cout<<"\n";
  textcolor(n);
  cout<<"\t\t*******************************************\n";
  cout<<"\t\t";
  cputs("       PROJECT ON HOTEL MANAGEMENT");
  cout<<"\n\t\t";
  cputs("     MADE BY CHANDRA PRAKASH ");
  cout<<"\n\t\t*******************************************"<<endl;
 }
void arun1( )
 {
  cout<<"\n";
  cout<<"\n";
  cout<<"\n";
  cout<<"\n";
 }
/**********************************************************/
/*********************WELCOME FUNCTION ********************/
void welcome( )
 {
  getch( );
  int gdriver = EGA, gmode = EGAHI, errorcode;
  int color=1, x=60, y=90,mc,style=1,size=5;
  char msg[80];
  initgraph(&gdriver, &gmode, " ");
  errorcode = graphresult( );
  if (errorcode != grOk)
   {
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch( );
exit(1);
   }
  mc=getmaxcolor( );
  cleardevice( );
  for(;!kbhit( );color++)
   {
if(color>mc)
 color=1;
delay(500);
setcolor(color);
    style=1;size=5;x=60;y=90;
settextstyle(style, HORIZ_DIR, size);
sprintf(msg, "WELCOME TO HOTEL TAJ");
outtextxy(x, y, msg);
    x=30;y=160;
sprintf(msg, "WE WISH YOU HAPPY STAY.");
outtextxy(x, y, msg);
    style=3;size=1;x=320;y=320;
    settextstyle(style, HORIZ_DIR, size);
    sprintf(msg, "PRESS ANY KEY TO CONTINUE.....");
outtextxy(x, y, msg);
    delay(650);
   }
  closegraph( );
 }
/*************************************************************/
/********************FUNCTION DANCE **************************/
void dance(int n)
 {
  clrscr( );
  arun(n);
  arun1( );
  if(n==1)
   {
    cout<<"\t\t\t\t  o  "<<endl;
    cout<<"\t\t\t\t ^|\\"<<endl;
    cout<<"\t\t\t\t  /\\";
   }
  if(n==2)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t ^|^"<<endl;
    cout<<"\t\t\t\t  >\\";
   }
  if(n==3)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t v|^"<<endl;
    cout<<"\t\t\t\t /< ";
   }
  if(n==4)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t v|^"<<endl;
    cout<<"\t\t\t\t >\\";
   }
  if(n==5)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t |/^"<<endl;
    cout<<"\t\t\t\t /< ";
   }
  if(n==6)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t |-|"<<endl;
    cout<<"\t\t\t\t >\\";
   }
  if(n==7)
   {
    cout<<"\t\t\t\t <o "<<endl;
    cout<<"\t\t\t\t \\|"<<endl;
    cout<<"\t\t\t\t /< ";
   }
  if(n==8)
   {
    cout<<"\t\t\t\t <o>"<<endl;
    cout<<"\t\t\t\t  | "<<endl;
    cout<<"\t\t\t\t >\\";
   }
  if(n==9)
   {
    cout<<"\t\t\t\t  o>"<<endl;
    cout<<"\t\t\t\t \\ "<<endl;
    cout<<"\t\t\t\t /< ";
   }
  if(n==10)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t  x "<<endl;
    cout<<"\t\t\t\t >\\";
   }
  if(n==11)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t </ "<<endl;
    cout<<"\t\t\t\t /< ";
   }
  if(n==12)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t <|>"<<endl;
    cout<<"\t\t\t\t >\\";
   }
  if(n==13)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t </>"<<endl;
    cout<<"\t\t\t\t /< ";
   }
  if(n==14)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t<\\>"<<endl;
    cout<<"\t\t\t\t >\\";
   }
  if(n==15)
   {
    cout<<"\t\t\t\t  o "<<endl;
    cout<<"\t\t\t\t <)>"<<endl;
    cout<<"\t\t\t\t  >>";
   }
  }
/*************************************************************/
/**********************CLASS HOTEL****************************/
class hotel
 {
  public:
         char cth,ctm,cts,cdd,cdm,lth,ltm,lts,ldd,ldm;
         int cdy,ldy;
         char name[50],status,add[100];
         int type, room_no,gno,empty;
         void readdata( );
         void showdata( );
         void modification( );
         void del( );
 };
/**********************************************************/
/******************INPUT DATA FUNCTION*********************/
void hotel::readdata( )
 {
  clrscr( );
  cout<<"\t \t \t ENTER RECORD OF GUEST NO."<<++count;
  gno=count;
  cout<<"\n\t \t \t ENTER THE NAME......";
  gets(name);
  cout<<"\n\t \t \t ENTER ADDRESS.......";
  gets(add);
  la:
  cout<<"\n\t \t \t ENTER THE SUITE TYPE(1, 2, 3, OR 4) ";
  cin>>type;
  cout<<"\n\t \t \t ENTER THE ROOM No........... "
 <<"\n\t \t \t PRESS ANY KEY TO SEE THE LIST OF EMPTY ROOM...";
  getch( );
  empty=empty_room(type);
  if(empty==0)
   {
cout<<"\n SORRY THERE IS NO ROOM VACANT IN THIS SUITE "
<<"\n DO U WANT TO CHANGE THE SUITE "
<<"\n IF YES THEN PRESS Y OTHERWISE PRESS N ";
char ch=getch( );
cout<<ch;
if(ch=='Y'|| ch=='y')
goto la;
else
goto lo;
   }
  getch( );
  cin>>room_no;
  getdate(&d);
  cdy=d.da_year;
  cdd=d.da_day;
  cdm=d.da_mon;
  gettime(&t);
  cth=t.ti_hour;
  ctm=t.ti_min;
  cts=t.ti_sec;
  status=' ';
  lo:
 }
/*************************************************************/
/*****************SHOW DATA **********************************/
void hotel :: showdata( )
 {
  clrscr( );
  cout<<"\t \t \t GUEST NO......";
  cout<<gno;
  cout<<"\n\t \t \t NAME......";
  puts(name);
  cout<<"\n\t \t \t ADDRESS.......";
  puts(add);
  cout<<"\n\t \t \t THE SUITE TYPE......";
  cout<<type;
  cout<<"\n\t \t \t ROOM No. OF GUEST IS......"
 <<room_no;
  cout<<"\n\t \t \t coming date is......";
  printf("%2d:%02d:%02d",cdd,cdm,cdy);
  cout<<"\n\t \t \t arrival time is.....";
  printf("%2d:%02d:%02d",cth,ctm,cts);
  if(status=='*')
   {
cout<<"\n\t \t \t leaving date is......";
printf("%2d:%02d:%02d",ldd,ldm,ldy);
cout<<"\n\t \t \t departureal time is.....";
printf("%2d:%02d:%02d",lth,ltm,lts);
   }
 }
/*************************************************************/
/*****************MODIFICATION FUNCTION***********************/
void hotel::modification ( )
 {
  char nm[20],ad[40];int rono;
  cout<<"\n IF U WANT TO RETAIN OLD NAME AND ADDRESH "
 <<"THEN SIMPLY PRESS ENTER "
 <<"\n TO RETAIN OLD ROOM NO, ENTER 0 "
 <<"\n NAME ";
  gets(nm);
  cout<<"\n addresh ";
  gets(ad);
  cout<<"\n LIST OF EMPTY ROOM IS.........";
  empty=empty_room(type);
  if(!empty)
   {
cout<<"\n SORRY THERE IS NO ROOM ";
rono=0;
goto la;
   }
  cout<<"\n ROOM NO ";
  cin>>rono;
  la:
  if(strlen(nm)!=0)
   strcpy(name,nm);
  if(strlen(ad)!=0)
   strcpy(add,ad);
  if(rono!=0)
   room_no=rono;
 }
/*************************************************************/
/*******************DELETE FUNCTION***************************/
void hotel::del( )
 {
  getdate(&d);
  ldy=d.da_year;
  ldd=d.da_day;
  ldm=d.da_mon;
  gettime(&t);
  lth=t.ti_hour;
  ltm=t.ti_min;
  lts=t.ti_sec;
  status='*';
 }
/*************************************************************/
/*********************STRUCTURE DATE**************************/
struct DA
 {
  int dd,dm,dy;
 };
DA read_date(char *ty);
void ret_amount(DA fg,int ty, int td);
/*************************************************************/
/************************CLASS BAN_CON************************/
class ban_con
 {
  public:
char name[30],add[50],type[20],sta;
int td;
         DA fd,tod;
         ban_con(char*s)
          {
           strcpy(type,s);
          }
void input_data();
         void show( )
 {
           clrscr( );
  cout<<"\n NAME ";
  puts(name);
  cout<<"\n ADDRESS ";
  puts(add);
           cout<<"\n TOTAL DAY "<<td
               <<"\n BOOKING DATE "
               <<"\n FROM ";
           printf("%2d:%02d:%02d",fd.dd,fd.dm,fd.dy);
           if(td>1)
            {
             cout<<"\t TO \t";
             printf("%2d:%02d:%02d",tod.dd,tod.dm,tod.dy);
            }
           cout<<"\n";
           getch( );
          }
         void del( )
          {
           sta='*';
          }
  };
/*************************************************************/
/*********************INPUT DATA FUNCTION*********************/
void ban_con :: input_data( )
 {
  cout<<"\n ENTER YOUR NAME ";
  gets(name);
  cout<<"\n ENTER YOUR ADRESS ";
  gets(add);
  cout<<"\n ENTER TOTAL DAY OF BOOKING ";
  cin>>td;
  cout<<"\n ENTER THE DATE OF BOOKING ";
  fd=read_date(type);
  if(td>1)
   {
    cout<<"\n ENTER THE LAST DATE ";
    tod=read_date(type);
   }
  sta=' ';
 }
/*************************************************************/
/********************FUNCTION READ DATE***********************/
DA read_date(char*ty)
 {
  DA d1; int yy; ban_con b1(ty);
  char ch;
  cout<<"\n BOOKED DATES ARE ";
  booked(b1.type);
  lo:
  cout<<"\n ENTER THE DATE (yyyy/mm/dd) ";
  cin>>d1.dy>>ch>>d1.dm>>ch>>d1.dd;
  getdate(&d);
  yy=d.da_year;
  while(d1.dy<yy||d1.dy>(yy+1))
   {
    cout<<"\n ENTER CORRECT YEAR ";
    cin>>d1.dy;
   }
  if(d1.dm>12)
   {
    cout<<"\n ENTER CORRECT DATE ";
    clrscr( );
    goto lo;
   }
  if(d1.dm==2)
   {
    if(d1.dy%4==0)
     {
      if(d1.dd>29)
       {
        cout<<"\n ENTER CORRECT DATE ";
        clrscr( );
        goto lo;
       }
     }
    else
     {
      if(d1.dd>28)
       {
        cout<<"\n ENTER CORRECT DATE ";
        clrscr( );
        goto lo;
       }
     }
   }
  else
   {
    if(d1.dm==4||d1.dm==6||d1.dm==9||d1.dm==11)
     {
      if(d1.dd>30)
       {
        cout<<"\n ENTER CORRECT DATE ";
        clrscr( );
        goto lo;
       }
     }
    else
     {
      if(d1.dd>31)
       {
        cout<<"\n ENTER CORRECT DATE ";
        clrscr( );
        goto lo;
       }
     }
   }
  return d1;
 }
/*************************************************************/
/***********************FUNCTION BOOKED***********************/
void booked(char type[20])
 {
   fstream fil;  ban_con ba(type);
   char cdd,cdm,*p;
   int dy,dd,dm;
   getdate(&d);
   dy=d.da_year;
   cdd=d.da_day;
   cdm=d.da_mon;
   p=&cdd; dd=atoi(p);
   p=&cdm; dm=atoi(p);
   fil.open("ban&con.dat",ios::out|ios::ate|ios::in|ios::binary);
   if(!fil)
    {
     cout<<"\n file cant be open ";
     getch( );
     exit(0);
    }
   fil.seekg(0,ios::end);
   int f=fil.tellg( );
   int count=f/sizeof(ba);
   if(!count)
    cout<<"\n NOT BOOKED TILL NOW ";
   else
    {
     count=0;
     fil.seekg(0,ios::beg);
     while(fil.read((char*)&ba,sizeof(ba)))
      {
       if((strcmp(type,ba.type)==0)&&ba.sta!='*')
        {
         if(dd<=ba.fd.dd||dm<ba.fd.dm||dy<ba.fd.dy)
          {
           cout<<"\n ";
           printf("%2d:%02d:%02d",ba.fd.dd,ba.fd.dm,ba.fd.dy);
           if(ba.td>1)
            {
             cout<<"\t TO \t";
             printf("%2d:%02d:%02d",ba.tod.dd,ba.tod.dm,ba.tod.dy);
       }
           count++;
          }
         else
          {
           if(ba.td>1)
            {
             if(dd<=ba.tod.dd||dm<ba.tod.dm||dy<ba.tod.dy)
              {
               cout<<"\n ";
               printf("%2d:%02d:%02d",ba.fd.dd,ba.fd.dm,ba.fd.dy);
               cout<<"\t TO \t";
               printf("%2d:%02d:%02d",ba.tod.dd,ba.tod.dm,ba.tod.dy);
         }
            }
          }
        }
      }
     if(!count)
      cout<<"\n NOT BOOKED FOR ANY DAY";
    }
   fil.clear( );
   fil.close( );
   getch( );
  }
/*************************************************************/
/*********************EMPTY ROOM FUNCTION*********************/
int empty_room(int ty)
 {
  int i=0,j=0,flag=0,empty=0;
  fstream fil;
  hotel gues;
  fil.open("record.dat",ios::out|ios::app|ios::in|ios::binary);
  if(ty==1)
   {
i=1;j=101;
   }
  if(ty==2)
   {
i=101;j=251;
   }
  if(ty==3)
   {
i=251;j=451;
   }
  if(ty==4)
   {
i=451;j=700;
   }
  for(;i<j;i++)
   {
fil.seekg(0,ios::beg);
while(!fil.eof( ))
{
 fil.read((char*)&gues,sizeof(gues));
 if(gues.status!='*'&& gues.room_no==i)
  {
flag=0;
fil.seekg(0,ios::end);
  }
 else
  flag=1;
}
if(flag==1)
{
 if(i<10)
  cout<<"0";
 cout<<i;
 if(i<100)
  cout<<"   ";
 else
  cout<<"  ";
 empty=i;
}
fil.clear( );
   }
  return empty;
 }
/*************************************************************/
/***************MAIN FUNCTION*********************************/
void main( )
 {
  clrscr( );  int df=2;
  while(!kbhit( ))
   {
    dance(df);
    gotoxy(15,18);
    cout<<"PRESS ANY KEY TO CONTINUE..............";
    delay(600);
    df++;
    if(df>15)
     df=2;
   }
  hotel guest;
  fstream fil;ban_con ban("banquet hall");
  int choice;ban_con con("conference hall");
  file.open("record.dat",ios::out|ios::ate|ios::in|ios::binary);
  if(!file)
   {
cout<<"\n file cant be open ";
getch( );
    exit(0);
   }
  int offset,temp,flag;
  file.seekg(0,ios::end);
  int file_size=file.tellg( );
  count=file_size/sizeof(guest);
  welcome( );
  cout<<"\n\t \t \t PRESS ENTER TO SEE FACILITIES..........";
  facilities( );
  do
   {
clrscr( );
lo:
choice=menu( );
switch(choice)
 {
  case 1:
 clrscr( );
 int m=res_menu( );
 if(m==1)
  {
cout<<"\n Plz ENTER THE INFORMATION OF GUEST..";
cout<<"\n PRESS ANY KEY.......................";
getch( );
guest.readdata( );
if(guest.empty!=0)
file.write((char*)&guest,sizeof(guest)) ;
  }
              if(m==2||m==3)
               {
                fil.open("ban&con.dat",ios::out|ios::ate|ios::in|ios::binary);
                if(!fil)
                 {
                  cout<<"\n fil cant be open ";
                  getch( );
                  exit(0);
                 }
   if(m==2)
                 {
                  ban.input_data( );
                  fil.write((char*)&ban,sizeof(ban));
                  cout<<"\n\n\n PAYBLE AMOUNT IS Rs. "<<(ban.td*5000);
                  getch( );
                 }
                if(m==3)
                 {
                  con.input_data( );
                  fil.write((char*)&con,sizeof(con));
                  cout<<"\n\n\n PAYBLE AMOUNT IS Rs. "<<(con.td*2500);
                  getch( );
                 }
                fil.close( );
               }
 break;
  case 2:
              m=see_menu( );
              if(m==1)
               {
       clrscr( );
   int n,guestno;
       cout<<"\n\n\n\t\t\t"
       <<"menu"
   <<"\n\n\n\n"
    <<"1.TO SEE RECORD OF ONE GUEST\n"
   <<"2.TO SEARCH THE RECORD OF GUEST (BY NAME)\n"
   <<"3.TO SEE ENTIRE RECORD\n"
   <<"4.TO SEE RECORD OF GEUEST CURRENTLY STAYING IN HOTEL\n"
   <<"ENTRE YOUR CHOICE\n";
   cin>>n;
   if(n==1)
    {
     file.seekg(0);
     cout<<"\n \t ENTER GUEST NO";
 cin>>guestno;
 if(!count|| guestno>count)
  {
   clrscr( );
   cout<<"\n\t THE RECORD DOES NOT EXIT"
   <<"\n\t PRESS ANY KEY TO SEE MENU";
   getch( );
  }
 else
  {
   offset=((guestno-1)*sizeof(guest));
                    file.seekg(offset,ios::beg);
   file.read((char*)&guest, sizeof(guest));
   guest.showdata( );
   getch( );
  }
    }
   if(n==2)
    {
     char na[30];
     cout<<"\n ENTER THE NAME OF GUEST ";
 gets(na);
 file.seekg(0,ios::beg);
 while(file.read((char*)&guest,sizeof(guest)))
  {
   if(na==guest.name)
    guest.showdata( );
   getch( );
  }
 file.clear( );
    }
   if(n==3)
    {
     clrscr( );
 file.seekg(0);
 while(file.read((char*)&guest,sizeof(guest)))
  {
   guest.showdata( );
   getch( );
  }
 file.clear( );
    }
   if(n==4)
    {
     clrscr( );
 file.seekg(0);
 while(file.read((char*)&guest,sizeof(guest)))
  {
   if(guest.status=='*')
   goto la;
   guest.showdata( );
   getch( );
   la:
  }
 file.clear( );
    }
   if(n<1 || n>4)
    {
     clrscr( );
 cout<<"\n\t WRONG CHOICE ENTERED \nPRESS ANY KEY";
 getch( );
    }
               }
              if(m==2||m==3)
               {
                fil.open("ban&con.dat",ios::out|ios::ate|ios::in|ios::binary);
                if(m==2)
                 {
                  int n;
                  char ty[]="banquet hall";
                  cout<<"\n \t\t\t\t****MENU****"
                      <<"\n 1. TO SEE ONLY ONE RECORD "
                      <<"\n 2. TO SEE ENTIRE RECORD "
                      <<"\n 3. TO SEE ONLY CURENT RECORD"
                      <<"\n ENTER YOUR CHOICE ";
                  cin>>n;
                  if(n==1)
                   {
                    char na[30];
       cout<<"\n ENTER THE NAME OF PERSON ";
                    gets(na);
   fil.seekg(0,ios::beg);
       while(fil.read((char*)&ban,sizeof(ban)))
    {
     if(strcmp(na,ban.name)==0&&strcmp(ty,ban.type)==0
                             &&ban.sta!='*')
      ban.show( );
    }
   fil.clear( );
      }
                  if(n==2)
                   {
       clrscr( );
   fil.seekg(0);
   while(fil.read((char*)&ban,sizeof(ban)))
    {
                      if(strcmp(ty,ban.type)==0&&ban.sta!='*')
      ban.show( );
            }
   fil.clear( );
      }
                  if(n==3)
                   {
                    char cdd,cdm,*p;
                    int dy,dd,dm;
                    getdate(&d);
                    dy=d.da_year;
                    cdd=d.da_day;
                    cdm=d.da_mon;
                    p=&cdd; dd=atoi(p);
                    p=&cdm; dm=atoi(p);
                    clrscr( );
   fil.seekg(0);
   while(fil.read((char*)&ban,sizeof(ban)))
    {
                      if(ban.td>1)
                       {
                        if(dd<=ban.tod.dd||dm<ban.tod.dm||dy<ban.tod.dy)
                         {
                          if(strcmp(ty,ban.type)==0&&ban.sta!='*')
          ban.show( );
                         }
                       }
                      else
                       {
                        if(dd<=ban.fd.dd||dm<ban.fd.dm||dy<ban.fd.dy)
                         {
                          if(strcmp(ty,ban.type)==0&&ban.sta!='*')
          ban.show( );
                         }
                       }
            }
   fil.clear( );
      }
                  if(n<1||n>3)
                   {
                    cout<<"\n WRONG CHOICE ENTERED ";
                   }
                 }
                if(m==3)
                 {
                  int n;
                  char ty[]="conference hall";
                  cout<<"\n \t\t\t\t****MENU****"
                      <<"\n 1. TO SEE ONLY ONE RECORD "
                      <<"\n 2. TO SEE ENTIRE RECORD "
                      <<"\n 3. TO SEE ONLY CURENT RECORD "
                      <<"\n ENTER YOUR CHOICE ";
                  cin>>n;
                  if(n==1)
                   {
                    char na[30];
       cout<<"\n ENTER THE NAME OF PERSON ";
       gets(na);
   fil.seekg(0,ios::beg);
   while(fil.read((char*)&con,sizeof(con)))
    {
     if(strcmp(na,con.name)==0&&strcmp(ty,con.type)==0
                              &&con.sta!='*')
      con.show( );
    }
   fil.clear( );
      }
                  if(n==2)
                   {
       clrscr( );
   fil.seekg(0);
   while(fil.read((char*)&con,sizeof(con)))
    {
                      if(strcmp(ty,con.type)==0&&con.sta!='*')
      con.show( );
    }
   fil.clear( );
      }
                  if(n==3)
                   {
                    char cdd,cdm,*p;
                    int dy,dd,dm;
                    getdate(&d);
                    dy=d.da_year;
                    cdd=d.da_day;
                    cdm=d.da_mon;
                    p=&cdd; dd=atoi(p);
                    p=&cdm; dm=atoi(p);
                    clrscr( );
   fil.seekg(0);
   while(fil.read((char*)&con,sizeof(con)))
    {
                      if(ban.td>1)
                       {
                        if(dd<=con.tod.dd||dm<con.tod.dm||dy<con.tod.dy)
                         {
                          if(strcmp(ty,con.type)==0&&con.sta!='*')
          con.show( );
                         }
                       }
                      else
                       {
                        if(dd<=con.fd.dd||dm<con.fd.dm||dy<con.fd.dy)
                         {
                          if(strcmp(ty,con.type)==0&&con.sta!='*')
          con.show( );
                         }
                       }
            }
   fil.clear( );
      }
                  if(n<1||n>3)
                   {
                    cout<<"\n WRONG CHOICE ENTERED ";
                   }
                 }
                fil.close( );
               }
 break;
  case 3:
              int guestno;
 cout<<"\n ENTER THE GUEST NO TO BE UPDATED";
 cin>>guestno;
 if(guestno>count)
  {
cout<<"\n THIS GUEST RECORD DOESNOT EXIST";
getch( );
goto lo;
  }
 else
  {
offset=((guestno-1)*sizeof(guest));
file.seekg(offset,ios::beg);
file.read((char*)&guest, sizeof(guest));
if(guest.status=='*')
{
 cout<<"\n THE GUEST RECORD IS DELETED ";
 getch( );
 goto lo;
}
else
{
 char ch;
 guest.showdata( );
 cout<<"\n DO U WANT TO MODIFY THIS RECORD "
 <<"PRESS Y FOR YES & N FOR NO ";
 ch=getch( );cout<<ch;
 if(ch=='y'|| ch=='Y');
  {
cout<<"\n ENTER NEW DATA ";
file.seekp(offset,ios::beg);
guest.modification( );
file.write((char*)&guest,sizeof(guest));
cout<<"\n NEW DATA REPLACED ";
getch( );
  }
}
  }
 break;
  case 4:
              int n=del_menu( );
              if(n==1)
               {
   char ch;
   cout<<"\n ENTER THE GUEST NO TO BE DELETED";
           cin>>guestno;
   if(guestno>count)
    {
 cout<<"\n THIS GUEST RECORD DOESNOT EXIST";
     getch( );
     goto lo;
    }
   else
    {
 offset=((guestno-1)*sizeof(guest));
 file.seekg(offset,ios::beg);
 file.read((char*)&guest, sizeof(guest));
 if(guest.status=='*')
  {
   cout<<"\n THE GUEST RECORD IS ALREADY DELETED ";
   getch( );
   goto lo;
  }
 else
  {
   guest.showdata( );
   cout<<"\n DO U WANT TO DELETE THIS RECORD "
       <<"PRESS Y FOR YES & N FOR NO ";
   ch=getch( );cout<<ch;
   if(ch=='y'|| ch=='Y');
    {
     file.seekp(offset,ios::beg);
 guest.del( );
 file.write((char*)&guest,sizeof(guest));
    }
  }
 file.seekp(0,ios::end);
    }
               }
              if(n==2||n==3)
               {
                fstream fil;
                fil.open("ban&con.dat",ios::out|ios::ate|ios::in|ios::binary);
                if(!fil)
                 {
                  cout<<"\n fil cant be open ";
                  getch( );
                  exit(0);
                 }
                if(n==2)
                 {
                  char na[30],ch;int co=1,t=0,off;
                  cout<<"\n ENTER THE PERSON NAME ";
                  gets(na);
                  char ty[]="banquet hall";
                  fil.seekg(0,ios::beg);
     while(fil.read((char*)&ban,sizeof(ban)))
      {
                    t++;
   if(strcmp(na,ban.name)==0&&strcmp(ty,ban.type)==0
                               &&ban.sta!='*')
    {
                      ban.show( );
                      cout<<"\n DO U WANT TO DELETE THIS FILE (PRESS Y OR N)";
                      ch=getch( ); cout<<" "<<ch;
                      if(ch=='y'|| ch=='Y')
                       {
                        off= ((t-1)*sizeof(ban));
                        fil.seekp(off,ios :: beg);
                        ban.del( );
                        fil.write((char*)&ban,sizeof(ban));
                        ret_amount(ban.fd,co,ban.td);
                       }
                     }
  }
 fil.clear( );
                 }
                if(n==3)
                 {
                  char na[30],ch;int co=2,t=0,off;
                  cout<<"\n ENTER THE PERSON NAME ";
                  gets(na);
                  char ty[]="conference hall";
                  fil.seekg(0,ios::beg);
     while(fil.read((char*)&con,sizeof(con)))
      {
                    t++;
   if(strcmp(na,con.name)==0&&strcmp(ty,con.type)==0&&con.sta!='*')
    {
                      con.show( );
                      cout<<"\n DO U WANT TO DELETE THIS FILE (PRESS Y OR N)";
                      ch=getch( ); cout<<" "<<ch;
                      if(ch=='y'|| ch=='Y')
                       {
                        off=((t-1)*sizeof(con));
                        fil.seekp(off,ios :: beg);
                        con.del( );
                        fil.write((char*)&con,sizeof(con));
                        ret_amount(con.fd,co,con.td);
                        getch( );
                       }
                     }
  }
 fil.clear();
                 }
                 fil.close( );
               }
 break;
  case 5:showbill( );
 break;
  case 6:clrscr( );
 cout<<"\n\t\t TOTAL ROOM IN HOTEL IS "<<700
 <<"\n\t\t TOTAL ROOM IN SUITE TYPE 1 IS "<<100
 <<"\n\t\t LIST OF EMPTY ROOM IS \n";
 int bn=1;
 int mn=empty_room(bn);
 if(!mn)
  cout<<"\n ALL THE ROOM ARE BOOKED ";
 getch( );
 clrscr( );
 cout<<"\n\t\t TOTAL ROOM IN SUITE TYPE 2 IS "<<150
 <<"\n\t\t LIST OF EMPTY ROOM IS \n";
 bn=2;
 mn=empty_room(bn);
 if(!mn)
  cout<<"\n ALL THE ROOM ARE BOOKED ";
 getch( );
 clrscr( );
 cout<<"\n\t\t TOTAL ROOM IN SUITE TYPE 3 IS "<<200
 <<"\n\t\t LIST OF EMPTY ROOM IS \n";
 bn=3;
 mn=empty_room(bn);
 if(!mn)
  cout<<"\n ALL THE ROOM ARE BOOKED ";
 getch( );
 clrscr( );
 cout<<"\n\t\t TOTAL ROOM IN SUITE TYPE 4 IS "<<250
 <<"\n\t\t LIST OF EMPTY ROOM IS \n";
 bn=4;
 mn=empty_room(bn);
 if(!mn)
  cout<<"\n ALL THE ROOM ARE BOOKED ";
 getch( );
              clrscr( );
              cout<<"\n CONFERENCE HALL IS BOOKED ON ";
              char ty[]="conference hall";
              booked(ty);
              getch( );
              clrscr( );
              cout<<"\n BANQUET HALL IS BOOKED ON ";
              char typ[]="banquet hall";
              booked(typ);
              getch( );
 break;
  case 7:char q;
 clrscr( );
 curtain( );
 delay(500);
 gotoxy(21,6);
 cout<<"\n THANK YOU FOR USING OUR SERVICE";
 gotoxy(20,8);
 cout<<"\n\t WE HOPE IN FUTURE YOU WILL";
 gotoxy(20,10);
 cout<<"\n\t GIVE US OPPERTUNITY TO SERVE YOU"
 <<"\n\t PRESS E TO EXIT";
 q=getch( );
 if(q=='E'||q=='e')
  choice=19;
 break;
  default:
  clrscr( );
  cout<<"\n \t WRONG CHOICE ENTERED \n"
  <<"PLEASE ENTER  RIGHT CHOICE \n"
  <<"PRESS ANY KEY TO SEE THE MENU";
  getch( );
  goto lo;
}
}while(choice>0 && choice<19);
   fil.close( );
   file.close( );
  }
/*************************************************************/
/********************FUNCTION RES_MENU************************/
int res_menu( )
 {
  int n;
  cout<<"\n 1. RESARVATION OF ROOM "
 <<"\n 2. RESERVATION OF BANQUET HALL"
 <<"\n 3. RESERVATION OF CONFERENCE HALL"
 <<"\n ENTER YOUR CHOICE ";
  cin>>n;
  return n;
 }
/**********************************************************/
/*****************FUNCTION RES_MENU************************/
int del_menu( )
 {
  int n;
  cout<<"\n 1. DELETION OF ROOM "
 <<"\n 2. DELETION OF BANQUET HALL"
 <<"\n 3. DELETION OF CONFERENCE HALL"
 <<"\n ENTER YOUR CHOICE ";
  cin>>n;
  return n;
 }
/**********************************************************/
/*****************FUNCTION SEE MENU************************/
int see_menu( )
 {
  int n;
  cout<<"\n 1. TO SEE RECORD OF GUEST "
 <<"\n 2. TO SEE RECORD OF BANQUET HALL"
 <<"\n 3. TO SEE RECORD OF CONFERENCE HALL"
 <<"\n ENTER YOUR CHOICE ";
  cin>>n;
  return n;
 }
/**********************************************************/
/*****************FUNCTION FACILITY************************/
 void facilities( )
  {
    int gdriver = EGA, gmode = EGAHI, errorcode;
int color=1, x=185, y=1,mc,style=1,size=2;
    char msg[80];
    initgraph(&gdriver, &gmode, " ");
    errorcode = graphresult( );
    if (errorcode != grOk)
     {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch( );
 exit(1);
     }
    getch( );
    mc=getmaxcolor( );
    cleardevice( );
    for(;!kbhit( );color++)
     {
 if(color>mc)
  color=1;
 setcolor(color); x=185;y=1;
 settextstyle(style, HORIZ_DIR, size);
 sprintf(msg, "DESCRIPTION  OF  SUITES");
      rectangle(60,60,600,280);
      line(60,100,600,100);line(330,60,330,280);
 outtextxy(x, y, msg); x=90;y=70;
 sprintf(msg, " TYPE OF SUITES            RENT PER DAY");
      outtextxy(x, y, msg); x=90;y=110;
 sprintf(msg, "     SUITE 1                  Rs 10000/-");
      outtextxy(x, y, msg); x=110;y=150;
 sprintf(msg, "   SUITE 2                  Rs 8500/-");
      outtextxy(x, y, msg); x=110;y=190;
 sprintf(msg, "   SUITE 3                  Rs 7000/-");
      outtextxy(x, y, msg); x=110;y=230;
 sprintf(msg, "   SUITE 4                  Rs 5500/-");
 outtextxy(x, y, msg); x=250;y=300;
      sprintf(msg, "PRESS ANY KEY TO SEE FACILITY.....");
 outtextxy(x, y, msg);
      delay(650);
     }
    getch( );
    cleardevice( );
    for(;!kbhit( );color++)
     {
 if(color>mc)
  color=1;
 setcolor(color); x=20;y=1;
 settextstyle(style, HORIZ_DIR, size);
 sprintf(msg, "**************************FACILITES"
                   "**************************");
 outtextxy(x, y, msg); x=110;y=30;
 sprintf(msg, "1. SWIMMING POOL(FREE)");
      outtextxy(x, y, msg); x=110;y=60;
 sprintf(msg, "2. INTERNATE CAFE (Rs 20/hr.) ");
      outtextxy(x, y, msg); x=110;y=90;
 sprintf(msg, "3. BANQUET ROOM (Rs 5000/day)");
      outtextxy(x, y, msg); x=110;y=120;
 sprintf(msg, "4. CONFERENCE HALL (Rs 2500/day)");
      outtextxy(x, y, msg); x=110;y=150;
 sprintf(msg, "5. COCKTAIL BAR (Rs 200/hr.)");
 outtextxy(x, y, msg); x=110;y=180;
      sprintf(msg, "6. GAMES ROOM(Rs 20/hr.)");
 outtextxy(x, y, msg); x=110;y=210;
      sprintf(msg, "7. LIBRARY(FREE)");
 outtextxy(x, y, msg); x=110;y=240;
      sprintf(msg, "8. JYM(FREE)");
 outtextxy(x, y, msg); x=110;y=270;
      sprintf(msg, "9. RESTURENT");
 outtextxy(x, y, msg); x=200;y=325;
      sprintf(msg, "PRESS ANY KEY TO CONTINUE.....");
 outtextxy(x, y, msg);
      delay(650);
     }
    closegraph( );
  }
/**********************************************************/
/****************FUNCTION MENU*****************************/
  int menu( )
   {
int gdriver = EGA, gmode = EGAHI, errorcode,n;
int color=1, x=185, y=1,mc,style=1,size=2;
    char msg[80],ch,*p,c;
    initgraph(&gdriver, &gmode, " ");
    errorcode = graphresult( );
    if (errorcode != grOk)
     {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch( );
 exit(1);
     }
    getch( );
    mc=getmaxcolor( );
    cleardevice( );
    for(;!kbhit( );color++)
     {
 if(color>mc)
  color=1;
      setcolor(color); x=1;y=1;
 settextstyle(style, HORIZ_DIR, size);
 sprintf(msg,"****************************************"
                  "****************************************");
 outtextxy(x, y, msg); x=60;y=30;
 sprintf(msg, "***********************MENU"
                   "***********************");
      outtextxy(x, y, msg); x=190;y=60;
 sprintf(msg, "1.RESERVATION");
      outtextxy(x, y, msg); x=190;y=90;
 sprintf(msg, "2.SEE FILE");
      outtextxy(x, y, msg); x=190;y=120;
 sprintf(msg, "3.MODIFICATION");
      outtextxy(x, y, msg); x=190;y=150;
 sprintf(msg, "4.DELETE");
 outtextxy(x, y, msg); x=190;y=180;
      sprintf(msg, "5.GET BILL");
 outtextxy(x, y, msg); x=190;y=210;
      sprintf(msg, "6.STATUS OF HOTEL");
 outtextxy(x, y, msg); x=190;y=240;
      sprintf(msg, "7.EXIT");
 outtextxy(x, y, msg); x=1;y=270;
      sprintf(msg,"****************************************"
                  "****************************************");
 outtextxy(x, y, msg); x=200;y=325;
      sprintf(msg, "PLEASE ENTER CHOICE(1-7)");
 outtextxy(x, y, msg);
      delay(650);
     }
    ch=getch( );p=&ch;
    n=atoi(p);
    sprintf(msg,"%d",n);
    outtextxy(500, 325, msg);
    getch( );
    closegraph( );
    return n;
  }
/**************************************************************/
/********************FUNCTION RET_AMOUNT***********************/
void ret_amount(DA fg,int ty,int td)
 {
  int tod,t=0,mt=0; float lt;
  char cdd,cdm,*p;
  int dy,dd,dm;
  getdate(&d);
  dy=d.da_year;
  cdd=d.da_day;
  cdm=d.da_mon;
  p=&cdd; dd=atoi(p);
  p=&cdm; dm=atoi(p);
  tod=cal_days(dy,dm,dd,fg.dy,fg.dm,fg.dy,t,mt);
  if(tod==1)
   {
    if(ty==1)
     lt=(td*50*50);
    if(ty==2)
     lt=(td*25*50);
   }
  if(tod>1&&tod<8)
   {
    if(ty==1)
     lt=(td*50*75);
    if(ty==2)
     lt=(td*25*75);
   }
  else
   {
    if(ty==1)
     lt=(td*50*90);
    if(ty==2)
     lt=(td*25*90);
   }
  cout<<"\n REFUNDABLE AMOUNT IS Rs. "<<lt;
  getch( );
 }
/************************************************************/
/********************FUNCTION SHOWBILL***********************/
void showbill( )
 {
  clrscr( );
  fstream fil;
  hotel gues;
  fil.open("record.dat",ios::out|ios::app|ios::in|ios::binary);
  char gname[30],gtype[20],*p,ch;
  int gfac,gsuite,guestno,cdd,cmm,cyy,ldd,lmm,lyy,hr;
  int cth,lth,tot_day,cafebill,gamesbill,rest_bill,bar_bill,con_bill,ban_bill;
  float suitecost,facicost,totfac,lodge,tax=0.07;
  long totbill;
  gotoxy(20,8);
  cout<<"\n ENTER GUEST NO...........\n";
  cin>>guestno;
  if(!count || guestno>count)
   {
cout<<"\n THIS RECORD DOES NOT EXITS ";
getch( );
fil.close( );
menu( );
goto la;
   }
  else
   {
fil.seekg((guestno-1)*sizeof(gues),ios::beg);
fil.read((char*)&gues,sizeof(gues));
clrscr( );
strcpy(gname,gues.name);
if(gues.status!='*')
{
 getdate(&d);
 gues.ldy=d.da_year;
 gues.ldd=d.da_day;
 gues.ldm=d.da_mon;
 gettime(&t);
 gues.lth=t.ti_hour;
 gues.ltm=t.ti_min;
 gues.lts=t.ti_sec;
}
cyy=gues.cdy; lyy=gues.ldy;
p=&gues.cdd; cdd=atoi(p);
p=&gues.ldd; ldd=atoi(p);
p=&gues.cdm; cmm=atoi(p);
p=&gues.ldm; lmm=atoi(p);
p=&gues.cth; cth=atoi(p);
p=&gues.lth; lth=atoi(p);
tot_day=cal_days(cyy,cmm,cdd,lyy,lmm,ldd,cth,lth);
if(tot_day==0)
tot_day++;
gsuite=gues.type;
switch(gsuite)
{
 case 1: strcpy(gtype,"suite 1");
 break;
 case 2:strcpy(gtype,"suite 2");
break;
 case 3:strcpy(gtype,"suite 3");
break;
 case 4:strcpy(gtype,"suite 1");
break;
}
suitecost=facilitybill(gsuite);
lodge=tot_day*suitecost;
cout<<"\n IS HE USED THE INTERNATE CAFE "
<<"PRESS Y FOR YES & N FOR NO ";
ch=getch( );
if(ch=='y'||ch=='Y')
{
 cout<<"\n ENTER THE TOTAL HOUR FOR WHICH HE USE THE CAFE";
 cin>>hr;
 cafebill=hr*20;
}
else
cafebill=0;
cout<<"\n IS HE USED THE GAMES ROOM "
<<"PRESS Y FOR YES & N FOR NO ";
ch=getch( );
if(ch=='y'||ch=='y')
{
 cout<<"\n ENTER THE TOTAL HOUR FOR WHICH HE USE THE GAMES ROOM";
 cin>>hr;
 gamesbill=hr*20;
}
else
gamesbill=0;
cout<<"\n ENTER THE RESTURENT BILL";
cin>>rest_bill;
cout<<"\n IS HE USED THE COCKE TAIL BAR "
<<"PRESS Y FOR YES & N FOR NO ";
ch=getch( );
if(ch=='y'||ch=='y')
{
 cout<<"\n ENTER THE TOTAL HOUR FOR WHICH HE USE THE GAMES ROOM";
 cin>>hr;
 bar_bill=hr*200;
}
else
bar_bill=0;
gfac=cafebill+gamesbill+rest_bill+bar_bill+con_bill+ban_bill;
totbill=lodge+gfac+(lodge+gfac)*tax;
seebill(gname,lodge,cafebill,gamesbill,rest_bill,
            bar_bill,tot_day,gtype,totbill);
menu( );
   }
  la:
  fil.close( );
 }
/*************************************************************/
/*****************FUNCTION CALCULAT DAYS**********************/
int cal_days(int yy,int mm,int dd,int lyy,int lmm,
             int ldd,int th,int lth)
 {
  int totd,totm,toty,i;
  if(lyy>=yy)
   {
toty=lyy-yy;
lmm+=12*toty;
   }
  if(lmm>=mm)
   {
totm=lmm-mm;
for(i=totm;i>0;i--)
{
 if(mm==4||mm==6||mm==9||mm==11)
  ldd+=30;
 else
 if(mm==2)
  {
if(yy%4==0)
ldd+=29;
else
ldd+=28;
  }
 else
  ldd+=31;
 mm++;
}
   }
  totd=ldd-dd;
  if(lth>th)
   totd++;
  return totd;
 }
/*************************************************************/
/****************** FUNCTION FACILITY BILL********************/
float facilitybill( int y)
 {
  float cost;
  switch(y)
   {
case 1:cost=10000;
  break;
case 2:cost=8500;
  break;
case 3:cost=7000;
  break;
case 4:cost=5500;
  break;
   }
  return cost;
 }
/*************************************************************/
/******************** FUNCTION SEEBILL ***********************/
void seebill(char gname[30],float lodge,int cafebill,
             int gamesbill,int rest_bill,int bar_bill,
             float totday,char gtype[20],long totbill)
 {
  clrscr( );
  cout<<"\n \n\n HOTAL TAJ \n"
 <<"\n BARLI MUMBAI\n"
 <<"\n Ph:- 99334427983, 9234798381"
 <<"\n                 BILL    "
 <<"\n NAME "<<gname
 <<"\n lodging bill "<<lodge
 <<"\n cafe bill (Rs. 20/Hr) "<<cafebill
 <<"\n games bill (Rs. 20/Hr)"<<gamesbill
 <<"\n resturent bill "<<rest_bill
 <<"\n cocktail bar bill (rs 200/hr) "<<bar_bill
 <<"\n tax 7% "
 <<"\n days of stay "<<totday
 <<"\n suite "<<gtype
 <<"\n grndtotal "<<totbill
 <<"\n thakyou"
 <<"\n press any key to go to menu......";
  getch( );
 }
/************************************************************/
/******************** FUNCTION CURTAIN **********************/
void curtain( )
 {
  clrscr( );
  int r,c=0,c1=80;
  while((c<=38)&&(c1>38))
   {
for(r=1;r<24;r++)
{
 gotoxy(c,r);
 cout<<"*_*_*";
 gotoxy(c1,r);
 cout<<"*_*_*";
}
c++;c1--;
delay(100);
   }
 }

No comments:

Post a Comment