0% found this document useful (0 votes)
26 views23 pages

roshan csc project

Uploaded by

psb6950
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)
26 views23 pages

roshan csc project

Uploaded by

psb6950
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/ 23

CHETTINAD VIDYASHRAM

COMPUTER SCIENCE PROJECT


STD XII (2024-25)

NAME:

SECTION:

TITLE:
(Affiliated to Central Board of Secondary Education, New Delhi)
(Chettinad House, R.A.Puram, Chennai – 600 028)

COMPUTER SCIENCE

Certified to be the Bonafide Record of work done by

of Std XII Sec

in the Computer Science Lab of the CHETTINAD VIDYASHRAM,

CHENNAI, during the year 2024 – 2025.

Date: Teacher-in-charge

REGISTER NO.

Submitted for All India Senior Secondary Practical Examination in

Computer Science held on at

Chettinad Vidyashram, Chennai – 600 028.

Principal Internal Examiner External Examiner


ACKNOWLEDGEMENT

I would like to express my sincere thanks to Meena

Aunty, Principal Mrs. S.Amudhalakshmi

for their encouragement and support to work on

this Project. I am grateful to my computer science

teacher Mrs. Vijayalakshmi Srinivas and to the

computer science department for the constant

guidance and support to complete the project.


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.

A significant advantage of Python is its extensive standard library, which provides built-
in modules for common tasks like file handling, date manipulation, and building
graphical interfaces. Python also supports multiple programming paradigms—including
object-oriented, procedural, and functional programming—offering students flexibility
in structuring their code.

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.

In addition to foundational programming, Python is also prominent in advanced areas


like machine learning, artificial intelligence, and web development, thanks to powerful
libraries and frameworks like TensorFlow, Flask, and Django.
Project Description: Hotel Booking System

The Hotel Booking System is a comprehensive desktop application developed to simplify


hotel room reservations and management. Built using Python and the Tkinter library for
an intuitive graphical user interface, this application offers hotel staff and customers an
efficient way to handle bookings and manage room availability.

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

- Purpose: Creates the bookings table in the SQLite database to store booking
information, including customer name, room type, food service, payment method,
etc.

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.

5. calculate_price(self, room_type, extra_bed, food_service, check_in,


check_out)

-Purpose: Calculates the total price of a booking based on room type, extra bed,
food service, and duration of stay.
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)

-Purpose: Hides all payment-related input fields. It is called when no specific


payment method is selected.

8. book_room(self)

-Purpose: Handles the booking process, including validating user inputs,


calculating the total price, saving booking data to the database, and displaying the
booking receipt.

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.

12. show_receipt(self, customer_name, room_type, extra_bed, food_service,


check_in, check_out, total_price, payment_method)
-Purpose: Displays a booking receipt with all the relevant booking details in a
new window after a successful transaction.
List of the text and binary files used in Hotel Booking System program and
their purpose:

Text Files

1. MYSQL Database File:


- `hotel_booking.db` : This is the primary storage for all room and booking
information. It contains two tables:
- rooms : Stores room details such as room type, price, and availability.
- bookings : Stores booking details including customer name, room type,
check-in/check-out dates, payment method, etc.
- File Type: Text file in a structured format (SQLite database).

Binary Files

2. ID Proof File (User-selected file):


- Purpose: When the user uploads an ID proof during the booking process, the
program allows the user to browse and select an ID file (e.g., `.jpg`, `.jpeg`, `.png`,
`.pdf`). The file is used to verify the identity of the customer.
- File Type: Binary file (image or PDF).
TABLES USED:

1. Rooms Table (rooms)

- Purpose: Stores information about the different types of rooms available in the
hotel, their prices, and availability.
- Columns:
- room_type (TEXT): The type of room (e.g., Single, Double, Suite).
- peak_season_price (REAL): The price of the room during peak season.
- off_season_price (REAL): The price of the room during off-season.
- available_rooms (INTEGER): The number of rooms available for that room
type.

Sample :
2. Bookings Table (bookings)

- Purpose: Stores details about each booking made by customers, including


customer information, booking dates, price, and payment details.
- Columns:
- id(INTEGER PRIMARY KEY AUTOINCREMENT): Unique booking ID.
- customer_name(TEXT): The name of the customer.
- room_type(TEXT): The type of room booked (linked to the rooms table).
- extra_bed (BOOLEAN): Whether an extra bed was added.
- food_service (TEXT): The food service chosen (e.g., Breakfast, Full-board).
- check_in (DATE): The check-in date.
- check_out(DATE): The check-out date.
- total_price(REAL): The total price of the booking.
- payment_method(TEXT): The payment method used (e.g., UPI, Credit Card).

Sample :
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
}

def __init__(self, root):


self.root = root
self.root.title("Hotel Booking System")
self.root.geometry("700x600")
self.root.configure(bg="#f4f4f4")

# Connect to MySQL database


self.conn = mysql.connector.connect(
host="localhost",
user="root",
password="root",
database="hotel_booking"
)
self.cursor = self.conn.cursor()

# Set up tables and data


self.create_rooms_table()
self.create_bookings_table()
self.room_data = self.load_room_data()

# 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,
off_season_price FLOAT,
available_rooms INT
)''')
self.conn.commit()

# Sample data for rooms


self.populate_sample_rooms()

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")
header_label = tk.Label(header_frame, text="Hotel Booking System", font=("Arial",
16), fg="white", bg="#333")
header_label.pack(pady=10)

# Booking form section


form_frame = tk.Frame(self.root, bg="#f4f4f4")
form_frame.pack(pady=20)

self.customer_name_label = tk.Label(form_frame, text="Customer Name:",


font=("Arial", 12), bg="#f4f4f4")
self.customer_name_label.grid(row=0, column=0, padx=5, pady=5, sticky="w")
self.customer_name_entry = tk.Entry(form_frame, font=("Arial", 12))
self.customer_name_entry.grid(row=0, column=1, padx=5, pady=5)

self.room_type_label = tk.Label(form_frame, text="Room Type:", font=("Arial", 12),


bg="#f4f4f4")
self.room_type_label.grid(row=1, column=0, padx=5, pady=5, sticky="w")
self.room_type_var = tk.StringVar(value="Single")
self.room_type_menu = ttk.Combobox(form_frame, textvariable=self.room_type_var,
values=list(self.room_data.keys()), state="readonly", font=("Arial", 12))
self.room_type_menu.grid(row=1, column=1, padx=5, pady=5)

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

self.food_service_label = tk.Label(form_frame, text="Food Service:", font=("Arial",


12), bg="#f4f4f4")
self.food_service_label.grid(row=3, column=0, padx=5, pady=5, sticky="w")
self.food_service_var = tk.StringVar(value="None")
self.food_service_menu = ttk.Combobox(form_frame,
textvariable=self.food_service_var, values=list(self.FOOD_PRICES.keys()),
state="readonly", font=("Arial", 12))
self.food_service_menu.grid(row=3, column=1, padx=5, pady=5)

self.check_in_label = tk.Label(form_frame, text="Check-In Date:", font=("Arial", 12),


bg="#f4f4f4")
self.check_in_label.grid(row=4, column=0, padx=5, pady=5, sticky="w")
self.check_in_entry = DateEntry(form_frame, font=("Arial", 12), date_pattern='yyyy-
mm-dd')
self.check_in_entry.grid(row=4, column=1, padx=5, pady=5)

self.check_out_label = tk.Label(form_frame, text="Check-Out Date:", font=("Arial",


12), bg="#f4f4f4")
self.check_out_label.grid(row=5, column=0, padx=5, pady=5, sticky="w")
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)

self.payment_method_label = tk.Label(form_frame, text="Payment Method:",


font=("Arial", 12), bg="#f4f4f4")
self.payment_method_label.grid(row=6, column=0, padx=5, pady=5, sticky="w")
self.payment_method_var = tk.StringVar(value="UPI")
self.payment_method_menu = ttk.Combobox(form_frame,
textvariable=self.payment_method_var, values=["UPI", "Credit Card", "Debit Card",
"Cash"], state="readonly", font=("Arial", 12))
self.payment_method_menu.grid(row=6, 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)

self.view_button = tk.Button(self.root, text="View Bookings",


command=self.view_bookings, font=("Arial", 12), bg="#007bff", fg="white")
self.view_button.pack(pady=10)

self.availability_button = tk.Button(self.root, text="View Room Availability",


command=self.view_room_availability, font=("Arial", 12), bg="#17a2b8", fg="white")
self.availability_button.pack(pady=10)

self.price_button = tk.Button(self.root, text="View Room Price",


command=self.view_room_price, font=("Arial", 12), bg="#ffc107", fg="white")
self.price_button.pack(pady=10)

self.cancel_button = tk.Button(self.root, text="Cancel Booking",


command=self.cancel_booking, font=("Arial", 12), bg="#dc3545", fg="white")
self.cancel_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()

# Calculate the total amount


try:
check_in = datetime.strptime(check_in_date, "%Y-%m-%d")
check_out = datetime.strptime(check_out_date, "%Y-%m-%d")
if check_in >= check_out:
raise ValueError("Check-out date must be after check-in date.")
days = (check_out - check_in).days
if days <= 0:
raise ValueError("Duration must be at least 1 day.")

# Get room price


room_price = self.get_room_price(room_type)
total_price = (room_price * days) + (self.EXTRA_BED_PRICE if extra_bed else 0)
+ self.FOOD_PRICES[food_service]
total_price = round(total_price, 2)

# Insert booking into the database


self.cursor.execute('''INSERT INTO bookings (customer_name, room_type,
check_in_date, check_out_date, extra_bed, food_service, payment_method, amount)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s)''',
(customer_name, room_type, check_in_date, check_out_date, extra_bed,
food_service, payment_method, total_price))
self.conn.commit()
messagebox.showinfo("Booking Successful", f"Room booked successfully!\nTotal
Price: ₹{total_price}")
except ValueError as e:
messagebox.showerror("Input Error", str(e))
except Exception as e:
messagebox.showerror("Database Error", str(e))

def get_room_price(self, room_type):


self.cursor.execute("SELECT peak_season_price, off_season_price FROM rooms
WHERE room_type = %s", (room_type,))
room_price = self.cursor.fetchone()
if not room_price:
raise ValueError("Room type not found.")
return room_price[0] # Return peak season price for this example

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"
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):
self.cursor.close()
self.conn.close()
self.root.quit()

if __name__ == "__main__":
root = tk.Tk()
app = BookingSystem(root)
root.protocol("WM_DELETE_WINDOW", app.close)
root.mainloop()
SAMPLE OUTPUT
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.
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/

3. Python MySQL Connector:


Documentation for MySQL Connector/Python, which allows Python
programs to access MySQL databases.
https://dev.mysql.com/doc/connector-python/en/

You might also like