0% found this document useful (0 votes)
14 views21 pages

Hotel Management

The document is a Python script that connects to a MySQL database for a hotel management system, allowing for operations such as viewing employee and customer details, managing room bookings, and processing restaurant orders. It includes functions for displaying room availability, booking rooms, and handling customer feedback. The script also provides a menu-driven interface for users to interact with various features of the hotel management system.

Uploaded by

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

Hotel Management

The document is a Python script that connects to a MySQL database for a hotel management system, allowing for operations such as viewing employee and customer details, managing room bookings, and processing restaurant orders. It includes functions for displaying room availability, booking rooms, and handling customer feedback. The script also provides a menu-driven interface for users to interact with various features of the hotel management system.

Uploaded by

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

import mysql.

connector
from tabulate import tabulate
import random
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset")
y=a.cursor()

#all details for admin


#to show employee details
def emp_details():
a=mysql.connector.con
nect(host="localhost",
user="root",password=
"admin",database="ho
tel_sunset")
y=a.cursor()
q="select * from employees"
y.execute(q)
r = y.fetchall()
columns = [i[0] for i in
y.description]
print(tabulate(r,
headers=columns,
tablefmt="fancy_grid"))

#to show customer details


Defcustomdet():
a=mysql.connector.conne
ct(host="localhost",user=
"root",password="admin
",database="hotel_sunset
")

y=a.cursor()
x="select * from booking"
y.execute(x)
r = y.fetchall()
columns = [i[0] for i in
y.description]
print(tabulate(r, headers=columns, tablefmt="fancy_grid"))
a.commit()

#to show room details(all rooms,vacant rooms,booked


rooms) def room_details():
while True:
print("**********ROOM DETAILS**********")
print("1.Show Rooms")
print("2.Rooms Vacant")
print("3.Rooms Booked")
print("FOR EXIT
ENTER ANY NO.: ")
ch=int(input("Enter your choice: "))
if ch==1:
show_rooms()
elif ch==2:
#to show all rooms
def showrooms():
a=mysql.connector
.connect(host="loc
alhost",user="root
",password="admi
n",database="hote
l_sunset")
y=a.cursor()
y.execute("select room_type,prices,count(*) from rooms group by room_type,prices;")
r = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(r, headers=columns, tablefmt="fancy_grid"))

#to show room vacant


def room_vacant():
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset")
y=a.cursor()
av="Available"
z="select * from rooms where Status ='{}'".format(av)
y.execute(z)
r = y.fetchall()

columns = [i[0] for i in y.description]


print(tabulate(r,
#to show bookedheaders=columns,
rooms
deftablefmt="fancy_grid"))
rooms_booked():
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset")
y=a.cursor()
bk="Booked"
x="select * from rooms where Status ='{}'".format(bk)
y.execute(x)
r = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(r, headers=columns,
tablefmt="fancy_grid"))

#to show restaurant details


def restaurant_details():
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset")
y=a.cursor()
z="select*from orders"
y.execute(z)
r = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(r, headers=columns, tablefmt="fancy_grid"))
#to show all feedback
def fedback():
a=mysql.connector.co
nnect(host="localhos
t",user="root",passw
ord="admin",databa
se="hotel_sunset")
y=a.cursor()
x="select * from fdback"
y.execute(x)
x = y.fetchall()
columns = [i[0] for i in
y.description]
print(tabulate(x,
headers=columns,
tablefmt="fancy_grid"))

#restaurant
def restaurant():
#VIEW MENU
def menu():
a=mysql.connector.
connect(host="local
host",user="root",p
assword="admin",d
atabase="hotel_su
nset")
y=a.cursor()
b="select * from menu".format()
y.execute(b)
menu=y.fetchall()
columns = [i[0] for i in
y.description]
print(tabulate(menu, headers=columns, tablefmt="fancy_grid"))
if len(menu)>0:
print("Available")
a.commit()

yn=int(input("Do uou want to order an item ?type(1 for yes/2 for back to main
page):")) if yn ==1:
b_order()
elif yn==2:
print("
THANK
YOU")
print("
YOU
HAVE
BEEN
REDIRE
CTED
TO
MAIN
PAGE")
custom
ins="insert into orders(ID,Name,Quantity,Item_Price,Total_Price,Mobile_No,Adress)values({},'{}',{},{},
{},{},'{}')".format(Id, itn,Quantity,ip,tp,Mobile_No,Address)
y.execute(ins)
print("THANKS FOR THE ORDER","\n\n","YOUR ORDER
HAS BEEN ORDERED SUCCESSFULLY","\n\n")
print("YOU HAVE BEEN REDIRECTED TO THE MAIN PAGE")
a.commit()

#VIEW ORDER
def vorders():
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset")
y=a.cursor()
m=int(input("Enter your number :"))
n="select * from orders where Mobile_No={}
".format(m) print("\n","YOUR RECENT ORDERS","\
n")
y.execut
e(n)
o=y.fetchall()
columns
= [i[0] for i
in
y.description]
print(tabulate(o, headers=columns,
tablefmt="fancy_grid")) for i in o:
p="select * from menu,orders where Mobile_No={} and
menu.Dish_ID=orders.ID".format(m) y.execute(p)
q=y.fetc
hall()
a.commit()

#cancel order
def corder():
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset")
y=a.cursor()
x=int(input("enter your number:"))
s="delete from orders where Mobile_No={}".format(x)
y.execute(s)
print("\n\n","YOUR ORDER HAS BEEN
CANCELLED")
print("YOU HAVE BEEN REDIRECTED TO THE
MAIN PAGE","\n\n")
a.commit()

#feedback
def fdback():
a=mysql.conne
ctor.connect(ho
st="localhost",
user="root",pa
ssword="admi
n",database="
hotel_sunset")
y=a.cursor
()
fdn=input("Enter your name:")
#welcome
def start1():
while
True:
print("
\n")
print("
1.
VIEW
MEN
U")
print("2. VIEW YOUR ORDERS")
print("3. CANCEL ORDER")
print("4. FEEDBACK")
print("5. EXIT")
ch1=int(input(" enter your choice:"))
if ch1==1:
menu()
elif ch1==2:
vorders()
elif ch1==3:
cord
er( )
elif ch1==4:
fdback()
elif ch1==5:
#bookingbreakrooms section
# Create the table if not exists
else:
create_table = "CREATE TABLE IF NOT EXISTS booking (Booking_ID int(10) PRIMARY
print("\
KEY,Room_Type varchar(20) not null,Guest_Name VARCHAR(255),Phone_number varchar(15) not null,
Room_Number n","INint(5) not null, Check_In_Date DATE, Check_Out_Date DATE)"
VALID
y.execute(create_table)
CHOIC
def booking_id():
E"," \
return random.randint(10000, 99999)
#to book room n" ,"TR
Y
def book_room(guest_name, ph_no,ro_no, check_in_date, check_out_date, td1,
pr): try: AGAIN.
"," \n")
a = mysql.connector.connect(host="localhost", user="root", password="admin",
database="hotel_sunset")
start1() y = a.cursor()
b_id = booking_id()
# Fetch available rooms
c = "SELECT * FROM rooms WHERE Status = 'Available' and
room_no={}".format(ro_no) y.execute(c)
d = y.fetchall()
if not d:
print("No
available
rooms.")
return None
e = d[0]
# Update
room status to
'booked'
update_query = "UPDATE rooms SET Status = 'Booked' WHERE room_no = {}".format(ro_no)
# Insert booking record
ins = "INSERT INTO booking (Booking_ID, Room_Type,
Guest_Name, Phone_number, Room_Number, Check_In_Date, Check_Out_Date,
Total_Days, Price)VALUES ({}, '{}', '{}', {}, {}, '{}', '{}',
{}, '{}')".format(b_id, e[1], guest_name, ph_no, ro_no, check_in_date, check_out_date, td1,
pr) y.execute(ins)
print("Room booked successfully! Room Number: ", ro_no)
return b_id
except:
print("Error")
finally:
a.commit()

#to book delux room


def book_delux_room():
a = mysql.connector.connect(host="localhost", user="root", password="admin",
database="hotel_sunset")
y=
a.cursor()
try:
z=random.randint(101,
111) ro_no = z
g_name = input("Enter guest name: ")
ph_no = input("Enter your phone number:
")
in_date = input("Enter check-in date
(YYYY-MM-DD): ")
out_date = input("Enter check-out date
(YYYY-MM-DD):")
total_days_query = "SELECT DATEDIFF('{}', '{}')".format(out_date, in_date)
y.execute(total_days_query)
td1 = y.fetchone()[0]
pr = 15000 * td1
booking_id = book_room(g_name, ph_no,ro_no, in_date, out_date, td1, pr)
# Display booking history for the specific Booking_ID
if booking_id is not None:
q = "SELECT * FROM booking WHERE Booking_ID = {}".format(booking_id)
y.execute(q)
print("\nBooking History for Booking_ID {}: ".format(booking_id))
x = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(x, headers=columns, tablefmt="fancy_grid"))
except :
print("Error")

#to book double


room def
book_double_room():
a=
mysql.connector.conne
ct(host="localhost",
user="root",
password="admin",
database="hotel_sunset")
y = a.cursor()
total_days_query = "SELECT DATEDIFF('{}', '{}')".format(out_date, in_date)
y.execute(total_days_query)
td1 = y.fetchone()[0]
pr = 25000 * td1
booking_id = book_room(g_name, ph_no,ro_no, in_date, out_date, td1, pr)
# Display booking history for the specific Booking_ID
if booking_id is not None:
q = "SELECT * FROM booking WHERE Booking_ID = {}".format(booking_id)
y.execute(q)
print("\nBooking History for Booking_ID {}: ".format(booking_id))
x = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(x, headers=columns, tablefmt="fancy_grid"))

except :
print("Error")

#to book king room


def book_king_room():
a = mysql.connector.connect(host="localhost", user="root", password="admin",
database="hotel_sunset")
y = a.cursor()
try:
z=random.randint(301,311)
ro_no = z
g_name = input("Enter guest
name: ")
ph_no = input("Enter your
phone number: ")
in_date = input("Enter check-in date (YYYY-MM-DD): ")
out_date = input("Enter check-out date (YYYY-MM-DD):")
total_days_query = "SELECT DATEDIFF('{}',
'{}')".format(out_date, in_date)
y.execute(total_days_query)
td1 = y.fetchone()[0]
pr = 40000 * td1
booking_id =
book_room(g_name,
ph_no,ro_no, in_date,
out_date, td1, pr)

# Display booking history for the specific Booking_ID


if booking_id is not None:
q = "SELECT * FROM booking WHERE Booking_ID = {}".format(booking_id)
y.execute(q)
print("\nBooking History for Booking_ID {}: ".format(booking_id))
x = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(x, headers=columns, tablefmt="fancy_grid"))
except :
print("Error")

#to book balcony


rooms def
try:
z=random.randint(401,411)
ro_no = z
g_name = input("Enter guest name: ")
ph_no = input("Enter your phone number:
")

in_date = input("Enter check-in date (YYYY-MM-DD): ")


out_date = input("Enter check-out date (YYYY-MM-DD):")
total_days_query = "SELECT DATEDIFF('{}', '{}')".format(out_date, in_date)
y.execute(total_days_query)
td1 = y.fetchone()[0]
pr = 45000 * td1
booking_id =
book_room(g_name,
ph_no,ro_no,
in_date, out_date,
td1, pr)
# Display booking history for the specific Booking_ID
if booking_id is not None:
q = "SELECT * FROM booking WHERE
Booking_ID = {}".format(booking_id)
y.execute(q)
print("\nBooking History for Booking_ID {}: ".format(booking_id))
x = y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(x, headers=columns, tablefmt="fancy_grid"))
except
a := mysql.connector.connect(host="localhost", user="root", password="admin",
print("Error")
database="hotel_sunset")
y = a.cursor()
try:
#to book cavana
z=random.randint(501,506)
roomro_no
def = z
book_cavana():
g_name = input("Enter guest name: ") ph_no
= input("Enter your phone number: ")
in_date = input("Enter check-in date (YYYY-MM-DD): ")
out_date = input("Enter check-out date (YYYY-MM-DD):")
total_days_query = "SELECT DATEDIFF('{}', '{}')".format(out_date, in_date)
y.execute(total_days_query)
td1 = y.fetchone()[0]
pr = 90000 * td1
booking_id = book_room(g_name, ph_no,ro_no, in_date, out_date, td1, pr)
# Display booking history for the specific Booking_ID
if booking_id is not None:
q = "SELECT * FROM booking WHERE

Booking_ID = {}".format(booking_id)
y.execute(q)
print("\nBooking History for Booking_ID {}: ".format(booking_id)) x =
y.fetchall()
columns = [i[0] for i in y.description]
print(tabulate(x, headers=columns, tablefmt="fancy_grid"))
except :
print("Error")

#user choice
def bookings():
try:
a = mysql.connector.connect(host="localhost", user="root", password="admin",
database="hotel_sunset")
y = a.cursor()
z="select * from
book_rooms"
y.execute(z)
x = y.fetchall()
columns = [i[0] for i in
y.description]
print(tabulate(x, headers=columns, tablefmt="fancy_grid"))
roomchoice = int(input("Enter Your Option : "))
if roomchoice == 1:

book_delux_room()
elif roomchoice == 2:
book_double_roo
m()
elif roomchoice ==
3: book_king_room()
elif roomchoice == 4:
book_balcony_room()
elif roomchoice == 5:
book_cavana()
else:
print("Sorry, May Be You Are Giving Me Wrong Input, Please Try Again !!! ")
except:
print("Error")
finally:
y.close()
a.close()

#gaming
section def
gaming():
print("1.
Table Tennis
-----> 15000
Rs./HR")
print("2.
Bowling -----
> 10000
Rs./HR")
print("3.
Snooker -----
>
25000Rs./HR
")
print("4. VR World Gaming -----> 40000
Rs./HR") print("5. Video Games -----> 35000
elif game==3:
print("YOU HAVE SELECTED TO PLAY : Snooker")
gamingbill = hour * 25000
price=print("Total price = ",gamingbill,"Rs.")
elif game==4:
print("YOU HAVE SELECTED TO PLAY :
VR World Gaming")
gamingbill = hour * 40000
price=print("Total price = ",gamingbill,"Rs.")
elif game==5:
print("YOU HAVE SELECTED TO
PLAY :Video Games")
gamingbill = hour * 35000
price=print("Total price = ",gamingbill,"Rs.")
elif game ==6:
print("YOU HAVE SELECTED TO PLAY : Swimming Pool
Games") gamingbill = hour *50000
price=print("Total price = ",gamingbill,"Rs.")
else:
print("Sorry ,May Be You Are Giving Me Wrong Input, Please Try
Again !!! ")

#feedback to be asked by
user def feedback():
a=mysql.connector.connect(host="localhost",user="root",password="admin",database="hotel_sunset"
) y=a.cursor()
fdn=input("Enter your name:")
print("Write something about
us...") fdi=input()
x="insert into fdback
values('{}','{}')".format(fdn,fdi) y.execute(x)
print("\n\n")
print("THANKYOU FOR YOUR FEEDBACK")
print("\n")
print("YOU HAVE BEEN REDIRECTED TO
THE MAIN PAGE")
a.commit()

#for admin
def admin_slot():
while True:
print("*********WELCOME ADMIN*********")
print("1.Employees Details")
print("2.Coustomer Details")
print("3.Room Details")
print("4.Feedback")
print("5.Restaurant Details")
print("6.Exit")
a=int(input("enter your choice"))
if a==1:
emp_details()
elif a==2:
customdet(
)
elif a==4:
fedback()
elif a==5:
restaurant_details()
elif a==6:
break
else:
print("\n\
n","INVALID
CHOICE","\
n","TRY AGAIN")
#for customer
def customer_slot():
while True:
print("*************NAMASTE*************")
print("1.RESTAURANT")
print("2.BOOK ROOMS")
print("3.GAMING")
print("4.FEEDBACK")
print("5.EXIT")
a=int(input("enter your choice"))
if a==1:
restaurant()
elif a==2:
bookings()
elif a==3:
gaming()
elif a==4:
feedba
ck()
elif a==5:
break

else:
print("\n\
n","IN
VALID
CHOI
CE")

#first interface
while True:
print("******
***WELCO
ME TO
HOTEL
SUNSET**
*******")
print("1.admin")
print("2.customer")
print("3.exit")
a=int(input("who are you"))
if a==1:
def admin_login(a,
username, password):
else:
print("Invalid username or password. Please try
again.") except Exception as e:
print(f"Error: {e}")
a.close()
admin_username =
input("Enter Admin
Username: ")
admin_password = input("Enter Admin Password:
") admin_login(a, admin_username,
admin_password) admin_slot()
elif a==2:
customer_slot()
elif a==3:
break
 All tables used:-

 Describing all tables:-


1. Booking:

2.Employees:
3.Feedback:

4.Menu:

5.Orders:
6.Rooms:

7.Room Details:

8.Users:
 First interface with admin login:

 Customer login:

 From restaurant view menu:


 Order an item:

 View order:

 Canceling an order:

 Feedback of restaurant:
 Book a room:

 Gaming:

 Feedback for hotel:


 Viewing employee details:

 Viewing customer details:

 Viewing room details:


 Showing vacant rooms:

 Showing booked rooms:


 Viewing feedbacks from both hotel and restaurant:

 Viewing restaurant details:

You might also like