You are on page 1of 56

MOUNT LITERA ZEE

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:

REGISTER NO. ____________________

Submitted for All India Senior Secondary Practical Examination in

Computer Science held on ______________________________at

Mount Litera Zee School, Mylaudy.

Principal Internal Examiner External


Examiner
ACKNOWLEDGEMENT

I would like to express my sincere thanks to our Chairman

T.Thillai Chellvam, Principal S. Deepa Selvi for their

encouragement and support to work on this Project. I am

grateful to my computer science teacher Mrs. Nithya Preya

and to the computer science department teachers, lab teachers

for the constant guidance and support to complete the project.

Also I would like to thank my parents, family members and

friends who helped me to complete this project successfully.


TABLE OF CONTENT

1. OVERVIEW OF PYTHON AND ITS VARIOUS OBJECTS

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 is an interpreted, object-oriented, high-level programming


language with dynamic semantics. Its high-level built in data structures,
combined with dynamic typing and dynamic binding, make it very attractive for
Rapid Application Development, as well as for use as a scripting or glue
language to connect existing components together. Python's simple, easy to
learn syntax emphasizes readability and therefore reduces the cost of program
maintenance. Python supports modules and packages, which encourages
program modularity and code reuse. The Python interpreter and the extensive
standard library are available in source or binary form without charge for all
major platforms, and can be freely distributed.
Somewhat more formally, in Python, data takes the form of objects
—either built-in objects that Python provides, or objects we create using Python
or external language tools such as C extension libraries. Although we’ll firm up
this definition later, objects are essentially just pieces of memory, with values
and sets of associated operations.
1. Programs are composed of modules.
2. Modules contain statements.
3. Statements contain expressions.
4. Expressions creates and process objects
5. Built-in objects make programs easy to write. For simple tasks, built-in
types are often all you need to represent the structure of problem domains.
Because you get powerful tools such as collections (lists) and search tables
(dictionaries) for free, you can use them immediately. You can get a lot of
work done with Python’s built-in object types alone.
6. Built-in objects are components of extensions. For more complex tasks,
you still may need to provide your own objects, using Python classes or C
language interfaces. But as you’ll see in later parts of this book, objects
implemented manually are often built on top of built-in types such as lists
and dictionaries. For instance, a stack data structure may be implemented as
a class that manages or customizes a built-in list.
7. Built-in objects are often more efficient than custom data structures.
Python’s built-in types employ already optimized data structure algorithms
that are implemented in C for speed. Although you can write similar object
types on your own, you’ll usually be hard-pressed to get the level of
performance built-in object types provide.
8. Built-in objects are a standard part of the language. In some ways,
Python borrows both from languages that rely on built-in tools (e.g., LISP)
and languages that rely on the programmer to provide tool implementations
or frameworks of their own (e.g., C++). Although you can implement unique
object types in Python, you don’t need to do so just to get started. Moreover,
because Python’s built-ins are standard, they’re always the same; proprietary
frameworks, on the other hand, tend to differ from site to site.
9. Easy-to-learn − Python has few keywords, simple structure, and a clearly
defined syntax. This allows the student to pick up the language quickly.
10.Easy-to-read − Python code is more clearly defined and visible to the eyes.
11.Easy-to-maintain − Python's source code is fairly easy-to-maintain.
12.A broad standard library − Python's bulk of the library is very portable
and cross-platform compatible on UNIX, Windows, and Macintosh.
13.Interactive Mode − Python has support for an interactive mode which
allows interactive testing and debugging of snippets of code.
14.Portable − Python can run on a wide variety of hardware platforms and has
the same interface on all platforms.
15.Extendable − You can add low-level modules to the Python interpreter.
These modules enable programmers to add to or customize their tools to be
more efficient.
16.Databases − Python provides interfaces to all major commercial databases.
17.GUI Programming − Python supports GUI applications that can be created
and ported to many system calls, libraries and windows systems, such as
Windows MFC, Macintosh, and the X Window system of Unix.
18.Scalable − Python provides a better structure and support for large programs
than shell scripting.

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

Scope of the project


The objective of the software project is to develop a computerized
management system and to automate the functions of a HOTEL
MANAGEMENT SYSTEM. This software project is also aimed to enhance
the current record keeping systems, which will help managers to retrieve the up-
to-date information at right time in right shape.
Functional Features
The proposed software system is expected to do the following
functionality:-
 To provide a user friendly and centralized environment for HOTEL
MANAGEMENT activities.
 The proposed system should maintain all the records of bookings and
Date to Check in and Check Out and generate the required reports and
information when required.
In its current scope, the software enables user to retrieve and update the
information from centralized database designed with MYSQL.

Technology Used:
• Python and mysql connectivity
• Mysql databases for storing datas.
3.FUNCTIONS USED

def add_roomtype(): This function adds or inserts details


of type of the new room.

def modify_roomtype_type(): This function modifies or alters the


type of the selected room.

def modify_roomtype_capacity(): This function modifies or alters the


capacity of the selected room.

def modify_roomtype_rent(): This function modifies or changes the


rent details of the selected room.

def add_guest(): This function inserts the details of the


guests or customers into the table
“guest”.

def modify_guest_firstname(): This function alters the firstname of


the selected guest.

def modify_guest_lastname(): This function alters the lastname of


the selected guest.

def modify_guest_mdate(): This function alters the date of


membership of selected guest.

def modify_guest_address(): This function modifies the address of


the selected guest.

def modify_guest_city(): This function modifies the city of the


selected guest.

def modify_guest_pincode(): This function modifies the pincode of


the selected guest.

def modify_guest_mobileno(): This function modifies the mobile


number of the selected guests.

def add_room(): This function adds details of newly


created room.

def modify_room_roomno: This function modifies the room


number of selected room.

def modify_room_status(): This function modifies the


status(working or non working) of the
room.
def new_booking(): This function adds the details of new
bookings for rooms.

def cancel_booking(): This function cancels the booking of


rooms by a guest.

def guest_arrived(): This function adds the details of the


guest at check in time into the table
“occupied room”

def guest_checkout(): This function adds the details of


checkout.

def billpay(): This function stores the details of


amount paid .

def generate_bill(): This function generates the final bill


amount.
4.SOURCE CODE

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")

print("Enter Details of HOSTED at Check In Time ")


id11=int(input("Enter HOSTED ID "))
guestid=int(input("Enter Guest ID "))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_insert_query=("""INSERT INTO hostedat (id, guestid,
occupiedroomid) VALUES (%d, %d, %d)"""%(id11, guestid, id1))
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 guest_checkout():
id1=int(input("Enter Reservation ID for Check Out "))
countdate=input("Enter Check Out Date ")
counttime=input("Enter Check Out Time ")
val=0
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE occupiedroom SET coutdate=%s where
reservationid=%d"""%("'"+countdate+"'",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")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE occupiedroom SET couttime=%s where
reservationid=%d"""%("'"+counttime+"'",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")
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_update=("""UPDATE reservation SET cancelled=%s 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")
def billing():
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 = 0")
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()
def billpay():
print("Do you want to Make Paymnet Y(1)")
reservationid=int(input("Enter Reservation Id :"))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_select=("""SELECT G.FIRSTNAME, G. LASTNAME,
RT.RENTPD, R.NO_OF_DAYS_STAY, R.CINDATE,
R.COUNTDATE FROM ROOMTYPE RT, RESERVEDROOM RR,
RESERVATION R , GUEST G WHERE R.ID=%d AND
R.ID=RR.RESERVATIONID AND RR.ROOMTYPEID=RT.ID AND
G.ID=R.GUESTID"""%(reservationid))
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
for x in result:
fname=x[0]
sname=x[1]
rent=x[2]
nod=x[3]
cindate=x[4]
coutdate=x[5]
amtpayable=rent*nod
gst=amtpayable*18/100
netamt=amtpayable+gst
print("Mr / Mrs / Ms ",fname," ",sname)
print("Total Bill Payable : ",amtpayable)
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()
try:
val=1
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
#sql_update_cancelled=("""UPDATE RESERVATION SET cancelled=
%d where id=%d"""%(val,reservationid))
sql_update_billpaid = (""" UPDATE RESERVATION SET billpaid=%d
where id=%d"""%(val,reservationid))
cursor = connection.cursor()
#result = cursor.execute(sql_update_cancelled)
result = cursor.execute(sql_update_billpaid)
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("Do you wnat to Make Paymnet Y(1)")


reservationid=int(input("Enter Reservation Id :"))
try:
connection=mysql.connector.connect(host='localhost',database='hotel',us
er='root',password='razeen9486')
sql_select=("""SELECT G.FIRSTNAME, G.LASTNAME,
RT.RENTPD, R.NO_OF_DAYS_STAY, R.CINDATE, R.COUNTDATE
FROM ROOMTYPE RT, RESERVEDROOM RR, RESERVATION R ,
GUEST G WHERE R.ID=%d AND R.ID=RR.RESERVATIONID AND
RR.ROOMTYPEID=RT.ID AND G.ID=R.GUESTID"""%(reservationid))
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
for x in result:
fname=x[0]
sname=x[1]
rent=x[2]
nod=x[3]
cindate=x[4]
coutdate=x[5]
amtpayable=rent*nod
gst=amtpayable*18/100
netamt=amtpayable+gst
print("Mr / Mrs / Ms ",fname," ",sname)
print("Total Bill Payable : ",amtpayable)
#generate_pdf()
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(0,5,"Hotel BHOPAL !", ln=0, align="L")
pdf.cell(0,5,"Receipt No. "+str(reservationid), ln=1, align="R")
pdf.cell(0,5,"Station Road !", ln=0, align="l")
pdf.cell(0,5,"Date . "+str(coutdate), ln=1, align="R")
pdf.cell(0,5,"BHOPAL M.P. !", ln=1, align="L")
pdf.cell(0, 10,'Invoice', 0, 1, align='C')
pdf.cell(0,0,"---------------------------",ln=1,align="L")
pdf.cell(160,10,"Guest Name",ln=0,align="L")
pdf.cell(160,10,fname+" "+sname,ln=1,align="L")
pdf.cell(0,0,"---------------------------",ln=1,align="L")
pdf.cell(160,10," Check In Date ",ln=0,align="L")
pdf.cell(160,10,str(cindate),ln=1,align="L")
pdf.cell(160,10," Check Out Date ",ln=0,align="L")
pdf.cell(160,10,str(coutdate),ln=1,align="L")
pdf.cell(160,10," Total Days ",ln=0,align="L")
pdf.cell(160,10,str(nod),ln=1,align="L")
pdf.cell(160,10," Rent Per day ",ln=0,align="L")
pdf.cell(160,10,str(rent),ln=1,align="L")
pdf.cell(160,10," Rented Amount without Tax ",ln=0,align="L")
pdf.cell(160,10,str(amtpayable),ln=1,align="L")
pdf.cell(160,10," SGST 9% & CGST 9% ",ln=0,align="L")
pdf.cell(160,10,str(gst),ln=1,align="L")
pdf.cell(160,10," Total Amount Payable ",ln=0,align="L")
pdf.cell(160,10,str(netamt),ln=1,align="L")
pdf.cell(0,0,"-----------------------------",ln=1,align="L")
pdf.cell(0,100,"Signature ",ln=1,align="R")
pdf.output("simple_demo.pdf")
url='file:///G:/PERSONAL/SCHOOL/IN-SERVICE-COURSE/SPELL-
2-BPL-NO2/simple_demo.pdf'
#chrome_path='C:/ProgramFiles(x86)/Google/Chrome/Applicatio
n/chrome.exe %s'
webbrowser.open(url)
pdf.cell(0,0,"----------------------------------",ln=1,align="L")
pdf.cell(0,100,"Signature ",ln=1,align="R")

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()
while(True):
while(True):
print()
print("**********************MainMenu*************************")
print()
print("1. Room Type Details ")
print("2. Reservation ")
print("3. Guest Details ")
print("4. Romm Details ")
print("5. Guest Arrival Check In ")
print("6. Guest Departure Check Out ")
print("7. Billing ")
print("8. Generate Old Bill ")
print("8. Exit ")
ch=int(input("Enter Choice from above "))
if (ch>=1 or ch <= 9):
break;
if (ch==9):
break
if (ch==1):
while(True):
while(True):
print()
print("*************MainMenu**********
**********")

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

Hotel management system now-a-days have the advantage of modernization.


Computer have done the work more easy. Computer is playing a important role
in management. Reports are made on daily basis for every customers check in
or check out which can be easily seen by the management. Hotel management
system has also primary purpose is to provide facilities to customers. A
software forcomputers makes the things many times easy, these are made as
user friendly and to keep an check and balance in hotel management and
accounts as well. So, these things are important.
With this project, I have applied the 12th standard concepts of python
programming that i have studied. I have also dealt with different programming
errors that have occurred duting code creation. Creating this project has
strengthened my understanding of this application.
I believe this program shall be useful to hotel staff in managing their business
7.BIBLIOGRAPHY

• https://www.google.com
• https://www.wikipedia.org
• https://www.slideshare.net

You might also like