Popular Posts

6/25/2012

Hotel Management in C Programming

Welcome to Home Land Hotel
Download Here 
and the following code :
=======================================

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
typedef struct {int day;
int month;
int year;
}date;
struct customer{int id;
char name[20];
date da_in;
date da_out;
int n_of_room;
char room;
int price;
}cust[30],temp;
int n,i,j,ID=0; int d,p,e; char a,b,c; int room;
void check_in();
void check_out();
void edit();
void view();
void search();
void draw();
void main()
{
char ch;
while(1)
{clrscr();
 textcolor(6); gotoxy(30,2); cprintf("Welcome to Home Land Hotel");textcolor(7);cprintf("");
 gotoxy(35,5); printf("Main Menu");
 gotoxy(3,9); printf("Please Press Any Keys Below");
 gotoxy(8,12); printf("1/ Check In the Customer");
 gotoxy(8,14); printf("2/ Check Out the Customer");
 gotoxy(8,16); printf("3/ Edit the Customer");
 gotoxy(8,18); printf("4/ View List of Customer");
 gotoxy(8,20); printf("5/ Search the Customer");
 gotoxy(8,22); printf("6/ Exit The Program");
 ch=getch();
 switch(ch)
 {case'1':clrscr(); check_in(); break;
  case'2':clrscr(); check_out(); break;
  case'3':clrscr(); edit(); break;
  case'4':clrscr(); view(); break;
  case'5':clrscr(); search(); break;
  case'6':clrscr(); exit(1);  break;
  default:gotoxy(3,27); printf("Error Enter Again!!");getch(); break;
 }
 }
}


//********The Function of Program  Check in********
void check_in()
{
draw();
gotoxy(30,3); printf("Customer %04d",ID+1);
gotoxy(10,6); printf("Name="); fflush(stdin); gets(cust[ID].name);
gotoxy(10,8); printf("Input Date Check In="); scanf("%d%c%d%c%d",&cust[ID].da_in.day,&a,&cust[ID].da_in.month,&b,&cust[ID].da_in.year);
again:
gotoxy(10,10); printf("                                       ");
gotoxy(10,10);printf("Room Number="); scanf("%d",&cust[ID].n_of_room);
if( cust[ID].n_of_room<101 || cust[ID].n_of_room>109 && cust[ID].n_of_room<201 || cust[ID].n_of_room>209 && cust[ID].n_of_room<301 || cust[ID].n_of_room>309)
   { gotoxy(10,10); printf("NO that Room!!!");
getch(); goto again;}
for(i=0;i<ID;i++)
{if(cust[i].n_of_room==cust[ID].n_of_room)
{gotoxy(10,10); printf("Room Number %d Aready Exist",cust[ID].n_of_room);
getch(); goto again;
}
}
again1:
gotoxy(10,12); printf("                                       ");
gotoxy(10,12); printf("Type of Room="); fflush(stdin); scanf("%c",&cust[ID].room);
if(cust[ID].room!='D' && cust[ID].room!='d' && cust[ID].room!='S' && cust[ID].room!='s')
{gotoxy(10,12); printf("Error type of room must be D or S ");getch();
goto again1;}

cust[ID].id=ID+1;
if(cust[ID].room=='D' || cust[ID].room=='d')
cust[ID].price=20;
if(cust[ID].room=='S' || cust[ID].room=='s')
{cust[ID].price=15;}
cust[ID].da_out.day=0;
cust[ID].da_out.month=0;
cust[ID].da_out.year=0;
ID++;
}
//******The Function of Program Check out********
void check_out()
{
char ch;
gotoxy(10,3); printf ("For Check_out!!! Input Customer ID=");
scanf("%d",&n);
gotoxy(10,6); printf("customer Name=%s  Y/N?",cust[n-1].name);ch=getch(); if (ch=='n' || ch== 'N') goto exit;
gotoxy(10,8);  printf("Date Check in=%02d/%02d/%02d",cust[n-1].da_in.day,cust[n-1].da_in.month,cust[n-1].da_in.year);
gotoxy(10,10); printf("Input Date Check Out="); scanf("%d%c%d%c%d",&cust[n-1].da_out.day,&a,&cust[n-1].da_out.month,&b,&cust[n-1].da_out.year);
gotoxy(10,12); printf("Room Type = '%c' so the price per night= %02d.00$",cust[n-1].room,cust[n-1].price);
gotoxy(30,18); printf("Thank You");
d=cust[n-1].da_out.day-cust[n-1].da_in.day;
p=d*cust[n-1].price;
gotoxy(25,20); printf("You have Stay for %d days",d);
gotoxy(30,22); printf("Cost=%d.00$",p); getch();
cust[n-1].room=NULL;
cust[n-1].n_of_room=NULL;
cust[n-1].price=NULL;
exit:

}
//******The Function of Program View********
void view()
{
clrscr();
gotoxy(30,3); printf("List of Customer");
gotoxy(1,7); printf("ID");
gotoxy(8,7); printf("Name");
gotoxy(24,7); printf("Check_in");
gotoxy(39,7); printf("Check_out");
gotoxy(54,7); printf("NO_of_Room");
gotoxy(67,7); printf("room");
gotoxy(74,7); printf("Price");
gotoxy(1,9); printf("==============================================================================");
for(i=0;i<ID;i++)
{
gotoxy(1,11+(i*2)); printf("%03d",cust[i].id);
gotoxy(8,11+(i*2)); printf("%s",cust[i].name);
gotoxy(23,11+(i*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
gotoxy(38,11+(i*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
gotoxy(57,11+(i*2)); printf("%d",cust[i].n_of_room);
gotoxy(69,11+(i*2)); printf("%c",cust[i].room);
gotoxy(73,11+(i*2)); printf("%d.00$",cust[i].price);
}
gotoxy(1,11+(i*2)); printf("==============================================================================");
getch();
}

//******The Function of Program Edit ********
void edit()
{
gotoxy(20,5); printf("For Editing!!! Input Customer ID="); scanf("%d",&e); clrscr();
draw();
gotoxy(30,3); printf("Customer %04d",e);
gotoxy(10,6); printf("Name=%s -> ",cust[e-1].name); fflush(stdin); gets(cust[e-1].name);
gotoxy(10,8); printf("Input Date Check In=%d/%d/%d -> ",cust[e-1].da_in.day,cust[e-1].da_in.month,cust[e-1].da_in.year);
scanf("%d%c%d%c%d",&cust[e-1].da_in.day,&a,&cust[e-1].da_in.month,&b,&cust[e-1].da_in.year);
again:
gotoxy(10,10); printf("                                       ");
gotoxy(10,10);printf("Room Number=%d -> ",cust[e-1].n_of_room); scanf("%d",&room);
if( room<101 || room>109 && room<201 || room>209 && room<301 || room>309)
   { gotoxy(10,10); printf("NO that Room!!!");
getch(); goto again; }
for(i=0;i<ID;i++)
{if(cust[i].n_of_room==room && room!=cust[e-1].n_of_room)
{gotoxy(10,10); printf("Room Number %d Aready Exist",room);
getch(); goto again;
}
}
again1:
gotoxy(10,12); printf("                                       ");
gotoxy(10,12); printf("Type of Room=%c -> ",cust[e-1].room); fflush(stdin); scanf("%c",&cust[e-1].room);
if(cust[e-1].room!='D' && cust[e-1].room!='d' && cust[e-1].room!='S' && cust[e-1].room!='s')
{gotoxy(10,12); printf("Error type of room must be D or S ");getch();
goto again1;}

cust[e-1].id=e;
if(cust[e-1].room=='D' || cust[e-1].room=='d')
cust[e-1].price=20;
if(cust[e-1].room=='S' || cust[e-1].room=='s')
{cust[e-1].price=15;}
cust[e-1].n_of_room=room;
cust[e-1].da_out.day=0;
cust[e-1].da_out.month=0;
cust[e-1].da_out.year=0;

}

//******The Function of Program Draw table ********
  void draw()

  {

gotoxy(8,27);printf("ÉÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍËÍÍÍÍÍ»");
gotoxy(8,28);printf("º     º     º     º     º     º     º     º     º     º");
gotoxy(8,29);printf("º     º     º     º     º     º     º     º     º     º <- Third Floor");
gotoxy(8,30);printf("º     º     º     º     º     º     º     º     º     º");
gotoxy(8,31);printf("ÌÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍ͹");
gotoxy(8,32);printf("º     º     º     º     º     º     º     º     º     º");
gotoxy(8,33);printf("º     º     º     º     º     º     º     º     º     º <- Second Floor");
gotoxy(8,34);printf("º     º     º     º     º     º     º     º     º     º");
gotoxy(8,35);printf("ÌÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍÍÎÍÍÍÍ͹");
gotoxy(8,36);printf("º     º     º     º     º     º     º     º     º     º");
gotoxy(8,37);printf("º     º     º     º     º     º     º     º     º     º <- First Floor");
gotoxy(8,38);printf("º     º     º     º     º     º     º     º     º     º");
gotoxy(8,39);printf("ÈÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍÍÊÍÍÍÍͼ");
for(i=0;i<9;i++)
{
gotoxy(10+(6*i),29);
for(j=0;j<ID;j++)
{
if(cust[j].n_of_room==301+i)
{
textcolor(RED);
}
}
cprintf("%d",301+i); textcolor(WHITE);

gotoxy(10+(6*i),33);
for(j=0;j<ID;j++)
{
if(cust[j].n_of_room==201+i)
{
textcolor(RED);
}
}
cprintf("%d",201+i); textcolor(WHITE);


gotoxy(10+(6*i),37);
for(j=0;j<ID;j++)
{
if(cust[j].n_of_room==101+i)
{
textcolor(RED);
}
}
cprintf("%d",101+i); textcolor(WHITE);
}

  }
 
//******The Function of Program Search ********
  void search()
{
again:
clrscr();
int f=0; int d,m,y; char sn[20]; int si, room;
gotoxy(30,3); printf("Search List of Customer");
gotoxy(3,10); printf(">>Please Press Any Keys Below");
gotoxy(8,12); printf("1/Search by ID");
gotoxy(8,14); printf("2/Search by Date(Check In)");
gotoxy(8,16); printf("3/Search by Date(Chck Out)");
gotoxy(8,18); printf("4/Search by Name of Customer");
gotoxy(8,20); printf("5/Search by No_of_Room");
char ch1; ch1=getch(); clrscr();

switch(ch1)
{
case'1':gotoxy(5,3);
printf("For Searching!!! Enter Customer ID="); scanf("%d",&si);
j=0;
clrscr();
for(i=0;i<ID;i++)
{if(cust[i].id==si)
{
f=1;
gotoxy(1,11+(j*2));
gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
j++;
}
}
gotoxy(1,11+(j*2)); printf("==============================================================================");
break;
case'2':gotoxy(5,3);
printf("For Searching!!! Enter Customer Date Check In=");
scanf("%d%c%d%c%d",&d,&a,&m,&b,&y);
j=0;
clrscr();
for(i=0;i<ID;i++)
{if(cust[i].da_in.day==d && cust[i].da_in.month==m && cust[i].da_in.year==y)
{
f=1;
gotoxy(1,11+(j*2));
gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
j++;
}
}
gotoxy(1,11+(j*2)); printf("==============================================================================");
break;
case'3':gotoxy(5,3);
printf("For Searching!!! Enter Customer Date Check Out=");
scanf("%d%c%d%c%d",&d,&a,&m,&b,&y);
j=0;
clrscr();
for(i=0;i<ID;i++)
{if(cust[i].da_out.day==d && cust[i].da_out.month==m && cust[i].da_out.year==y)
{
f=1;
gotoxy(1,11+(j*2));
gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
j++;
}
}
gotoxy(1,11+(j*2)); printf("==============================================================================");
break;
case'4':gotoxy(5,3);
printf("For Searching!!! Enter Customer Name=");
fflush(stdin); gets(sn);
j=0;
clrscr();
for(i=0;i<ID;i++)
{if(strcmp(cust[i].name,sn)==0)
{
f=1;
gotoxy(1,11+(j*2));
gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
j++;
}
}
gotoxy(1,11+(j*2)); printf("==============================================================================");
break;
case'5':gotoxy(5,3);
printf("For Searching!!! Enter Room Number="); scanf("%d",&room);
j=0;
clrscr();
for(i=0;i<ID;i++)
{if(cust[i].n_of_room==room)
{
f=1;
gotoxy(1,11+(j*2));
gotoxy(1,11+(j*2)); printf("%03d",cust[i].id);
gotoxy(8,11+(j*2)); printf("%s",cust[i].name);
gotoxy(23,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_in.day,cust[i].da_in.month,cust[i].da_in.year);
gotoxy(38,11+(j*2)); printf("%02d/%02d/%04d",cust[i].da_out.day,cust[i].da_out.month,cust[i].da_out.year);
gotoxy(57,11+(j*2)); printf("%d",cust[i].n_of_room);
gotoxy(69,11+(j*2)); printf("%c",cust[i].room);
gotoxy(73,11+(j*2)); printf("%d.00$",cust[i].price);
j++;
}
}
gotoxy(1,11+(j*2)); printf("==============================================================================");
break;
default: gotoxy(3,27); printf("Error Enter Again!!");getch(); goto again;
}
if(f==0) {clrscr(); gotoxy(20,20); printf("Can not Find!!!");
getch(); goto again;}
gotoxy(30,3); printf("List of Customer");
gotoxy(1,7); printf("ID");
gotoxy(8,7); printf("Name");
gotoxy(24,7); printf("Check_in");
gotoxy(39,7); printf("Check_out");
gotoxy(54,7); printf("NO_of_Room");
gotoxy(67,7); printf("room");
gotoxy(74,7); printf("Price");
gotoxy(1,9); printf("==============================================================================");
    gotoxy(80,50);getch();
}

1 comments: