0% found this document useful (0 votes)
18 views19 pages

Hotel Management and Room Booking System Project

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views19 pages

Hotel Management and Room Booking System Project

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Certificate

This is to certify that _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ of class


XII Roll No. _ _ _ _ _ has satisfactorily completed his Computer Science
(083) project as prescribed by the CBSE during the Academic year 2024-25.

Teacher’s Signature Principal’s Signature

Page 1 of 19
Acknowledgement
I would like to express my special thanks of gratitude to my Computer
Teacher Abhishek sir as well as our School Principal Sister Theresal who
gave me the excellent opportunity to do this project on Hotel Management
and Room Booking System, which also helped me in doing a lot of Research
and I came to know about so many new things. I am really thankful to
them.
Secondly, I would also like to thank my parents and friends who
helped me a lot in finishing this Project within the limited time. Just because
of them I was able to complete it.
I am Making this Project not only for marks but also to improve my
knowledge.
Thanks once again to all who helped me.

Name of Student

Page 2 of 19
INDEX
Sr. No. Date Subject Page Marks T.Sign
1 26/6/2024 Introduction 4
About
Python-
2 28/6/2024 5
MySQL
Connectivity
Database
3 1/7/2024 (The back 5
end)
4 3/7/2024 Why Python 5
Hotel
Management
and Room
5 5/7/2024 Booking 6
System
Source Code
of Python
Output of
Hotel
Management
6 15/7/2024 13
and Room
Booking
System
7 19/7/2024 Conclusion 18
SQL Queries
8 22/7/2024 for the table 19
hotel

Page 3 of 19
Project on Hotel Management and Room Booking System
Introduction
This project is based on hotel management and room booking system. The project is developed on
Python by interfacing it with MySQL. This system can insert records, update records delete records, display
records and generate reports, i.e., of a particular person we want. This project serves the following purposes:
1. Adding customer details
2. Allotting the rooms to the customers
3. Searching and updating customer records
4. Removing undesirable details and records
5. Generating a report of the customers of the hotel
The important modules used in the project are as follows:
➔ main menu
➔ create table
➔ display_struc
➔ add
➔ search
➔ display
➔ edit
➔ delete
➔ generate
Name of the Database: project
Name of the Table: hotel
Database Table Structure

Records of Table Hotel

Page 4 of 19
About Python-MySQL Connectivity
While designing real-life applications, certain situations arise pertaining to storing some important
and necessary information by the user. Usually, the data inputted by the user along with the generated
output are displayed but not stored.
Since all the program execution takes place inside the RAM, which is a temporary memory, and as
soon as we close the form, its contents (form input and generated output) get erased. They can't be retrieved
since they are not getting saved on a hard disk (or any secondary storage device)
Thus, when the application is executed the second time, it requires a new set of inputs from the user.
This limitation can be overcome by sending the output generated and saving the input fetched from the user
in a database created at the back-end of the application. The input is fetched from the user using Python
Interface. This is termed as the Front-end Interface of the application.

Database (The Back-end)


While working with an application, it is required to save data permanently on some secondary
storage device, which is usually the hard disk, so that data can be stored on it for future reference,
modification, deletion and retrieval. An application usually stores a lot of data in the form of a database which
is not directly accessible to the user. This database is used by the application to suitable response to the user.
This database is called Back-end Database

We have already learnt how to create databases, tables and how to perform query processing on these
tables using SQL commands like CREATE, UPDATE, ALTER, INSERT, DELETE, SELECT and so on
in various forms according to their specific syntax structures. We shall be implementing all these DDL and
DML commands of SQL through Python Interface.
Why Python
Python is a flexible, portable, easy to learn and modifiable language. So, we are integrating MySQL
with Python interface for executing any database applications. The various reasons to use Python for
programming database applications are:
➔ Programming in Python is arguably more efficient and faster as compared to other languages.
➔ Python is famous for its portability.
➔ It is platform-independent.
➔ Python supports SQL cursors.
➔ In many programming languages, the application developer needs to take care of the open and closed
connections of the database to avoid further exceptions and errors. In Python, these connections are
taken care of.
➔ Python supports Relational database systems.
➔ Python database APIs are compatible with various databases, so it is very easy to migrate and port
database application interfaces.

Page 5 of 19
Coding
import mysql.connector

def add():

mydb = mysql.connector.connect (host="localhost", user="root",


passwd="school", database="Project")

mycur = mydb.cursor()

ch='y';

while ch =='y' or ch == 'Y':


cno = int(input("Enter the Customer Number: "))

cname = input ("Enter the Customer Name: ")

address = input ("Enter the Customer Address: ")

roomno = int(input ("Enter the Room Number: "))

mobileno = int(input("Enter the Mobile Number: "))


check_in = input ("Enter the Check-In Date (YYYY-MM-DD): ")

check_out = input ("Enter the Check-Out Date ( YYYY-MM-DDI: ")


adv_pay = float (input ("Enter the Advance Amount: "))

room_type = int(input("Enter the Room Category: (1: Deluxe 2: Semi-


Deluxe 3:Standard)"))
if room_type == 1:

room_type = "Deluxe"

elif room_type == 2:

room_type = "Semi-Deluxe"

elif room_tyрe == 3:
room_tyрe = "Standard"

else:

print("Enter the correct Cholos")

str = "INSERT INTO Hotel values ({}, '{}', '{}', {}, {}, '{}', '{}',
{}, '{}')"

query = (str.format(cno, cname, address, roomno, mobileno, check_in,


check_out, adv_pay, room_type))

mycur.execute(query)

mydb.commit()
print("\nRecord inserted\n")

ch = input("Do you want to add more records? (y/n): ")

def search():

Page 6 of 19
mydb = mysql.connector.connect(host="localhost", user="root",passwd
="school", database="project")

mycur = mydb.cursor()

cno = int(input("Enter The Customer Number: "))

str = "Select * from hotel where cno = {}"

query = str.format(cno)

print("===================================================")

mycur.execute(query)

myrec = mycur.fetchall()

for x in myrec:

cno = x[0]

cname = x[1]

address = x[2]

roomno = x[3]

mobileno = x[4]
check_in = x[5]

check_out = x[6]

adv_pay = x[7]

room_type = x[8]

print(cno, cname, address, roomno, mobileno, check_in,check_out,


adv_pay, room_type)

def display():

mydb = mysql.connector.connect (host = "localhost", user = "root", passwd


= "school", database = "project")

mycur = mydb.cursor()

mycur.execute("Select * from hotel")

print("===================================================")

myrec = mycur.fetchall()

for x in myrec:

cno = x[0]

cname = x[1]

address = x[2]

roomno = x[3]

mobileno = x[4]

check_in = x[5]

Page 7 of 19
check_out = x[6]

adv_pay = x[7]

room_type = x[8]

print(cno, cname, address, roomno, mobileno, check_in, check_out,


adv_pay, room_type)

def edit():

mydb = mysql.connector.connect(host = "localhost", user = "root",


passwd = "school", database = "project")

mycur = mydb.cursor()

mycur.execute("Select * from hotel");

print("Before Updation")

myrec = mycur.fetchall()
for x in myrec:

cno = x[0]

cname = x[1]

address = x[2]

roomno = x[3]

mobileno = x[4]

check_in = x[5]

check_out = x[6]

adv_pay = x[7]

room_type = x[8]

print (cno, cname, address, roomno, mobileno, check_in, check_out,


adv_pay, room_type)

cno = int (input("Enter The Customer Number you want to Update: "))

print("Enter the changes you want to make\n")

cname = input("Enter the Customer Name: ")

address = input("Enter the Customer Address: ")

roomno = int(input ("Enter the Room Number: "))

mobileno = int(input("Enter the Mobile Number: "))

check_in = input("Enter the Check-In Date (YYYY-MM-DD): ")

check_out = input ("Enter the Check-Out Date (YYYY-MM-DD): ")

adv_pay = float (input ("Enter the Advance Amount: "))

room_type = int(input ("Enter the Room Category: (1:Deluxe 2: Semi-


Deluxe 3:Standard)"))

if room_type == 1:
Page 8 of 19
room_type = "Deluxe"

elif room_type == 2:

room_type = "Semi-Deluxe"

elif room_type == 3:

room_type = "Standard"

else:

print("Enter the correct Choice")

mycur = mydb.cursor()

str = "Update hotel set


cname='{}',address='{}',roomno='{}',mobileno={}, check_in = '{}',
check_out='{}',adv_pay={},room_type='{}' where cno={}"

query = str.format (cname, address, roomno, mobileno, check_in,


check_out, adv_pay, room_type, cno)

mycur.execute (query)

mydb.commit()

mycur.execute("Select * from hotel")


print("===================================================")

print ("After Updation")

myrec = mycur.fetchall()

for x in myrec:

cno = x[0]
cname = x[1]

address = x[2]
roomno = x[3]

mobileno = x[4]

check_in = x[5]

print(cno, cname, address, roomno, mobileno, check_in, check_out,


adv_pay, room_type)

def delete():

mydb = mysql.connector.connect(host = "localhost", user = "root", passwd


= "school", database = "project")
mycur = mydb.cursor()

mycur.execute("select * from hotel")

print("===================================================")
print("Before Deletion")

myrec = mycur.fetchall()

Page 9 of 19
for x in myrec:

cno = x[0]

cname = x[1]

address = x[2]

roomno = x[3]

mobileno = x[4]

check_in = x[5]

check_out = x[6]

adv_pay = x[7]

room_type = x[8]

print(cno, cname, address, roomno, mobileno, check_in, check_out,


adv_pay, room_type)

cno = int(input("Enter The Customer Number: "))

str = "Delete from hotel where cno = {}"

query = str.format(cno)
mycur.execute(query)

mydb.commit()

mycur.execute(query)

print("Record Deleted")

mycur.execute("Select * from hotel")

print("===================================================")

print ("After Deletion")

myrec = mycur.fetchall()

for x in myrec:
cno = x[0]

cname = x[1]

address = x[2]

roomno = x[3]

mobileno = x[4]

check_in = x[5]

check_out = x[6]

adv_pay = x[7]

room_type = x[8]

print(cno, cname, address, roomno, mobileno, check_in, check_out,


adv_pay, room_type)

Page 10 of 19
def generate():

Tax = 0

mydb = mysql.connector.connect(host = "localhost", user = "root", passwd


= "school", database = "project")

mycur = mydb.cursor()

cno = int(input("Enter The Customer number: "))

str = "select cno, cname, address, roomno, mobileno, check_in, check_out,


adv_pay, room_type, dayofyear(check_out) - dayofyear(check_in) from hotel where
cno={}"

query = str.format(cno)

print("===================================================")

mycur.execute(query)

myrec = mycur.fetchall()

for x in myrec:

cno = x[0]

cname = x[1]
address = x[2]

roomno = x[3]

mobileno = x[4]

check_in = x[5]

check_out = x[6]
adv_pay = x[7]

room_type = x[8]
days = x[9]

print("=====================================================")

print(" The Taj Hotel ")

print(" ")

print(" Colaba, Mumbai ")

print("=====================================================")

print("Customer Number", cno)

print("Customer Name", cname)

print("Customer Address", address)

print("=====================================================")

print("Room Number", roomno)

print("Mobile Number", mobileno)

print("=====================================================")

Page 11 of 19
print("Check-In", check_in)

print("Check-Out", check_out)

print("Room Category", room_type)

print("=====================================================")

print("Number of Days:", days)

Total = days*4500

print("Total Amount", Total)

print("Advance Payment", adv_pay)

Tax = Total * 0.10

print("Tax: ", Tax)

net = Total - adv_pay + tax

print("Net Amount", net)

ch='y'

while ch == 'y' or ch == 'Y':

print("=====================================================")
print("\t\tMAIN MENU\n")

print("1. To ADD New Record")

print("2. To Search a Record")

print("3. To Update the Record")

print("4. To Delete the Record")


print("5. To View all the Record")

print("6. To Generate the Report\n")


print("=====================================================")

ch = int(input ("Enter the choice: "))

tax = 0

if ch==1:

add()
elif ch==2:

search()

elif ch==3:

edit()

elif ch==4:
delete()

elif ch==5:

Page 12 of 19
display()

elif ch==6:

generate()

print("=====================================================")

ch = input("Want to see Main Menu (y/n): ")

Once the above code is written and all modules are created, upon execution, it will show the following
output window:

To Add a New Record:

Page 13 of 19
To Search a Record:

Page 14 of 19
To Update a Record:

Page 15 of 19
To Delete a Record:

Page 16 of 19
To View all the Records:

Page 17 of 19
To Generate the Report:

Conclusion:
Hotel Management and Room Booking System has been developed to reduce the manual work using Python
and MySQL.
Its aim is to achieve maximum efficiency in room booking and other reservation tasks, which will reduce the
time required for handling the payment system, performing calculations, storing data and managing booking details.

Page 18 of 19
SQL Queries for the table hotel
create database project;

use project;

create table hotel(cno int primary key,

cname varchar(30),

address varchar(31),

roomno int,

mobileno bigint,

check_in date,

check_out date,

adv_pay decimal(10,3),

room_type char(30));

insert into hotel values(101, "Mohit Sharma", "H-150, Mayur Vihar, Delhi", 605,
9876453213, '2024-08-10', '2024-08-13', 2000.000, "Deluxe")

insert into hotel values(102, "Hiten Arora", "C-90, Model Town, Delhi", 201,
8976453423, '2024-09-15', '2024-09-17', 5000.000, "Deluxe")

insert into hotel values(103, "Rahul Malhotra", "D-20, Krishna Nagar, Delhi", 310,
8800764532, '2024-06-12', '2024-06-15', 3500.000, "Semi-Deluxe")

insert into hotel values(104, "Akash Singh", "A-173, Gulabi Bagh, Delhi", 110,
8376588905, '2024-04-20', '2024-04-21', 4000.000, "Standard")

insert into hotel values(105, "Priya Sethi", "B-100, Saraswati Vihar, Delhi", 210,
9811608976, '2024-03-19', '2024-03-22', 6500.000, "Deluxe")

insert into hotel values(106, "Shreya Jain", "H-3/17, Indira Nagar, Delhi", 108,
9867453210, '2024-07-15', '2024-07-18', 8000.000, "Semi-Deluxe")

insert into hotel values(107, "Sunil Sharma", "A-71, Gagan Vihar, Delhi", 601,
8890653412, '2024-09-19', '2024-09-21', 1500.000, "Deluxe")

insert into hotel values(108, "Trisha Gupta", "D-110, Ashok Vihar, Delhi", 203,
9867452310, '2024-08-01', '2024-08-03', 2500.000, "Semi-Deluxe")

insert into hotel values(109, "Mohini Goyal", "H-80, Pitampura, Delhi", 225,
9867134567, '2024-07-01', '2024-07-03', 2500.000, "Standard")

insert into hotel values(110, "Deepak Saini", "D-108, Sant Nagar, Delhi", 309,
9867251235, '2024-09-18', '2024-09-22', 7500.000, "Semi-Deluxe")

select * from hotel;

Page 19 of 19

You might also like