Roshan CSC Project
Roshan CSC Project
COMPUTER SCIENCE
PROJECT STD XII (2024-
25)
ROSHAN PLATO
NAME:
F
SECTION:
COMPUTER SCIENCE
REGISTER NO.
at
Mrs. S.Amudha Lakshmi for their encouragement and support to work on this
Computer Science Department for the constant guidance and support to complete
the project.
.
1
2
1
15
18
19
Python Overview:
3 Python is a high-level, versatile programming language celebrated for its simplicity
and readability, making it particularly accessible for beginners. It’s widely applied
across fields like web development, data science, artificial intelligence, and
automation. Python’s syntax is clear and intuitive, closely resembling everyday
English, which allows new programmers to focus more on developing logical solutions
than on navigating complex code structures.
Python's interactive features make it ideal for learning and experimentation, as code can
be tested immediately, reinforcing programming concepts effectively. Its cross-platform
compatibility ensures that Python programs can run on various operating systems, such
as Windows, macOS, and Linux.
1
Project Description: Hotel Booking System
The system provides a variety of room options—including Single, Double, Suite, Deluxe,
and Family—along with add-on services like meal plans (breakfast, half-board, full-
board) and extra amenities such as additional beds. A dynamic pricing feature calculates
the total cost based on room type, peak or off-season rates, stay duration, selected
services, and additional amenities. This ensures accurate and real-time billing that reflects
seasonal price adjustments.
To manage data effectively, the system uses MySQL as its database, storing essential
information on room availability, customer profiles, and booking records. This enables
real-time data retrieval and secure storage of records. Additionally, guests can upload ID
proof during the booking process for secure verification, adding an extra layer of
security to the booking process.
The system includes a versatile payment module that supports various methods such as
UPI, credit/debit cards, and cash. Each method prompts relevant fields for a smooth and
convenient checkout process. Once a booking is confirmed, a detailed receipt is
generated, which can be printed for the guest’s reference.
Hotel administrators benefit from the ability to view current bookings and room
availability in real-time, making this system a robust solution for hotels aiming
to automate their booking operations and provide exceptional customer service
2
FUNCTIONS USED:
1. create_rooms_table(self)
-Purpose: Creates the rooms table in the SQLite database if it does not
already exist. It stores room types, prices, and availability data.
2. create_bookings_table(self)
3. load_room_data(self)
-Purpose: Fetches room information (like price and availability) from the
rooms table and stores it in a dictionary to be used within the program.
4. upload_id_proof(self)
-Purpose: Opens a file dialog for the user to upload their ID proof and
shows a message once the file is successfully selected.
-Purpose: Calculates the total price of a booking based on room type, extra
bed, food service, and duration of stay.
3
6. show_payment_details(self, selected_payment)
-Purpose: Displays the appropriate payment input fields (Credit Card, UPI,
or Cash) based on the user's selected payment method.
7. hide_payment_details(self)
8. book_room(self)
9. update_room_availability(self, room_type)
-Purpose: Decreases the availability count for the selected room type in the
rooms table after a successful booking.
10. view_bookings(self)
-Purpose: Fetches and displays all booking records from the bookings table
to show users their current bookings.
11. view_room_details(self)
-Purpose: Fetches and displays room details such as room prices and
availability from the `rooms` table.
4
List of the text and binary files used in Hotel Booking System program
and their purpose:
Text Files
Binary Files
5
TABLES USED:
Sample :
6
2. Bookings Table (bookings)
Card). Sample :
7
SOURCE CODE
import tkinter as tk
from tkinter import ttk, messagebox, simpledialog
from tkcalendar import DateEntry
import mysql.connector
from datetime import datetime
class BookingSystem:
EXTRA_BED_PRICE = 30
FOOD_PRICES = {
"None": 0,
"Breakfast": 20,
"Half-board": 50,
"Full-board": 80
}
# UI
Components
self.setup_ui()
def create_rooms_table(self):
# Creating the rooms table in MySQL
self.cursor.execute('''CREATE TABLE IF NOT EXISTS rooms (
room_type VARCHAR(50) PRIMARY KEY,
peak_season_price FLOAT,
8
off_season_price FLOAT,
available_rooms INT
)''')
self.conn.commit()
def create_bookings_table(self):
# Creating the bookings table in MySQL
self.cursor.execute('''CREATE TABLE IF NOT EXISTS bookings (
id INT PRIMARY KEY AUTO_INCREMENT,
customer_name VARCHAR(100),
room_type VARCHAR(50),
check_in_date DATE,
check_out_date DATE,
extra_bed BOOLEAN,
food_service VARCHAR(20),
payment_method VARCHAR(50),
amount FLOAT
)''')
self.conn.commit()
def populate_sample_rooms(self):
sample_rooms = [
("Single", 1000.00, 800.00, 5),
("Double", 1500.00, 1200.00, 3),
("Suite", 2500.00, 2000.00, 2),
("Deluxe", 1800.00, 1500.00, 4),
("Family", 2000.00, 1600.00, 5)
]
for room in sample_rooms:
self.cursor.execute('''INSERT IGNORE INTO rooms (room_type,
peak_season_price, off_season_price, available_rooms)
VALUES (%s, %s, %s, %s)''', room)
self.conn.commit()
def load_room_data(self):
self.cursor.execute("SELECT room_type FROM rooms")
rows = self.cursor.fetchall()
return {row[0]: None for row in rows}
def setup_ui(self):
# Layout setup for a modern appearance
header_frame = tk.Frame(self.root, bg="#333", height=50)
header_frame.pack(side="top", fill="x")
9
header_label = tk.Label(header_frame, text="Hotel Booking System", font=("Arial",
16), fg="white", bg="#333")
header_label.pack(pady=10)
self.extra_bed_var = tk.BooleanVar()
self.extra_bed_check = tk.Checkbutton(form_frame, text="Add Extra Bed",
variable=self.extra_bed_var, font=("Arial", 12), bg="#f4f4f4")
self.extra_bed_check.grid(row=2, column=1, pady=5, sticky="w")
10
self.check_out_entry = DateEntry(form_frame, font=("Arial", 12),
date_pattern='yyyy- mm-dd')
self.check_out_entry.grid(row=5, column=1, padx=5, pady=5)
# Buttons for booking, viewing bookings, room availability, room price, and cancel
booking
self.book_button = tk.Button(self.root, text="Book Room", command=self.book_room,
font=("Arial", 12), bg="#28a745", fg="white")
self.book_button.pack(pady=10)
def book_room(self):
customer_name = self.customer_name_entry.get()
room_type = self.room_type_var.get()
check_in_date = self.check_in_entry.get()
check_out_date = self.check_out_entry.get()
extra_bed = self.extra_bed_var.get()
food_service = self.food_service_var.get()
payment_method = self.payment_method_var.get()
def view_bookings(self):
self.cursor.execute("SELECT * FROM
bookings") bookings = self.cursor.fetchall()
booking_list = ""
for booking in bookings:
booking_list += f"ID: {booking[0]}, Customer: {booking[1]}, Room:
{booking[2]}, Check-In: {booking[3]}, Check-Out: {booking[4]}, Extra Bed:
{booking[5]}, Food:
{booking[6]}, Payment: {booking[7]}, Amount: ₹{booking[8]}\n"
12
if booking_list:
messagebox.showinfo("Current Bookings",
booking_list) else:
messagebox.showinfo("Current Bookings", "No bookings found.")
def view_room_availability(self):
self.cursor.execute("SELECT room_type, available_rooms FROM rooms")
availability = self.cursor.fetchall()
availability_list = ""
for room in availability:
availability_list += f"Room Type: {room[0]}, Available Rooms: {room[1]}\n"
if availability_list:
messagebox.showinfo("Room Availability", availability_list)
else:
messagebox.showinfo("Room Availability", "No room data found.")
def view_room_price(self):
self.cursor.execute("SELECT room_type, peak_season_price, off_season_price FROM
rooms")
prices = self.cursor.fetchall()
price_list = ""
for price in prices:
price_list += f"Room Type: {price[0]}, Peak Season Price: ₹{price[1]}, Off-
Season Price: ₹{price[2]}\n"
if price_list:
messagebox.showinfo("Room Prices", price_list)
else:
messagebox.showinfo("Room Prices", "No price data found.")
def cancel_booking(self):
booking_id = simpledialog.askinteger("Cancel Booking", "Enter Booking ID to
cancel:")
if booking_id:
self.cursor.execute("DELETE FROM bookings WHERE id = %s", (booking_id,))
self.conn.commit()
if self.cursor.rowcount > 0:
messagebox.showinfo("Cancellation Successful", f"Booking ID {booking_id} has
been canceled.")
else:
messagebox.showerror("Cancellation Error", "Booking ID not found.")
def close(self):
13
self.cursor.close()
self.conn.close()
self.root.quit()
14
SAMPLE OUTPUT
15
16
17
CONCLUSION
The Hotel Booking System developed using Python's Tkinter and MySQL offers a user-friendly interface for
managing hotel bookings. By integrating various features, such as selecting room types, checking availability, and
calculating total costs based on selected options, the application streamlines the booking process for both
customers and hotel management.
Key Functions:
Room Selection: Users can choose from different room types, ensuring a tailored experience that
meets their needs.
Date Management: The inclusion of a calendar feature allows users to easily select check-in and
check- out dates, facilitating better planning.
Food Options: Users can select additional services like food packages, which enhances their overall stay.
Extra Bed Option: The system allows for flexible accommodation by providing the option for an
extra bed at an additional cost.
Database Integration: By utilizing MySQL for data storage, the application ensures reliable
and persistent data management, making it easy to add, retrieve, and update booking
information.
This project showcases fundamental programming concepts and effective use of libraries for GUI applications,
presenting a valuable tool for hotel management while also serving as an educational resource for those learning
software development.
Future enhancements could include features like online payment processing, user authentication, and a more
detailed reporting system to further improve functionality and user experience.
18
BIBILIOGRAPHY
1. Tkinter :
Tkinter documentation provides comprehensive information on
using the Tkinter library for GUI development in Python.
https://docs.python.org/3/library/tkinter.html
2. MySQL :
The official MySQL documentation offers detailed insights into
database management, SQL syntax, and functionalities.
https://dev.mysql.com/doc/refman/8.0/en/
19