roshan csc project
roshan csc project
NAME:
SECTION:
TITLE:
(Affiliated to Central Board of Secondary Education, New Delhi)
(Chettinad House, R.A.Puram, Chennai – 600 028)
COMPUTER SCIENCE
Date: Teacher-in-charge
REGISTER NO.
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.
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.
-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)
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.
Text Files
Binary Files
- 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)
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
}
# 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()
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)
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")
# 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"
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/