Professional Documents
Culture Documents
Hotel Management
Hotel Management
SCHOOL
MYLAUDY.
Project Report submitted to
All India Senior Secondary Practical Examination in
Computer Science
HOTEL
MANAGEMENT SYSTEM
Submitted by
AL MUDHIR
CBSE - Grade XII
MARCH – 2022
(Mylaudy, Kanyakumari -629 024)
COMPUTER SCIENCE
Certified to be the Bonafide Record of work done by AL MUDHIR of Std
XII in the Computer Science Lab of the MOUNT LITERA ZEE
SCHOOL, MYLAUDY, KANYAKUMARI, during the year 2021 – 2022.
Date: Teacher-in-charge:
2. PROJECT DESCRIPTION
3. FUNCTIONS USED
4. SOURCE CODE
5. SAMPLE OUTPUT
6. CONCLUSION
7. BIBLIOGRAPHY
1.OVERVIEW OF PYTHON AND ITS
VARIOUS OBJECTS
Python too supports file handling and allows users to handle files
i.e., to read and write files, along with many other file handling options, to
operate on files. The concept of file handling has stretched over various other
languages, but the implementation is either complicated or lengthy, but alike
other concepts of Python, this concept here is also easy and short. Python treats
file differently as text or binary and this is important. Each line of code includes
a sequence of characters and they form text file. Each line of a file is terminated
with a special character, called the EOL or End of Line characters like comma
{,} or newline character. It ends the current line and tells the interpreter a new
one has begun. Let’s start with Reading and Writing files. There are also
various other functions that help to manipulate the files and its contents. One
can explore various other functions in Python Docs.
2.PROJECT DESCRIPTION
Technology Used:
• Python and mysql connectivity
• Mysql databases for storing datas.
3.FUNCTIONS USED
import mysql.connector
from mysql.connector import Error
from mysql.connector import errorcode
from datetime import datetime
from dateutil.relativedelta import relativedelta
from dateutil.parser import parse
from fpdf import FPDF
import webbrowser
def add_roomtype():
print("Enter Details of Newly Created Room Type ")
id1=int(input("Enter ROOM TYPE ID "))
type1=input("Enter Type of Room ")
cap=int(input("Enter Capacity "))
rent=int(input("Enter Rent for Type of room "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_insert_query = (""" INSERT INTO roomtype(id,type,capacity,rentpd)
VALUES (%d,%s,%d,%d)"""%(id1,"'"+type1+"'",cap,rent))
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_roomtype_type():
id1=int(input("Enter ROOM TYPE ID for Modify "))
print("Re Enter Details of Newly Created Room Type ")
type1=input("Enter Type of Room ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE ROOMTYPE SET TYPE=%s where id=
%d"""%("'"+type1+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_roomtype_capacity():
id1=int(input("Enter ROOM TYPE ID for Modify "))
print("Re Enter Details of Newly Created Room Type ")
cap=int(input("Enter Capacity of Room "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update = (""" UPDATE ROOMTYPE SET CAPACITY=%d where
id=%d"""%(cap,id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_roomtype_rent():
id1=int(input("Enter ROOM TYPE ID for Modify "))
print("Re Enter Details of Newly Created Room Type ")
cap=int(input("Enter Rent of Room per day "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE ROOMTYPE SET RENTPD=%d where id=
%d"""%(cap,id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def add_guest():
print("Enter Details of Newly Created Room Type ")
id1=int(input("Enter GUEST ID "))
firstname=input("Enter First Name of Guest ")
lastname=input("Enter Last Name of Guest ")
mdate=input("Enter Date of membership of Guest ")
address=input("Enter Address of Guest ")
city=input("Enter City of Guest ")
pincode=input("Enter Pincode of city of Guest ")
mobileno=input("Enter Mobile No of city of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_insert_query=("""INSERT INTO GUEST
(id,FIRSTNAME,LASTNAME,MDATE,ADDRESS,CITY,PIN,MOBIL
ENO)VALUES(%d,%s,%s,%s,%s,%s,%s,%s)"""%
(id1,"'"+firstname+"'","'"+lastname+"'","'"+mdate+"'","'"+address+"'","'"
+city+"'","'"+pincode+"'","'"+mobileno+"'"))
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_firstname():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
firstname=input("Enter First Name of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET FIRSTNAME=%s where id=
%d"""%("'"+firstname+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_lastname():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
lastname=input("Enter Last Name of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET LASTNAME=%s where id=
%d"""%("'"+lastname+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_mdate():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
mdate=input("Enter Date of Membership of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET MDATE=%s where id=%d"""%
("'"+mdate+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_address():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
address=input("Enter Address of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET ADDRESS=%s where id=
%d"""%("'"+address+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_city():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
city=input("Enter City of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET CITY=%s where id=%d"""%
("'"+city+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_pincode():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
pin=input("Enter Pincode of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET PIN=%s where id=%d"""%
("'"+pin+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_guest_mobileno():
id1=int(input("Enter GUEST ID for Modify "))
print("Re Enter Details of Guest ")
mobileno=input("Enter Mobile No of Guest ")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE GUEST SET MOBILENO=%s where id=
%d"""%("'"+mobileno+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def add_room():
print("Enter Details of Newly Created Room ")
id1=int(input("Enter ROOM ID "))
roomno=int(input("Enter Newly Created Room No "))
status=int(input("Enter Status 1 for working and 0 for not Working "))
roomtypeid=int(input("Enter Room Type id which was created in room type
"))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_insert_query=("""INSERT INTO room
(id,roomno,func_status,room_type_id)VALUES(%d,%d,%d,%d)"""%
(id1,roomno,status,roomtypeid))
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_room_roomno():
id1=int(input("Enter ROOM ID for Modify "))
print("Re Enter Details of ROOM ")
roomno=int(input("Enter Room No of Room "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE ROOM SET ROOMNO=%d where id=
%d"""%(roomno,id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def modify_room_status():
id1=int(input("Enter ROOM ID for Modify "))
print("Re Enter Details of ROOM ")
status=int(input("Enter Status of Room 1 for WORKING AND 0 FOR NOT
WORKING "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE ROOM SET func_status=%d where id=
%d"""%(status,id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def new_booking():
print("Enter Details of New Booking ")
id1=int(input("Enter New Booking ID "))
cindate2=input("Enter Check In Date ")
cindate=parse(cindate2)
noofdaysstay=int(input("Enter No of Days Stay "))
roomtypeid=int(input("Enter Room Type id for booking "))
noofrooms=int(input("Enter No of Rooms "))
guestid=int(input("Enter Guest id "))
madeby=input("Enter Made By ")
cindate1=datetime.date(cindate)
reservationdate=datetime.date(datetime.now())
reservationdate1=reservationdate.strftime('%Y-%m-%d')
coutdate=cindate1+relativedelta(days=noofdaysstay)
coutdate2=coutdate.strftime('%Y-%m-%d')
print(cindate2)
print(coutdate2)
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_insert_query=("""INSERT INTO reservation(id, noofrooms, cindate,
countdate, madeby, guestid, reservationdate, no_of_days_stay,
roomtypeid)VALUES(%d,%d,%s,%s,%s,%d,%s,%d,%d)"""%
(id1,noofrooms,"'"+cindate2+"'","'"+coutdate2+"'","'"+madeby
+"'",guestid,"'"+reservationdate1+"'",noofdaysstay,roomtypeid))
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
try:
for i in range(0,noofrooms):
id2=int(input("Enter Room ID "))
roomno2=int(input("Enter Room No "))
roomtypeid1=roomtypeid
reservationid1=id1
connection=mysql.connector.connect(host='localhost',database='ho
tel',user='root',password='razeen9486')
sql_insert_query=("""INSERT INTO reservedroom (id, roomno,
roomtypeid, reservationid)VALUES (%d, %d, %d, %d)"""%(id2,
roomno2, roomtypeid1, reservationid1))
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def cancel_booking():
id1=int(input("Enter Reservation ID for Cancel Booking "))
val=1
try:
connection= mysql.connector.connect(host='localhost', database='hotel',
user='root', password='razeen9486')
sql_update=("""UPDATE RESERVATION SET cancelled=%d where
id=%d"""%(val, id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
cancelleddate=datetime.date(datetime.now())
cancelleddate1=cancelleddate.strftime('%Y-%m-%d')
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update = (""" UPDATE RESERVATION SET cancelleddate=%s
where id=%d"""%("'"+cancelleddate1+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
val1=0
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE RESERVEDROOM SET STATUS=%d
where RESERVATIONid=%d"""%(val1,id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def guest_arrived():
print("Enter Details of Guest at Check In Time ")
id1=int(input("Enter OCCUPIED ID "))
cindate=input("Enter Check In Date ")
cintime=input("Enter Check In Time ")
roomid=int(input("Enter Room ID "))
reservationid=int(input("Enter Reservation ID "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_insert_query=("""INSERT INTO OCCUPIEDROOM (id, cindate,
cintime, roomid, reservationid) VALUES (%d, %s, %s, %d, %d)"""%
(id1, "'"+cindate+"'", "'"+cintime+"'", roomid, reservationid))
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
print ("Record inserted successfully into python_users table")
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def generate_bill():
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
#sql_select=("SELECT * FROM RESERVEDROOM")
#sql_select = ("SELECT id, GUESTID FROM RESERVEDROOM
where cancelled=True and billpaid is null")
#SELECT ID, GUESTID FROM RESERVATION WHERE
CANCELLED=1 AND BILLPAID IS NULL
sql_select = ("SELECT ID, GUESTID FROM RESERVATION WHERE
CANCELLED=0 AND BILLPAID = 1")
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
print("Bill going to generate ")
print("Customer Id Reservation Id ")
for x in result:
print(x[0]," ",x[1])
#for x in result:
# print(x[0],x[1],x[2],x[3])
#generate_pdf()
except mysql.connector.Error as error :
connection.rollback() #rollback if any exception occured
print("Failed inserting record into python_users table {}".format(error))
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
print()
print("1. Add Room Type ")
print("2. Mofigy Room Type ")
print("3. MOdify Room Capacity ")
print("4. MOdify Room Rent per Day ")
print("5. Exit ")
ch1=int(input("Enter Choice from above "))
if (ch1>=1 or ch1 <= 5):
break;
if (ch1==5):
break
if (ch1==1):
add_roomtype()
if (ch1==2):
modify_roomtype_type()
if (ch1==3):
modify_roomtype_capacity()
if (ch1==4):
modify_roomtype_rent()
if (ch==3):
while(True):
while(True):
print()
print(“*************GUEST DETAILS MENU***********”
print()
print("1. Add New Guest ")
print("2. Mofigy Guest First Name ")
print("3. MOdify Guest Last Name ")
print("4. MOdify Guest Membership Date ")
print("5. MOdify Guest Address ")
print("6. Modify Guest City ")
print("7. Modify Guest Pincode ")
print("8. Modify Guest Mobile No ")
print("9. Exit ")
ch_guest=int(input("Enter Choice from above "))
if (ch_guest>=1 or ch_guest <= 9):
break;
if (ch_guest==9):
break
if (ch_guest==1):
add_guest()
if (ch_guest==2):
modify_guest_firstname()
if (ch_guest==3):
modify_guest_lastname()
if (ch_guest==4):
modify_guest_mdate()
if (ch_guest==5):
modify_guest_address()
if (ch_guest==6):
modify_guest_city()
if (ch_guest==7):
modify_guest_pincode()
if (ch_guest==8):
modify_guest_mobileno()
if (ch==4):
while(True):
while(True):
print()
print(“**************room details menu*************”)
print()
print("1. Add New Room ")
print("2. Mofigy Room No ")
print("3. MOdify Room Status ")
print("4. Exit ")
ch_room=int(input("Enter Choice from above "))
if (ch_room>=1 or ch_room <= 4):
break
if (ch_room==4):
break
if (ch_room==1):
add_room()
if (ch_room==2):
modify_room_roomno()
if (ch_room==3):
modify_room_status()
if (ch==2):
while(True):
while(True):
print()
print(“**************reservationmenu*******************”)
print()
print("1. New Booking ")
print("2. Modify Booking Date ")
print("3. Cancel Booking ")
print("4. Exit ")
ch_res=int(input("Enter Choice from above "))
if (ch_res>=1 or ch_res <= 4):
break
if (ch_res==4):
break
if (ch_res==1):
new_booking()
if (ch_res==2):
cancel_booking()
new_booking()
if (ch_res==3):
cancel_booking()
if (ch==5):
guest_arrived()
if (ch==6):
guest_checkout()
if (ch==7):
billing()
billpay()
if (ch==8):
generate_bill()
5.SAMPLE OUTPUT
6.CONCLUSION
• https://www.google.com
• https://www.wikipedia.org
• https://www.slideshare.net