CS Project Synopsis - Johan
CS Project Synopsis - Johan
1 Acknowledgment 3
6 Use of Technology 28
7 Source code 34
8 Sample Output 52
10 Bibliography 65
2
Acknowledgement
3
Hotel
Management
System
2023-24
4
Aim of the Project
5
The aim of the "JA Hotels and Resorts Booking Gateway"
project is to provide a comprehensive and user-friendly
software solution for streamlining hotel booking and
management processes. This project primarily serves two key
objectives:
6
Functions and
Modules
7
Modules:
1. tkinter:
A module for creating the graphical user interface (GUI) of the
application. It provides widgets for building the user interface,
such as buttons and entry fields.
2. tkinter.font:
A module for setting custom fonts in the GUI components. It
allows you to specify fonts for text elements.
3. tkinter.ttk:
Part of the tkinter library and used for creating themed Tkinter
widgets. It enhances the appearance of GUI elements.
5. datetime:
Provides classes for manipulating dates and times, allowing
the application to work with data related operations.
6. reportlab:
Used for generating PDF documents, particularly for creating
receipts in the hotel reservation system.
7. mysql.connector:
Provides a Python interface for communicating with a MySQL
database. It allows the system to interact with the database
for storing and retrieving reservation data.
8
Functions:
1. update_rooms_dictionary():
Updates the rooms dictionary with room numbers and their
availability status by querying a MySQL database. This
function is used to keep track of room availability.
2. welcome_screen():
Displays a welcome screen with a colorful background and a
message using the turtle library. It provides a visual greeting
to users.
3. home_page():
Creates the main GUI window for the hotel reservation
system. It displays a background image and provides buttons
for booking and contacting the hotel.
4. contact_us():
A placeholder function intended to provide contact information
for users to get in touch with the hotel.
5. admin_panel():
Creates an admin control panel with options to book, check,
update, cancel reservations, and view room availability. It
interacts with a MySQL database to perform these operations.
6. book_now_btn_command():
A function called when the "Book Now" button is clicked. It
opens the login screen for users to log in and book rooms.
7. display():
Displays the reservation data in a treeview widget in the
9
admin panel. It fetches and presents reservation information.
8. book():
Allows users to book a room. This function checks room
availability, selects an unoccupied room, and inserts the
booking data into the MySQL database.
9. check_date():
Validates the selected booking date to ensure it is in the
future.
10. clear():
Clears the input fields on the booking and checkout screens,
making it easy for users to reset their input.
11. search():
Searches for a booking by name and populates the input
fields with the booking data, helping users to find and manage
their reservations.
12. cancel():
Cancels a reservation and sets the room's availability status
back to unoccupied in the database.
13. update():
Allows users to update reservation details. This function
modifies existing reservation information in the MySQL
database.
14. room_format():
Converts the selected room type into a numeric format (0 for
suite, 1 for double, 2 for normal) for proper storage in the
database.
10
15. check():
Checks room availability and ensures that vacant rooms are
available for booking. It helps manage room occupancy.
16. colour_format():
Used to format the background color of room availability
labels in the admin panel based on their availability status.
17. stat():
Refreshes the admin panel and updates room availability,
showing the current room status.
18. booking_screen():
Creates a GUI window for the hotel booking screen, where
users can input their booking details and interact with the
reservation system.
19. login_screen():
Creates a GUI window for the login screen, allowing users to
log in with a username and password. Depending on the
credentials, users can access different parts of the system.
20. checkout():
Creates a GUI window for the checkout screen, where users
can calculate the cost of their stay and make payments. It
generates PDF receipts and updates room availability in the
database.
21. calculate_total():
Calculates the total cost for a booking based on room type
and the number of nights stayed, helping users understand
their expenses.
11
22. payment():
Handles the payment process, generates a PDF receipt for
users, and updates the room availability in the database upon
successful checkout.
12
Brief Description of
the Project
13
This project is a hotel reservation system with a graphical
user interface (GUI) that allows users to book and manage
hotel rooms. It is a comprehensive software application
designed to streamline the hotel booking process. It offers
both users and administrators a user-friendly interface for
managing room reservations and related operations. The
project consists of several key components and features,
including:
14
5. Reservation Management: Users can search for their
reservations, update booking details, and cancel reservations
as needed.
15
1. welcome_screen()
16
2. home_page()
17
The page invites users to either "Book Now" or "Contact Us"
through prominent buttons, guiding them to take action.
3. login_screen()
18
4. booking_screen()
19
users to search for and update existing bookings, cancel
reservations, and check room availability. An additional
feature, enabled through a developer mode flag, lets users
check the current room availability status. Overall, the
booking_screen() function plays a pivotal role in the hotel
reservation system, offering a comprehensive user interface
for managing bookings and reservations.
20
5. checkout()
21
(retrieved from the database). The cost calculation takes into
account different room rates for "Normal," "Suite," and
"Double" room types.
22
23
6. admin_panel()
24
3. Booking: The admin can book a room using this interface
by entering the guest's name, selecting a room type,
specifying the check-in date, and providing a unique booking
ID. When the "Book" button is clicked, it validates the check-in
date and checks for room availability. If the date is valid and a
room is available, it updates the room's availability status,
inserts the booking data into the database, and displays a
"Booking Completed" message.
25
26
27
Use of technology
28
1. MySQL
1. What is MySQL?
MySQL is a type of software that helps store and manage
data. It's like a digital filing cabinet for information.
2. History of MySQL:
MySQL was created in the mid-1990s by a Swedish company
called MySQL AB. It was later acquired by Sun Microsystems
and then by Oracle Corporation. However, the original version
of MySQL remains open-source, which means it's free for
everyone to use and modify.
3. Simple to Use:
MySQL is known for its user-friendliness. It's relatively easy to
set up and use, even for beginners. You don't need to be a
computer expert to work with MySQL.
29
4. Reliability:
MySQL is highly reliable, which means it rarely crashes or
loses your data. It's like a dependable friend who never
forgets your secrets.
6. Community Support:
One of MySQL's strengths is its large community of users and
developers. This community helps keep the software
up-to-date, secure, and full of useful features. It's like having a
big group of friends to help you with your database needs.
30
2. Python
1. What is Python?
Python is a programming language that helps people write
computer programs and automate tasks. It's like a versatile
tool for creating software and solving problems with code.
2. History of Python:
Python was created in the late 1980s by Guido van Rossum,
a Dutch programmer. It was officially released in 1991. Python
was designed to be easy to read and write, making it
accessible for beginners.
3. Simplicity:
Python is known for its simplicity and readability. Its code
looks a lot like everyday English, making it easier for
programmers to understand and work with. It's like writing
instructions in plain language.
4. Versatility:
Python is a versatile language that can be used for a wide
range of tasks, from web development to data analysis and
31
artificial intelligence. It's like having a toolbox with many
different tools for various jobs.
6. Cross-Platform Compatibility:
Python works on different operating systems like Windows,
macOS, and Linux. This means you can write code on one
type of computer and run it on others without major changes.
It's like a universal translator for computers.
32
3. Hardware & Software
Requirement
Processor Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
2.30 GHz
Installed RAM 8.00 GB (7.89 GB usable)
System type 64-bit operating system, x64-based
processor
Wi-Fi Intel(R) Dual Band Wireless-AC 7265
Disk SK hynix SC210 mSATA 256GB
GPU Intel(R) HD Graphics 5500
33
Source Code
34
import tkinter as tk
from tkinter import *
from tkinter import messagebox
import tkinter.font as font
from tkinter import ttk
from PIL import ImageTk, Image
from datetime import datetime
from reportlab.lib.pagesizes import letter
from reportlab.lib import colors
from reportlab.platypus import SimpleDocTemplate, PageTemplate, PageBreak, Frame, Spacer, Paragraph, Table, TableStyle
from reportlab.lib.styles import getSampleStyleSheet
import mysql.connector
# Establish connection
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
# Create a cursor to execute SQL commands
cursor = connection.cursor()
sorted_list = {}
rooms = {}
dev_mode = 1
def update_rooms_dictionary():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
except Exception as e:
print("Error:", e)
finally:
35
if connection.is_connected():
cursor.close()
connection.close()
def welcome_screen():
import turtle
import random
wn = turtle.Screen()
wn.bgcolor("black")
octago = turtle.Turtle()
octago.hideturtle()
octago.speed(0)
octago.up()
octago.down()
colors = ["red", "gold", "black", "black", "white", "cyan", "pink"]
for i in range(250):
octago.color(random.choice(colors))
octago.forward(i)
octago.left(80)
octago.up()
octago.down()
turtle.color('white')
style = ('Courier', 20, 'bold')
turtle.write('WELCOME TO HOTEL RESERVATION SYSTEM!', font=style, align='center')
turtle.done()
def home_page():
def book_now_btn_command():
login_screen()
def contact_btn_command():
contact_us()
root = tk.Tk()
root.title("HMS")
head_img = Image.open("images\logo_2.jpeg")
head_img = head_img.resize((700, 600))
head_img = ImageTk.PhotoImage(head_img)
panel_1 = tk.Label(root, image = head_img)
# panel.pack(side = "bottom", fill = "both", expand = "yes")
panel_1.place(x=150,y=30,width=550,height=59)
intro_lbl=tk.Label()
ft = font.Font(family='Times',size=10)
intro_lbl["font"] = ft
intro_lbl["bg"] = "#f2eee3"
intro_lbl["fg"] = "#5065a8"
intro_lbl["justify"] = "center"
intro_lbl["text"] = "Welcome to JA Hotels, the newest and most luxurious hotel in Abu Dhabi! Our hotel offers a wide range of
facilities and amenities to \n ensure that our guests have a comfortable and enjoyable stay. Some of the facilities available at our
hotel include a full-service spa, \n a state-of-the-art fitness center, multiple dining options, and a large outdoor pool. We also offer a
range of business facilities, including \n conference rooms and a business center. Whether you're traveling for business or leisure,
JA Hotels has something for everyone."
intro_lbl.place(x=30,y=110,width=750,height=100)
book_now_btn=tk.Button()
book_now_btn["bg"] = "#5065a8"
ft = font.Font(family='Times',size=10)
book_now_btn["font"] = ft
book_now_btn["fg"] = "#f0f0f0"
36
book_now_btn["justify"] = "center"
book_now_btn["text"] = "Book Now"
book_now_btn.place(x=550,y=430,width=200,height=40)
book_now_btn["command"] = book_now_btn_command
contact_btn=tk.Button()
contact_btn["bg"] = "#5065a8"
ft = font.Font(family='Times',size=10)
contact_btn["font"] = ft
contact_btn["fg"] = "#f0f0f0"
contact_btn["justify"] = "center"
contact_btn["text"] = "Contact Us"
contact_btn.place(x=550,y=480,width=200,height=40)
contact_btn["command"] = contact_btn_command
desc_lbl=tk.Label(root)
ft = font.Font(family='Times',size=10)
desc_lbl["font"] = ft
desc_lbl["bg"] = "#f2eee3"
desc_lbl["fg"] = "#5065a8"
desc_lbl["justify"] = "center"
desc_lbl["text"] = "Located in the vibrant and dynamic city of Abu Dhabi! As the capital and largest city \n of the United Arab
Emirates, Abu Dhabi is a melting pot of cultures and traditions, offering \n something for everyone. With its modern skyline,
world-class shopping, and stunning \n beaches, Abu Dhabi is a destination that truly has it all. From visiting iconic landmarks like \n
the Sheikh Zayed Grand Mosque and the Louvre Abu Dhabi, to enjoying the city's rich \n culinary scene and exciting nightlife, there
is no shortage of things to do in Abu Dhabi. \n At JA Hotels, we are perfectly positioned to help you make the most of your stay in
this \n amazing city. We hope you will join us and experience all that Abu Dhabi has to offer!"
desc_lbl.place(x=30,y=400,width=510,height=170)
img = Image.open("images\hotel_4.png")
img = img.resize((250, 200))
img = ImageTk.PhotoImage(img)
panel = tk.Label(root, image = img)
# panel.pack(side = "bottom", fill = "both", expand = "yes")
panel.place(x=310,y=200,width=200,height=200)
img2 = Image.open("images\hotel_2.png")
img2 = img2.resize((250, 200))
img2 = ImageTk.PhotoImage(img2)
panel2 = tk.Label(root, image = img2)
# panel.pack(side = "bottom", fill = "both", expand = "yes")
panel2.place(x=60,y=200,width=210,height=200)
img3 = Image.open("images\hotel_1.png")
img3 = img3.resize((250, 200))
img3 = ImageTk.PhotoImage(img3)
panel3 = tk.Label(root, image = img3)
# panel.pack(side = "bottom", fill = "both", expand = "yes")
panel3.place(x=550,y=200,width=220,height=200)
root.mainloop()
def contact_us():
return
def admin_panel():
def display():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
root = tk.Tk()
root.geometry("1400x800")
root.title("ADMIN PANEL")
37
root['background'] = 'LightGreen'
tk.Label(root, text="ADMIN PANEL", font=("Times New Roman Bold", 20)).pack()
frame = tk.Frame(root)
frame.pack()
tree = ttk.Treeview(frame, columns=(1, 2, 3, 4), height=300, show="headings")
tree.pack(side='right')
tree.heading(1, text="NAME")
tree.heading(2, text="ROOM")
tree.heading(3, text="DATE")
tree.heading(4, text="ID NO")
tree.column(1, width=130)
tree.column(2, width=130)
tree.column(3, width=130)
tree.column(4, width=130)
scroll = ttk.Scrollbar(frame, orient="vertical", command=tree.yview)
scroll.pack(side='right', fill='y')
root.mainloop()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while displaying data.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def book():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
date_status = check_date()
if date_status:
# Find the last unoccupied room number from the database
select_unoccupied_query = "SELECT room_number FROM rooms WHERE availability = 0 ORDER BY room_number
DESC LIMIT 1"
cursor.execute(select_unoccupied_query)
unoccupied_room = cursor.fetchone()
if unoccupied_room:
room_number = unoccupied_room[0] # Get room_number
room_type = drop_down_menu.get() # Get room_type from the option menu
# Use the room column to store both room number and type
room = f"{room_number} ({room_type})"
name = name_txt.get()
date = date_txt.get()
booking_id = id_txt.get()
38
# Insert data into the MySQL table
insert_query = """
INSERT INTO reservations (name, room, date, booking_id)
VALUES (%s, %s, %s, %s)
"""
data = (name, room, date, booking_id)
cursor.execute(insert_query, data)
connection.commit()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while booking.")
finally:
if connection is not None and connection.is_connected():
cursor.close()
connection.close()
def check_date():
date = date_txt.get()
checkDate = datetime.strptime(date, "%Y-%m-%d")
present = datetime.now()
def clear():
name_txt.delete(0,END)
drop_down_menu.set("Normal")
date_txt.delete(0,END)
id_txt.delete(0,END)
def search():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
name = name_txt.get()
clear()
if booking:
messagebox.showinfo("Message", "Booking found!")
name_txt.insert(END, booking[1])
drop_down_menu.set(booking[2])
date_txt.insert(END, booking[3])
id_txt.insert(END, booking[4])
else:
messagebox.showinfo("Message", "No such booking")
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while searching.")
finally:
39
if connection.is_connected():
cursor.close()
connection.close()
def cancel():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
if x:
# Delete the booking from the MySQL table
delete_query = "DELETE FROM reservations WHERE name = %s"
cursor.execute(delete_query, (regno,))
connection.commit()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while canceling.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def update():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
if x:
name = name_txt.get()
room = drop_down_menu.get()
date = date_txt.get()
booking_id = id_txt.get()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while updating.")
finally:
40
if connection.is_connected():
cursor.close()
connection.close()
def room_format():
room = drop_down_menu.get()
room = room.lower()
if room == "suite":
return 0
elif room == "double room" or room == "doubleroom":
return 1
elif room == "normal":
return 2
else:
messagebox.showinfo("ALERT ", "Invalid Entry")
return "Invalid!"
def check():
for room in rooms:
if rooms[room] == 0:
rooms[room] = 1
return True
messagebox.showinfo("Message ", "No vacant rooms")
return False
def colour_format(integer):
if integer == 1:
return "Red"
else:
return "Green"
def stat():
root.destroy()
update_rooms_dictionary()
admin_panel()
print(rooms)
root = tk.Tk()
root.geometry("700x700")
root.title("Admin Control Panel")
root.configure(bg='#F7BF4F')
# lblmenu = tk.Label(root, text ="ADMIN CONTROL PANEL", bg= '#F7BF4F',font=('Times New Roman',28,'bold'))
# lblmenu.place(x = 120, y = 20)
global title_img
title_img = Image.open("images\logo_3.png")
title_img = title_img.resize((400, 150))
title_img = ImageTk.PhotoImage(title_img)
panel_title = tk.Label(root, image = title_img)
panel_title.place(x=150,y=20,width=400,height=150)
name_lbl = tk.Label(root, text ="NAME",bg= '#F7BF4F',fg ='black',font=("Times New Roman Bold", 10) )
name_lbl.place(x = 50, y = 200)
name_txt= tk.Entry(root, width = 35,fg ='black',bg= '#F7BF4F',font=("Times New Roman Bold", 10))
name_txt.place(x = 350, y = 200, width = 300)
room_lbl = tk.Label(root, text ="ROOM TYPE",fg ='black',bg= '#F7BF4F',font=("Times New Roman Bold", 10))
room_lbl.place(x = 50, y = 250)
room_lbl_2 = tk.Label(root, text ="[SUITE / DOUBLE ROOM / NORMAL]",fg ='black',bg= '#F7BF4F',font=("Times New Roman
Bold", 10))
room_lbl_2.place(x = 50, y = 270)
drop_down_menu = StringVar(root)
drop_down_menu.set("Normal")
41
room_opt = OptionMenu(root, drop_down_menu, "Normal", "Suite", "Double")
room_opt.pack()
room_opt.place(x = 350, y = 250, width = 300)
date_lbl = tk.Label(root, text ="DATE [DD/MM/YYYY]",fg ='black',bg= '#F7BF4F',font=("Times New Roman Bold", 10) )
date_lbl.place(x = 50, y = 300)
date_txt= tk.Entry(root, width = 35,fg ='black',bg= '#F7BF4F',font=("Times New Roman Bold", 10))
date_txt.place(x = 350, y = 300, width = 300)
id_lbl = tk.Label(root, text ="ID No.",fg ='black',bg= '#F7BF4F',font=("Times New Roman Bold", 10))
id_lbl.place(x = 50, y = 350)
id_txt = tk.Entry(root, width = 35,fg ='black',bg= '#F7BF4F',font=("Times New Roman Bold", 10))
id_txt.place(x = 350, y = 350, width = 300)
btninsert = tk.Button(root, text ="Book",fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=book)
btninsert.place(x = 150, y = 400, width = 60)
btnclear = tk.Button(root, text ="Clear", fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=clear)
btnclear.place(x = 220, y = 400, width = 60)
btndisplay = tk.Button(root, text ="Check",fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=display)
btndisplay.place(x = 280, y = 400, width = 60)
btnsearch = tk.Button(root, text ="Cancel",fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=cancel)
btnsearch.place(x = 340, y = 400, width = 60)
btnupdate = tk.Button(root, text ="Update",fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=update)
btnupdate.place(x = 400, y = 400, width = 60)
btnsearch = tk.Button(root, text ="Search",fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=search)
btnsearch.place(x = 460, y = 400, width = 60)
btnsearch = tk.Button(root, text ="Refresh",fg ='red',bg= '#F7BF4F',font=("Times New Roman Bold", 10),command=stat)
btnsearch.place(x = 550, y = 600, width = 100)
hotel_room_1 = tk.Label(root, text ="Room 1",fg ='black',bg= colour_format(rooms[1]) ,font=("Times New Roman Bold", 10))
hotel_room_1.place(x = 100, y = 500)
hotel_room_2 = tk.Label(root, text ="Room 2",fg ='black',bg= colour_format(rooms[2]) ,font=("Times New Roman Bold", 10))
hotel_room_2.place(x = 150, y = 500)
hotel_room_3 = tk.Label(root, text ="Room 3",fg ='black',bg= colour_format(rooms[3]) ,font=("Times New Roman Bold", 10))
hotel_room_3.place(x = 200, y = 500)
hotel_room_4 = tk.Label(root, text ="Room 4",fg ='black',bg= colour_format(rooms[4]) ,font=("Times New Roman Bold", 10))
hotel_room_4.place(x = 250, y = 500)
hotel_room_5 = tk.Label(root, text ="Room 5",fg ='black',bg= colour_format(rooms[5]) ,font=("Times New Roman Bold", 10))
hotel_room_5.place(x = 300, y = 500)
hotel_room_6 = tk.Label(root, text ="Room 6",fg ='black',bg= colour_format(rooms[6]) ,font=("Times New Roman Bold", 10))
hotel_room_6.place(x = 350, y = 500)
hotel_room_7 = tk.Label(root, text ="Room 7",fg ='black',bg= colour_format(rooms[7]) ,font=("Times New Roman Bold", 10))
hotel_room_7.place(x = 400, y = 500)
hotel_room_8 = tk.Label(root, text ="Room 8",fg ='black',bg= colour_format(rooms[8]) ,font=("Times New Roman Bold", 10))
hotel_room_8.place(x = 450, y = 500)
hotel_room_9 = tk.Label(root, text ="Room 9",fg ='black',bg= colour_format(rooms[9]) ,font=("Times New Roman Bold", 10))
hotel_room_9.place(x = 500, y = 500)
hotel_room_10 = tk.Label(root, text ="Room 10",fg ='black',bg= colour_format(rooms[10]) ,font=("Times New Roman Bold", 10))
hotel_room_10.place(x = 550, y = 500)
root.mainloop()
def booking_screen():
42
def display():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
root = tk.Tk()
root.geometry("1400x800")
root.title("RESERVATIONS")
root['background'] = '#66a3bb'
tk.Label(root, text="RESERVATIONS", font=("Times New Roman Bold", 20)).pack()
frame = tk.Frame(root)
frame.pack()
tree = ttk.Treeview(frame, columns=(1, 2, 3), height=300, show="headings")
tree.pack(side='right')
tree.heading(1, text="NAME")
tree.heading(2, text="ROOM")
tree.heading(3, text="DATE")
tree.column(1, width=130)
tree.column(2, width=130)
tree.column(3, width=130)
scroll = ttk.Scrollbar(frame, orient="vertical", command=tree.yview)
scroll.pack(side='right', fill='y')
root.mainloop()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while displaying data.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def book():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
date_status = check_date()
if date_status:
# Find the last unoccupied room number from the database
select_unoccupied_query = "SELECT room_number FROM rooms WHERE availability = 0 ORDER BY room_number
DESC LIMIT 1"
cursor.execute(select_unoccupied_query)
unoccupied_room = cursor.fetchone()
if unoccupied_room:
room_number = unoccupied_room[0] # Get room_number
room_type = drop_down_menu.get() # Get room_type from the option menu
# Use the room column to store both room number and type
room = f"{room_number} ({room_type})"
43
name = name_txt.get()
date = date_txt.get()
booking_id = id_txt.get()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while booking.")
finally:
if connection is not None and connection.is_connected():
cursor.close()
connection.close()
def check_date():
date = date_txt.get()
checkDate = datetime.strptime(date, "%Y-%m-%d")
present = datetime.now()
def clear():
name_txt.delete(0,END)
drop_down_menu.set("Normal")
date_txt.delete(0,END)
id_txt.delete(0,END)
def search():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
name = name_txt.get()
clear()
if booking:
messagebox.showinfo("Message", "Booking found!")
name_txt.insert(END, booking[0])
drop_down_menu.set(booking[1])
44
date_txt.insert(END, booking[2])
id_txt.insert(END, booking[3])
else:
messagebox.showinfo("Message", "No such booking")
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while searching.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def cancel():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
if x:
# Delete the booking from the MySQL table
delete_query = "DELETE FROM reservations WHERE name = %s"
cursor.execute(delete_query, (regno,))
connection.commit()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while canceling.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def update():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
if x:
name = name_txt.get()
room = drop_down_menu.get()
date = date_txt.get()
booking_id = id_txt.get()
45
cursor.execute(update_query, data)
connection.commit()
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while updating.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def check():
for room in rooms:
if rooms[room] == 0:
rooms[room] = 1
return True
messagebox.showinfo("Message ", "No vacant rooms")
return False
def stat():
print(rooms)
root = tk.Tk()
root.geometry("700x700")
root.title("Booking Page")
root.configure(bg='#66a3bb')
global title_img_2
title_img_2 = Image.open("images\logo_4.jpeg")
title_img_2 = title_img_2.resize((500, 500))
title_img_2 = ImageTk.PhotoImage(title_img_2)
panel_title_2 = tk.Label(root, image = title_img_2)
panel_title_2.place(x=150,y=20,width=400,height=150)
name_lbl = tk.Label(root, text ="NAME",bg= '#66a3bb',fg ='black',font=("Times New Roman Bold", 10) )
name_lbl.place(x = 50, y = 200)
name_txt= tk.Entry(root, width = 35,fg ='black',bg= '#66a3bb',font=("Times New Roman Bold", 10))
name_txt.place(x = 350, y = 200, width = 300)
room_lbl = tk.Label(root, text ="ROOM TYPE",fg ='black',bg= '#66a3bb',font=("Times New Roman Bold", 10))
room_lbl.place(x = 50, y = 250)
room_lbl_2 = tk.Label(root, text ="[SUITE / DOUBLE ROOM / NORMAL]",fg ='black',bg= '#66a3bb',font=("Times New Roman
Bold", 10))
room_lbl_2.place(x = 50, y = 270)
drop_down_menu = StringVar(root)
drop_down_menu.set("Normal")
date_lbl = tk.Label(root, text ="DATE [DD/MM/YYYY]",fg ='black',bg= '#66a3bb',font=("Times New Roman Bold", 10) )
date_lbl.place(x = 50, y = 300)
date_txt= tk.Entry(root, width = 35,fg ='black',bg= '#66a3bb',font=("Times New Roman Bold", 10))
date_txt.place(x = 350, y = 300, width = 300)
id_lbl = tk.Label(root, text ="ID No.",fg ='black',bg= '#66a3bb',font=("Times New Roman Bold", 10))
id_lbl.place(x = 50, y = 350)
46
id_txt = tk.Entry(root, width = 35,fg ='black',bg= '#66a3bb',font=("Times New Roman Bold", 10))
id_txt.place(x = 350, y = 350, width = 300)
btninsert = tk.Button(root, text ="Book",fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=book)
btninsert.place(x = 150, y = 400, width = 60)
btnclear = tk.Button(root, text ="Clear", fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=clear)
btnclear.place(x = 220, y = 400, width = 60)
btndisplay = tk.Button(root, text ="Check",fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=display)
btndisplay.place(x = 280, y = 400, width = 60)
btnsearch = tk.Button(root, text ="Cancel",fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=cancel)
btnsearch.place(x = 340, y = 400, width = 60)
btnupdate = tk.Button(root, text ="Update",fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=update)
btnupdate.place(x = 400, y = 400, width = 60)
btnsearch = tk.Button(root, text ="Search",fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=search)
btnsearch.place(x = 460, y = 400, width = 60)
if dev_mode == 1:
btnsearch = tk.Button(root, text ="Availability",fg ='red',bg= '#66a3bb',font=("Times New Roman Bold", 10),command=stat)
btnsearch.place(x = 550, y = 500, width = 100)
root.mainloop()
def login_screen():
def clear():
txtUser.delete(0,END)
txtpass.delete(0,END)
txtUser.focus()
def login():
user = txtUser.get()
passw = txtpass.get()
if user=="user" and passw=="user":
messagebox.showinfo("Login ", "Login Successful")
root.destroy()
booking_screen()
elif user=="admin" and passw=="admin":
messagebox.showinfo("Login ", "Login Successful")
root.destroy()
admin_panel()
else:
messagebox.showinfo("Login ", "Login Denied")
root = tk.Tk()
root.geometry("300x300")
root.title("JA Login Page")
C = Canvas(root, bg ="Red", height = 250, width = 300)
lbluser = tk.Label(root, text ="Username ",fg="red",font=("Times New Roman Bold", 10) )
lbluser.place(x = 50, y = 20)
txtUser = tk.Entry(root, width = 35,fg="blue",font=("Times New Roman Bold", 10))
txtUser.place(x = 150, y = 20, width = 100)
lblpass = tk.Label(root, text ="Password ",fg="red",font=("Times New Roman Bold", 10))
lblpass.place(x = 50, y = 50)
txtpass = tk.Entry(root,show="*", width = 35,fg="blue",font=("Times New Roman Bold", 10))
txtpass.place(x = 150, y = 50, width = 100)
loginbtn = tk.Button(root, text ="Login", fg ='blue', font=("Times New Roman Bold", 10),command = login)
loginbtn.place(x = 100, y = 135, width = 55)
clearbtn = tk.Button(root, text ="Clear",fg ='blue', font=("Times New Roman Bold", 10),command = clear)
clearbtn.place(x = 200, y = 135, width = 55)
root.mainloop()
def checkout():
def check_date():
date = date_txt.get()
checkDate = datetime.strptime(date, "%Y-%m-%d")
47
present = datetime.now()
def clear():
name_txt.delete(0,END)
drop_down_menu.set("Normal")
date_txt.delete(0,END)
id_txt.delete(0,END)
checkout_cost_txt.delete(0,END)
def search():
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
name = name_txt.get()
clear()
if booking:
messagebox.showinfo("Message", "Booking found!")
name_txt.insert(END, booking[0])
drop_down_menu.set(booking[1])
date_txt.insert(END, booking[2])
id_txt.insert(END, booking[3])
else:
messagebox.showinfo("Message", "No such booking")
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while searching.")
finally:
if connection.is_connected():
cursor.close()
connection.close()
def room_cost():
room_type = room_format()
val = 0
if room_type == 0:
val = 250
return val
elif room_type == 1:
val = 500
return val
elif room_type == 2:
val = 200
return val
def calculate_total():
room_rate = room_cost()
num_nights = datetime.now() - datetime.strptime(date_txt.get(), "%Y-%m-%d")
num_nights = num_nights.days
checkout_cost_txt.insert(END, (room_rate * num_nights))
48
def room_format():
room = drop_down_menu.get()
room = room.lower()
if "suite" in room:
return 0
elif "double" in room:
return 1
elif "normal" in room:
return 2
else:
messagebox.showinfo("ALERT ", "Invalid Entry")
return "Invalid!"
def payment():
id = id_txt.get()
date = date_txt.get()
name = name_txt.get()
cost = checkout_cost_txt.get()
filename = f"{id}.pdf"
try:
connection = mysql.connector.connect(
host="localhost",
user="root",
password="adis",
database="reservation_system"
)
cursor = connection.cursor()
room_num = int(room_data[0][:2])
49
# Build the PDF document
doc.build(elements)
except Exception as e:
print("Error:", e)
messagebox.showerror("Error", "An error occurred while generating receipt and deleting the entry.")
finally:
if connection is not None and connection.is_connected():
cursor.close()
connection.close()
root = tk.Tk()
root.geometry("700x700")
root.title("Checkout")
root.configure(bg='#0d67b5')
# lblmenu = tk.Label(root, text ="ADMIN CONTROL PANEL", bg= '#F7BF4F',font=('Times New Roman',28,'bold'))
# lblmenu.place(x = 120, y = 20)
global title_img
title_img = Image.open("images\logo_5.jpeg")
title_img = title_img.resize((500, 450))
title_img = ImageTk.PhotoImage(title_img)
panel_title = tk.Label(root, image = title_img)
panel_title.place(x=150,y=20,width=400,height=150)
name_lbl = tk.Label(root, text ="NAME",bg= '#0d67b5',fg ='white',font=("Times New Roman Bold", 10))
name_lbl.place(x = 50, y = 200)
name_txt= tk.Entry(root, width = 35,fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
name_txt.place(x = 350, y = 200, width = 300)
room_lbl = tk.Label(root, text ="ROOM TYPE",fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
room_lbl.place(x = 50, y = 250)
room_lbl_2 = tk.Label(root, text ="[SUITE / DOUBLE ROOM / NORMAL]",fg ='white',bg= '#0d67b5',font=("Times New Roman
Bold", 10))
room_lbl_2.place(x = 50, y = 270)
drop_down_menu = StringVar(root)
drop_down_menu.set("Normal")
date_lbl = tk.Label(root, text ="DATE [DD/MM/YYYY]",fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10) )
date_lbl.place(x = 50, y = 300)
date_txt= tk.Entry(root, width = 35,fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
date_txt.place(x = 350, y = 300, width = 300)
id_lbl = tk.Label(root, text ="ID No.",fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
id_lbl.place(x = 50, y = 350)
id_txt = tk.Entry(root, width = 35,fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
id_txt.place(x = 350, y = 350, width = 300)
checkout_cost = tk.Label(root, text ="Cost",fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
checkout_cost.place(x = 50, y = 400)
50
checkout_cost_txt = tk.Entry(root, width = 35,fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10))
checkout_cost_txt.place(x = 350, y = 400, width = 300)
btnclear = tk.Button(root, text ="Pay", fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10),command=payment)
btnclear.place(x = 250, y = 480, width = 90)
btnsearch = tk.Button(root, text ="Clear",fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10),command=clear)
btnsearch.place(x = 350, y = 480, width = 90)
btnsearch = tk.Button(root, text ="Search",fg ='white',bg= '#0d67b5',font=("Times New Roman Bold", 10),command=search)
btnsearch.place(x = 450, y = 480, width = 90)
root.mainloop()
welcome_screen()
update_rooms_dictionary()
home_page()
booking_screen()
admin_panel()
checkout()
51
Sample Output
52
53
54
55
56
57
58
59
60
Merits and
Demerits
61
Merits (Advantages):
62
6. Authentication and User Roles: The system distinguishes
between regular users and administrators, enhancing security
and allowing administrators to manage bookings effectively.
Demerits (Disadvantages):
63
4. Design Customization: The project may not offer easy ways
to customize the design or theme of the GUI to match the
branding of a specific hotel.
64
Bibliography
65
To develop this project many references were used:
66
Remarks
67