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

📄 hotel_managment.cpp

📁 Contains a project on hotel management system.. feel free to download and use..
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	}
	file.close() ;
	return t_tarriff ;
}


//**********************************************************
//	CLASS NAME    : ROOM
//	FUNCTION NAME : ADD
//	DETAILS       : IT ADDS THE ROOM RECORD TO THE ROOM
//                   FILE (ROOM.DAT).
//**********************************************************

void room :: add (void)
{
	char ch ;
	char t_rcode[5] ;
	int t_roomno ;
	char t_status ;
	float t_tarriff ;
	do
	{
	fstream file ;
	file.open("ROOM.DAT", ios::out | ios::app ) ;
	clrscr() ;
	gotoxy(1,1) ;
	cout <<"Enter the details for the room" ;
	gotoxy(1,3) ;
	cout <<"Code     :  " ;
	gotoxy(1,4) ;
	cout <<"Room no. :  " ;
	gotoxy(1,5) ;
	cout <<"Status   :  " ;
	gotoxy(1,6) ;
	cout <<"Tarriff  :  " ;
	gotoxy(20,11) ;
	cout <<"SS : SINGLE SUIT" ;
	gotoxy(20,12) ;
	cout <<"SR : SINGLE ROOM" ;
	gotoxy(20,13) ;
	cout <<"DR : DOUBLE ROOM" ;
	gotoxy(20,14) ;
	cout <<"DS : DOUBLE SUIT" ;
	int valid = 0 ;
	do
	{
		valid = 1 ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM CODE (SS/SR/DR/DS)" ;
		gotoxy(13,3) ;
		cin >>t_rcode ;
		strupr(t_rcode) ;
		char *string[4] = {"SS","DR","SR","DS"} ;
		int result , count = 0 ;
		for ( int i=0; i<4; i++ )
		{
			result = strcmpi(t_rcode,string[i]) ;
			if ( result != 0 )
			count++ ;
		}
		if ( count == 4 )
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"INVALID CODE" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,3) ;	clreol() ;
		}
	} while ( valid == 0 ) ;
	for ( int i=11; i<=14; i++ )
	{
		gotoxy(1,i) ;	clreol() ;
	}
	do
	{
		valid = 1 ;
		gotoxy(1,25) ; clreol() ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM NUMBER" ;
		gotoxy(13,4) ;
		cin >>t_roomno ;
		if ( t_roomno <= 0 || t_roomno > 900 )
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"IT SHOULD NOT BE NEGATIVE OR ZERO OR GREATER THAN 900" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,4) ;	clreol() ;
		}
		if ( room_found( t_roomno ) )
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"ROOM NO. ALREADY EXIST" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,4) ;	clreol() ;
		}
	} while ( !valid ) ;
	do
	{
		valid = 1 ;
		gotoxy(1,25) ;	clreol() ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM STATUS : V=vacant, O=occupied" ;
		gotoxy(13,5) ;
		cin >>t_status ;
		t_status = toupper(t_status) ;
		if (t_status != 'O' && t_status != 'V')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"INVALID DATA ENTERED" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,5) ;	clreol() ;
		}
	} while ( !valid ) ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE TARRIFF FOR THE ROOM" ;
	gotoxy(13,6) ;
	cin >>t_tarriff ;
	gotoxy(1,8) ;
	cout <<"Do you want to save the record (y/n)  :  " ;
	do
	{
		valid = 1 ;
		gotoxy(42,8) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,8) ;	clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'Y')
	{
		strcpy(roomcode,t_rcode) ;
		roomno  = t_roomno  ;
		status  = t_status  ;
		tarriff = t_tarriff ;
		file.write((char *) this, sizeof(room)) ;
	}
	gotoxy(1,9) ;
	cout <<"Do you want to add more records (y/n) :  " ;
	do
	{
		valid = 1 ;
		gotoxy(42,9) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,9) ;	clreol() ;
		}
	} while ( !valid ) ;
	file.close () ;
	} while ( ch == 'Y') ;
}


//**********************************************************
//	CLASS NAME    : ROOM
//	FUNCTION NAME : MODIFY
//	DETAILS       : IT MODIFY THE ROOM RECORD IN THE ROOM
//                   FILE (ROOM.DAT).
//**********************************************************

void room :: modify(void)
{
	clrscr() ;
	int valid ;
	char ch ;
	char t_rcode[5] ;
	int t_roomno , tr ;
	char t_status ;
	float t_tarriff ;
	fstream file ;
	file.open("ROOM.DAT", ios::out | ios::ate) ;
	gotoxy(1,3) ;
	cout <<"Enter the Room no. to be modified " ;
	cin >>tr ;
	if ( !room_found( tr ) )
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ;	clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	display_record(tr) ;
	gotoxy(1,10) ;
	cout <<"Do you want to modify this Room Record (y/n) : " ;
	do
	{
		valid = 1 ;
		gotoxy(48,10) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,9) ;	clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'N')
		return ;
	gotoxy(1,12) ;
	cout <<"ENTER THE NEW DATA FOR THE ROOM" ;
	gotoxy(1,14) ;
	cout <<"Code     :  " ;
	gotoxy(1,15) ;
	cout <<"Room no. :  " ;
	gotoxy(1,16) ;
	cout <<"Status   :  " ;
	gotoxy(1,17) ;
	cout <<"Tarriff  :  " ;
	do
	{
		valid = 1 ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM CODE (SS/SR/DR/DS)" ;
		gotoxy(13,14) ;
		cin >>t_rcode ;
		strupr(t_rcode) ;
		char *string[4] = {"SS","DR","SR","DS"} ;
		int result , count = 0 ;
		for ( int i=0; i<4; i++ )
		{
			result = strcmpi(t_rcode,string[i]) ;
			if ( result != 0 )
			count++ ;
		}
		if ( count == 4 )
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"INVALID CODE" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,14) ; clreol() ;
		}
	} while ( valid == 0 ) ;
	do
	{
		valid = 1 ;
		gotoxy(1,25) ; clreol() ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM NUMBER" ;
		gotoxy(13,15) ;
		cin >>t_roomno ;
		if ( room_found( t_roomno ) && t_roomno != tr )
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"ROOM NO. ALREADY EXIST" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,15) ; clreol() ;
		}
	} while ( !valid ) ;
	do
	{
		valid = 1 ;
		gotoxy(1,25) ;	clreol() ;
		gotoxy(1,25) ;
		cout <<"ENTER THE ROOM STATUS : V=vacant, O=occupied" ;
		gotoxy(13,16) ;
		cin >>t_status ;
		t_status = toupper(t_status) ;
		if (t_status != 'O' &&  t_status != 'V')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(1,24) ;
			cout <<"INVALID DATA ENTERED" ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			gotoxy(1,24) ;	clreol() ;
			gotoxy(1,25) ;	clreol() ;
			gotoxy(13,16) ; clreol() ;
		}
	} while ( !valid ) ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE TARRIFF FOR THE ROOM" ;
	gotoxy(13,17) ;
	cin >>t_tarriff ;
	gotoxy(1,19) ;
	cout <<"Do you want to save the record (y/n)  :  " ;
	do
	{
		valid = 1 ;
		gotoxy(42,19) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,19) ; clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'Y')
	{
		int recno ;
		recno = recordno(tr) ;
		int location ;
		location = (recno-1) * sizeof(room) ;
		file.seekp(location) ;
		strcpy(roomcode,t_rcode) ;
		roomno  = t_roomno  ;
		status  = t_status  ;
		tarriff = t_tarriff ;
		file.write((char *) this, sizeof(room)) ;
	}
	file.close () ;
}


//**********************************************************
//	CLASS NAME    : ROOM
//	FUNCTION NAME : DELETION
//	DETAILS       : IT DELETES THE ROOM RECORD IN THE ROOM
//                   FILE (ROOM.DAT).
//**********************************************************

void room :: deletion(void)
{
	clrscr() ;
	int valid ;
	char ch ;
	int t_roomno ;
	gotoxy(1,3) ;
	cout <<"Enter the Room no. to be deleted " ;
	cin >>t_roomno ;
	if ( !room_found( t_roomno ) )
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ; clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	display_record(t_roomno) ;
	gotoxy(1,10) ;
	cout <<"Do you want to delete this Room Record (y/n) : " ;
	do
	{
		valid = 1 ;
		gotoxy(48,10) ;
		ch = getche() ;
		ch = toupper(ch) ;
		if (ch != 'Y' && ch != 'N')
		{
			valid = 0 ;
			sound(500) ;
			delay(100) ;
			nosound() ;
			gotoxy(42,9) ;	clreol() ;
		}
	} while ( !valid ) ;
	if (ch == 'N')
		return ;
	fstream file ;
	file.open("ROOM.DAT", ios::in) ;
	fstream temp ;
	temp.open("temp.dat", ios::out) ;
	while ( !file.eof() )
	{
		file.read((char *) this, sizeof(room)) ;
		if ( file.eof() )
			break ;
		if ( roomno != t_roomno )
			temp.write((char *) this, sizeof(room)) ;
	}
	file.close() ;
	temp.close() ;
	file.open("ROOM.DAT", ios::out) ;
	temp.open("temp.dat", ios::in) ;
	temp.seekg(0) ;
	while ( !temp.eof() )
	{
		temp.read((char *) this, sizeof(room)) ;
		if ( temp.eof() )
			break ;
		file.write((char *) this, sizeof(room)) ;
	}
	file.close() ;
	temp.close() ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : DISPLAY_LIST
//	DETAILS       : IT DISPLAYS THE LIST OF THE CUSTOMER
//                   RECORDS
//**********************************************************

void customer :: display_list(void)
{
	clrscr() ;
	fstream file ;
	file.open("CUSTOMER.DAT", ios::in) ;
	file.seekg(0) ;
	int row = 5 , found = 0 , pageno = 1 , total = 0 ;
	gotoxy(18,1) ;
	cout <<"LIST OF CUSTOMERS" ;
	gotoxy(1,3) ;
	cout <<" Room no.  Name                  Phone        Room service   Advance   Misc." ;
	while (file.read((char *) this, sizeof(customer)))
	{
		total++ ;
		delay(20) ;
		found = 1 ;
		gotoxy(2,row) ;
		cout <<roomno ;
		gotoxy(12,row) ;
		puts(name) ;
		fflush(stdout) ;
		gotoxy(34,row) ;
		cout	<<phone ;
		gotoxy(47,row) ;
		cout <<room_srv ;
		gotoxy(62,row) ;
		cout <<advance ;
		gotoxy(72,row) ;
		cout <<misc ;
		if ( row == 23 )
		{
			row = 5 ;
			gotoxy(66,1) ;
			cout <<"Page no. : " <<pageno ;
			pageno++ ;
			gotoxy(1,25) ;
			cout <<"Press any key to continue..." ;
			getche() ;
			clrscr() ;
			gotoxy(18,1) ;
			cout <<"LIST OF CUSTOMERS" ;
			gotoxy(1,3) ;
			cout <<" Room no.  Name                  Phone        Room service   Advance   Misc." ;
		}
		else
			row++ ;
	}
	if ( !found )
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,5) ;
		cout <<"Records not found" ;
	}
	gotoxy(66,1) ;
	cout <<"Page no. : " <<pageno ;
	gotoxy(1,25) ;
	cout <<"Press any key to continue..." ;
	getche() ;
	clrscr() ;
	gotoxy(5,5) ;
	cout <<"Total no. of Customers = " <<total ;
	gotoxy(1,25) ;
	cout <<"Press any key to continue..." ;
	getche() ;
	file.close () ;
}


//**********************************************************
//	CLASS NAME    : CUSTOMER
//	FUNCTION NAME : CHECKIN
//	DETAILS       : IT ADDS THE RECORDS IN THE CUSTOMER
//                   FILE (CUSTOMER.DAT)
//**********************************************************

void customer :: checkin(void)
{
	room r ;
	char ch ;
	int valid ;
	int   t_roomno , t_no_cust ;
	char  t_name[31] , t_address[35] , t_phone[15] , t_nation[16] , t_passport[30] ;
	float t_advance , t_misc , t_room_srv ;
	clrscr() ;
	gotoxy(1,1) ;
	cout <<"Enter the details of the Customer" ;
	gotoxy(1,3) ;
	cout <<"Room no.         : " ;
	gotoxy(1,4) ;
	cout <<"Name             : " ;
	gotoxy(1,5) ;
	cout <<"No. of guests    : " ;
	gotoxy(1,6) ;
	cout <<"Address          : " ;
	gotoxy(1,7) ;
	cout <<"Phone            : " ;
	gotoxy(1,8) ;
	cout <<"Nationality      : " ;
	gotoxy(1,9) ;
	cout <<"Passport no.     : " ;
	gotoxy(1,11) ;
	cout <<"Advance          : " ;
	gotoxy(1,12) ;
	cout <<"Miscellineous    : " ;
	gotoxy(1,13) ;
	cout <<"Room service     : " ;
	gotoxy(20,3) ;
	cin >>t_roomno ;
	char t_status ;
	t_status = r.room_status(t_roomno) ;
	if (!r.room_found(t_roomno) || t_status == 'O')
	{
		sound(500) ;
		delay(100) ;
		nosound() ;
		gotoxy(1,25) ;	clreol() ;
		gotoxy(1,24) ;
		cout <<"ROOM NO. NOT FOUND OR NOT VACANT" ;
		gotoxy(1,25) ;
		cout <<"Press any key to continue..." ;
		getche() ;
		return ;
	}
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE NAME OF THE CUSTOMER" ;
	gotoxy(20,4) ;
	gets(t_name) ;
	strupr(t_name) ;
	fflush(stdin) ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE NO. OF GUESTS WITH THE CUSTOMER" ;
	gotoxy(20,5) ;
	cin >>t_no_cust ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE ADDRESS OF THE CUSTOMER" ;
	gotoxy(20,6) ;
	gets(t_address) ;
	fflush(stdin) ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER THE PHONE NO. OF THE CUSTOMER, ENTER '-' FOR NO PHONE NO." ;
	gotoxy(20,7) ;
	cin >>t_phone ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER NATIONALITY OF THE CUSTOMER" ;
	gotoxy(20,8) ;
	gets(t_nation) ;
	fflush(stdin) ;
	gotoxy(1,25) ;	clreol() ;
	gotoxy(1,25) ;
	cout <<"ENTER PASSPORT NO. OF THE CUSTOMER" ;
	gotoxy(20,9) ;
	gets(t_passport) ;
	fflush(stdin) ;
	gotoxy(1,25) ; clreol() ;

⌨️ 快捷键说明

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