⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hotel_managment.cpp

📁 Contains a project on hotel management system.. feel free to download and use..
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	gotoxy(1,25) ;
	cout <<"ENTER THE ADVANCE RS." ;
	gotoxy(20,11) ;
	cin >>t_advance ;
	gotoxy(1,25) ; clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE MISCALLENIOUS CHARGES" ;
	gotoxy(20,12) ;
	cin >>t_misc ;
	gotoxy(1,25) ; clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE ROOM SERVICE CHARGES" ;
	gotoxy(20,13) ;
	cin >>t_room_srv ;
	gotoxy(1,15) ;
	cout <<"Do you want to save the record (y/n)  :  " ;
	do
	{
		valid = 1 ;
		gotoxy(42,15) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,15) ; clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'Y')
	{
		r.change_status(t_roomno,'O') ;
		roomno = t_roomno ;
		strcpy(name,t_name) ;
		strcpy(phone,t_phone) ;
		advance = t_advance ;
		misc = t_misc ;
		room_srv = t_room_srv ;
		fstream file ;
		file.open("CUSTOMER.DAT", ios::out | ios::app) ;
		file.write((char*) this, sizeof(customer)) ;
		file.close() ;
	}
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : DISPLAY_RECORD
//	DETAILS       : IT DISPLAYS THE RECORDS OF CUSTOMER
//                   IN THE GIVEN ROOM NO.
//**********************************************************

void customer :: display_record(int t_roomno)
{
	fstream file ;
	file.open("CUSTOMER.DAT", ios::in) ;
	file.seekg(0) ;
	int found = 0 ;
	while (file.read((char *) this, sizeof(customer)) && !found)
	{
		if (t_roomno == roomno)
		{
			found = 1 ;
			gotoxy(1,5) ;
			cout<<"Room no.             : " <<roomno ;
			gotoxy(1,6) ;
			cout<<"Customer Name        : " <<name ;
			gotoxy(1,7) ;
			cout<<"Phone no.            : " <<phone ;
			gotoxy(1,8) ;
			cout<<"Advance              : " <<advance ;
			gotoxy(1,9) ;
			cout<<"Misc. charges        : " <<misc ;
			gotoxy(1,10) ;
			cout<<"Room Service Charges : " <<room_srv ;
		}
	}
	file.close () ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : RECORDNO
//	DETAILS       : IT RETURNS THE RECORD NO. OF THE GIVEN
//                   ROOM NO. IN CUSTOMER'S FILE
//**********************************************************

int customer :: recordno(int t_roomno)
{
	fstream file ;
	file.open("CUSTOMER.DAT", ios::in) ;
	file.seekg(0) ;
	int count = 0 ;
	while (file.read((char *) this, sizeof(customer)))
	{
		count++ ;
		if (t_roomno == roomno)
			break ;
	}
	file.close() ;
	return count ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : MODIFY
//	DETAILS       : IT MODIFY THE CUSTOMER'S RECORDS IN
//                   THE CUSTOMER'S FILE (CUSTOMER.DAT)
//**********************************************************

void customer :: modify(void)
{
	clrscr() ;
	room r ;
	int valid ;
	char ch ;
	int t_roomno , tr ;
	char  t_name[21] , t_phone[15] ;
	float t_advance , t_misc , t_room_srv ;
	fstream file ;
	file.open("CUSTOMER.DAT", ios::out | ios::ate) ;
	gotoxy(1,3) ;
	cout <<"Enter the Room no. of the customer to be modified " ;
	cin >>tr ;
	char t_status ;
	t_status = r.room_status(tr) ;
	if (!r.room_found(tr) || t_status == 'V')
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ; clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	display_record(tr) ;
	gotoxy(1,12) ;
	cout <<"Do you want to modify this Room Record (y/n) : " ;
	do
	{
		valid = 1 ;
		gotoxy(48,12) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,12) ; clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'N')
		return ;
	gotoxy(1,14) ;
	cout <<"ENTER THE NEW DATA FOR THE CUSTOMER" ;
	gotoxy(1,16) ;
	cout <<"Room no.         : " ;
	gotoxy(1,17) ;
	cout <<"Name             : " ;
	gotoxy(1,18) ;
	cout <<"Phone            : " ;
	gotoxy(1,19) ;
	cout <<"Advance          : " ;
	gotoxy(1,20) ;
	cout <<"Miscellineous    : " ;
	gotoxy(1,21) ;
	cout <<"Room service     : " ;
	do
	{
		valid = 1 ;
		gotoxy(1,25) ; clreol() ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM NUMBER FOR CUSTOMER" ;
		gotoxy(20,16) ;
		cin >>t_roomno ;
		t_status = r.room_status(t_roomno) ;
		if ((!r.room_found(t_roomno)) || (r.room_found(t_roomno) && t_roomno != tr && t_status == 'O'))
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"ROOM NO. NOT EXIST OR NOT VACANT" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(20,16) ; clreol() ;
		}
	} while ( !valid ) ;
	gotoxy(1,25) ; clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE NAME OF THE CUSTOMER" ;
	gotoxy(20,17) ;
	gets(t_name) ;
	strupr(t_name) ;
	fflush(stdin) ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
	gotoxy(20,18) ;
	cin >>t_phone ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE ADVANCE RS." ;
	gotoxy(20,19) ;
	cin >>t_advance ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE MISCALLENIOUS CHARGES" ;
	gotoxy(20,20) ;
	cin >>t_misc ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE ROOM SERVICE CHARGES" ;
	gotoxy(20,21) ;
	cin >>t_room_srv ;
	gotoxy(1,23) ;
	cout <<"Do you want to save the record (y/n)  :  " ;
	do
	{
		valid = 1 ;
		gotoxy(42,23) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,23) ; clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'Y')
	{
		if (t_roomno != tr)
		{
			r.change_status(t_roomno,'O') ;
			r.change_status(tr,'V') ;
		}
		int recno ;
		recno = recordno(tr) ;
		int location ;
		location = (recno-1) * sizeof(customer) ;
		file.seekp(location) ;
		roomno  = t_roomno  ;
		strcpy(name,t_name) ;
		strcpy(phone,t_phone) ;
		room_srv = t_room_srv ;
		advance = t_advance ;
		misc = t_misc ;
		file.write((char *) this, sizeof(customer)) ;
	}
	file.close () ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : DELETE_RECORD
//	DETAILS       : IT DELETES THE CUSTOMER'S RECORD IN
//                   THE CUSTOMER'S FILE (CUSTOMER.DAT) OF
//                   THE GIVEN ROOM NO.
//**********************************************************

void customer :: delete_record(int t_roomno)
{
	fstream file ;
	file.open("CUSTOMER.DAT", ios::in) ;
	fstream temp ;
	temp.open("temp.dat", ios::out) ;
	while ( !file.eof() )
	{
		file.read((char *) this, sizeof(customer)) ;
		if ( file.eof() )
			break ;
		if ( roomno != t_roomno )
			temp.write((char *) this, sizeof(customer)) ;
	}
	file.close() ;
	temp.close() ;
	file.open("CUSTOMER.DAT", ios::out) ;
	temp.open("temp.dat", ios::in) ;
	temp.seekg(0) ;
	while ( !temp.eof() )
	{
		temp.read((char *) this, sizeof(customer)) ;
		if ( temp.eof() )
			break ;
		file.write((char *) this, sizeof(customer)) ;
	}
	file.close() ;
	temp.close() ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : DISPLAY_CUSTOMER_RECORD
//	DETAILS       : IT GIVES THE ROOM NO. OF THE CUSTOMER
//                   TO DISPLAY THE CUSTOMER RECORD
//**********************************************************

void customer :: display_customer_record(void)
{
	clrscr() ;
	room r ;
	int valid ;
	int t_roomno ;
	gotoxy(1,3) ;
	cout <<"Enter the Room no. of the customer : " ;
	cin >>t_roomno ;
	char t_status ;
	t_status = r.room_status(t_roomno) ;
	if (!r.room_found(t_roomno) || t_status == 'V')
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ; clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	clrscr() ;
	gotoxy(5,3) ;
	cout <<"CUSTOMER RECORD" ;
	display_record(t_roomno) ;
	gotoxy(1,25) ;
	cout <<"Press any key to continue..." ;
	getch() ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : DELETION
//	DETAILS       : IT GIVES THE ROOM NO. OF THE CUSTOMER
//                   TO DELETE THE CUSTOMER RECORD
//**********************************************************

void customer :: deletion(void)
{
	clrscr() ;
	room r ;
	int valid ;
	char ch ;
	int t_roomno ;
	gotoxy(1,3) ;
	cout <<"Enter the Room no. of the customer to be deleted " ;
	cin >>t_roomno ;
	char t_status ;
	t_status = r.room_status(t_roomno) ;
	if (!r.room_found(t_roomno) || t_status == 'V')
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ;	clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	display_record(t_roomno) ;
	gotoxy(1,15) ;
	cout <<"Do you want to delete this Customer Record (y/n) : " ;
	do
	{
		valid = 1 ;
		gotoxy(52,15) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(52,15) ; clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'N')
		return ;
	r.change_status(t_roomno,'V') ;
	delete_record(t_roomno) ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : CHECKOUT
//	DETAILS       : IT GIVES THE DATA OF THE CUSTOMER TO
//                   PREPARE BILL OF THE CUSTOMER AND ALSO
//                   DELETE THE CUSTOMER'S RECORD
//**********************************************************

void customer :: checkout(void)
{
	clrscr() ;
	room r ;
	int valid ;
	char ch ;
	int t_roomno ;
	gotoxy(1,3) ;
	cout <<"Enter the Room no. of the customer to be check out " ;
	cin >>t_roomno ;
	char t_status ;
	t_status = r.room_status(t_roomno) ;
	if (!r.room_found(t_roomno) || t_status == 'V')
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ;	clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND OR ROOM IS VACANT" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	display_record(t_roomno) ;
	gotoxy(1,15) ;
	cout <<"Do you want to prepare bill of this Customer Record (y/n) : " ;
	do
	{
		valid = 1 ;
		gotoxy(63,15) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(63,15) ; clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'N')
		return ;
	fstream file ;
	file.open("CUSTOMER.DAT", ios::in) ;
	file.seekg(0) ;
	char t_name[21] ;
	float t_advance, t_room_srv, t_misc, t_tarriff ;
	while (file.read((char *) this, sizeof(customer)))
	{
		if (t_roomno == roomno)
		{
			strcpy(t_name,name) ;
			t_advance = advance ;
			t_room_srv = room_srv ;
			t_misc = misc ;
			break ;
		}
	}
	file.close() ;
	t_tarriff = r.get_data(t_roomno) ;
	account a ;
	a.prepare_bill(t_roomno,t_tarriff,t_name,t_advance,t_room_srv,t_misc) ;
	r.change_status(t_roomno,'V') ;
	delete_record(t_roomno) ;
	gotoxy(1,25) ;
	cout <<"Press any key to continue..." ;
	getche() ;
}


//**********************************************************
//	CLASS NAME    : ACCOUNT
//	FUNCTION NAME : PREPARE
//	DETAILS       : IT ACCEPTS THE DATA OF THE CUSTOMER &
//                   PREPARE BILL OF THE CUSTOMER & ALSO
//                   CREATES BILL SLIP
//**********************************************************

void account :: prepare_bill(int t_roomno, float t_tarriff, char t_name[21], float t_advance, float t_room_srv, float t_misc)
{
	int valid ;
	int days ;
	float tax , total ;
	gotoxy(1,17) ;
	cout <<"Enter the no. of days : " ;
	do
	{
		valid = 1 ;
		gotoxy(25,17) ;
		cin >>days ;
		if (days < 0 || days > 999)
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"SHOULD NOT LESS THAN ZERO" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(25,17) ; clreol() ;
		}
	} while ( !valid ) ;
	t_tarriff = t_tarriff * days ;
	total = (t_room_srv + t_misc + t_tarriff) - t_advance ;
	tax = total * 0.22 ;
	total = total + tax ;
	clrscr() ;
	menu m ;
	gotoxy(5,3) ;
	cout <<"Bill of Room no. : " <<t_roomno ;
	gotoxy(5,6) ;
	cout <<"Name of Customer     : " <<t_name ;
	gotoxy(5,8) ;
	cout <<"Tarriff Charges      : " <<t_tarriff ;
	gotoxy(5,10) ;
	cout <<"Misc. Charges        : " <<t_misc ;
	gotoxy(5,12) ;
	cout <<"Room service Charges : " <<t_room_srv ;
	gotoxy(5,14) ;
	cout <<"Tax                  : " <<tax ;
	gotoxy(5,16) ;
	cout <<"Advance              : " <<t_advance ;
	gotoxy(5,18) ;
	cout <<"------------------------------------------" ;
	gotoxy(5,19) ;
	cout <<"Total Bill           : " <<total ;
	gotoxy(5,20) ;
	cout <<"------------------------------------------" ;
}



//**********************************************************
//	FUNCTION NAME : MAIN
//	DETAILS       : IT CALLS THE PASSWORD FUNCTION AND
//                   MENU FUNCTION.
//**********************************************************

void main()
{
	clrscr();
	int i, x, y;
	char hm[]="HOTEL MANAGEGEMENT SYSTEM";

	gotoxy(1,4);
	cout<<"--------------------------------------------------------------------------------";
	gotoxy(1,6);
	cout<<"--------------------------------------------------------------------------------";

	for(y=24; y!=4; y--)
	{
		gotoxy(30,y+1);
		cout<<"                   ";
		gotoxy(30,y);
		cout<<"GURPREET SINGH MODI";
		sound(3*y+2000);
		gotoxy(80,24);
		delay(100);
		nosound();
	}
	gotoxy(1,6);
	cout<<"--------------------------------------------------------------------------------";

	for(x=1; x<35; x++)
	{
		gotoxy(x-1,8);
		cout<<"        ";
		gotoxy(x,8);
		cout<<"Presents";
		sound(3*x+1500);
		gotoxy(80,24);
		delay(80);
		nosound();
	}

	for(x=70; x!=32; x--)
	{
		gotoxy(x+1,11);
		cout<<"          ";
		gotoxy(x,11);
		cout<<"Project on";
		sound(3*x+700);
		gotoxy(80,24);
		delay(80);
		nosound();
	}

	gotoxy(26,15);
	cout<<"*****************************";
	gotoxy(26,17);
	cout<<"*****************************";
	for(i=0, x=28; x<25, i<25; x++,i++)
	{
		gotoxy(x,16);
		cout<<hm[i];
		sound(1500);
		delay(60);
		nosound();
	}
	gotoxy(80,24);
	getch();

	menu m ;
	m.enter_password() ;
	m.main_menu() ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -