Completed Cs Project
Completed Cs Project
By
Ritvik Harigovind.B
RITVIK HARIGOVIND.B
INDEX
1. About project 1
Hardware and
2. software 1
requirements
3. Python 5
Overview
4. CSV files 6
Overview
5. Source Code 7
6. Output screens 17
7. Bibliography 20
ABSTRACT
This project focuses on developing a Lodge
Accommodation Management System using Python and
CSV files. The system aims to streamline and automate
the management of lodge bookings, customer
information, room availability, and billing processes.
The system is designed to handle core
functionalities such as room booking, check-ins, check-
outs, and cancellations, while maintaining customer and
room data in CSV files. The use of Python ensures
flexibility, simplicity, and scalability, while CSV files
provide a lightweight and portable data storage solution.
The CSV format ensures data portability, making the
system suitable for deployment across diverse
environments. This solution targets small and medium-
sized hotels, offering a scalable and user-friendly tool for
improving operational efficiency without requiring
complex infrastructure.
HARDWARE AND SOFTWARE
REQUIREMENTS
Hardware requirements:
Laptop
Minimum 1GB of ram
Minimum of 100GB HDD
Software requirements:
Windows operating system
Python 3. 12. 5
PYTHON OVERVIEW
4. Community Support
Large Community: Python has a massive and active community,
ensuring that developers can easily find tutorials, forums, and
support for troubleshooting.
Frequent Updates: The community-driven development ensures
the language evolves to meet current demands.
9. Portability
Python programs can be executed across different operating
systems (Windows, macOS, Linux) without modification, provided
the required dependencies are installed.
2. High Performance
Optimized for fast read and write operations, MySQL is
ideal for web applications, supporting millions of queries
per second.
3. Scalability
Handles databases of all sizes, from small-scale projects to
enterprise-level applications, and supports horizontal
scaling through replication.
4. Cross-Platform Compatibility
Runs on multiple operating systems, including Windows,
Linux, and macOS, making it versatile and portable.
8. Ease of Use
User-friendly tools like MySQL Workbench provide
graphical interfaces for database modeling, management,
and administration.
9. Rich Features
ACID compliance (via InnoDB engine), support for
transactions, stored procedures, and triggers provide
flexibility and reliability for complex applications.
import mysql.connector
from datetime import datetime
cursor.execute("""
CREATE TABLE IF NOT EXISTS guests (
guest_id INT AUTO_INCREMENT PRIMARY KEY,
guest_name VARCHAR(50) NOT NULL,
contact_no BIGINT NOT NULL,
email VARCHAR(100),
address TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS bookings (
booking_id INT AUTO_INCREMENT PRIMARY KEY,
guest_id INT,
room_id INT,
check_in DATE,
check_out DATE,
total_cost INT DEFAULT 0,
booking_status VARCHAR(20) DEFAULT 'Active',
FOREIGN KEY (guest_id) REFERENCES
guests(guest_id),
FOREIGN KEY (room_id) REFERENCES rooms(room_id)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS food_items (
food_id INT AUTO_INCREMENT PRIMARY KEY,
food_name VARCHAR(50) NOT NULL,
price INT NOT NULL,
food_description TEXT
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS room_service (
service_id INT AUTO_INCREMENT PRIMARY KEY,
booking_id INT,
food_id INT,
quantity INT NOT NULL,
total_price INT NOT NULL,
service_time TIMESTAMP DEFAULT
CURRENT_TIMESTAMP,
FOREIGN KEY (booking_id) REFERENCES
bookings(booking_id),
FOREIGN KEY (food_id) REFERENCES
food_items(food_id)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS bills (
bill_id INT AUTO_INCREMENT PRIMARY KEY,
booking_id INT,
total_room_cost INT,
total_food_cost INT,
grand_total INT,
payment_status VARCHAR(20) DEFAULT 'Pending',
payment_method VARCHAR(20),
FOREIGN KEY (booking_id) REFERENCES
bookings(booking_id)
)
""")
db.commit()
# Function Definitions
def add_guest():
name = input("Enter guest name: ")
contact = input("Enter contact number: ")
email = input("Enter email address (optional): ")
address = input("Enter address (optional): ")
cursor.execute("INSERT INTO guests (guest_name,
contact_no, email, address) VALUES (%s, %s, %s, %s)",
(name, contact, email, address))
db.commit()
print("Guest added successfully.")
def add_room():
room_type = input("Enter room type (e.g., Single,
Double, Suite): ")
price = int(input("Enter price per night: "))
description = input("Enter room description
(optional): ")
cursor.execute("INSERT INTO rooms (room_type,
price_per_night, room_description) VALUES (%s, %s,
%s)",
(room_type, price, description))
db.commit()
print("Room added successfully.")
def book_room():
guest_id = int(input("Enter guest ID: "))
room_id = int(input("Enter room ID: "))
check_in = input("Enter check-in date (YYYY-MM-DD):
")
check_out = input("Enter check-out date (YYYY-MM-
DD): ")
cursor.execute("SELECT status, price_per_night FROM
rooms WHERE room_id = %s", (room_id,))
room_info = cursor.fetchone()
if room_info[0] == 'Booked':
print("Room is currently unavailable.")
return
price = room_info[1]
total_days = (datetime.strptime(check_out, "%Y-%m-
%d") - datetime.strptime(check_in, "%Y-%m-%d")).days
total_cost = total_days * price
cursor.execute("INSERT INTO bookings (guest_id,
room_id, check_in, check_out, total_cost) VALUES (%s,
%s, %s, %s, %s)",
(guest_id, room_id, check_in, check_out,
total_cost))
cursor.execute("UPDATE rooms SET status = 'Booked'
WHERE room_id = %s", (room_id,))
db.commit()
print("Room booked successfully with a total cost of:",
total_cost)
def add_food_item():
food_name = input("Enter food item name: ")
price = int(input("Enter price: "))
description = input("Enter food description (optional):
")
cursor.execute("INSERT INTO food_items
(food_name, price, food_description) VALUES (%s, %s,
%s)",
(food_name, price, description))
db.commit()
print("Food item added successfully.")
def room_service():
booking_id = int(input("Enter booking ID: "))
food_id = int(input("Enter food ID: "))
quantity = int(input("Enter quantity: "))
cursor.execute("SELECT price FROM food_items
WHERE food_id = %s", (food_id,))
food_price = cursor.fetchone()[0]
total_price = food_price * quantity
cursor.execute("INSERT INTO room_service
(booking_id, food_id, quantity, total_price) VALUES (%s,
%s, %s, %s)",
(booking_id, food_id, quantity, total_price))
db.commit()
print("Room service added successfully with a total
cost of:", total_price)
def check_out():
booking_id = int(input("Enter booking ID for check-
out: "))
cursor.execute("SELECT total_cost FROM bookings
WHERE booking_id = %s", (booking_id,))
room_cost = cursor.fetchone()[0]
cursor.execute("""
SELECT SUM(f.price * s.quantity) FROM room_service
s
JOIN food_items f ON s.food_id = f.food_id
WHERE s.booking_id = %s
""", (booking_id,))
food_cost = cursor.fetchone()[0] or 0
grand_total = room_cost + food_cost
def view_rooms():
cursor.execute("SELECT * FROM rooms")
for room in cursor.fetchall():
print("Room ID:", room[0], "| Type:", room[1], "|
Price per Night:", room[2], "| Status:", room[3], "|
Description:", room[4])
def view_guests():
cursor.execute("SELECT * FROM guests")
for guest in cursor.fetchall():
print("Guest ID:", guest[0], "| Name:", guest[1], "|
Contact:", guest[2], "| Email:", guest[3], "| Address:",
guest[4])
def view_bookings():
cursor.execute("""
SELECT b.booking_id, g.guest_name, r.room_type,
b.check_in, b.check_out, b.total_cost, b.booking_status
FROM bookings b
JOIN guests g ON b.guest_id = g.guest_id
JOIN rooms r ON b.room_id = r.room_id
""")
for booking in cursor.fetchall():
print("Booking ID:", booking[0], "| Guest Name:",
booking[1], "| Room Type:", booking[2],
"| Check-in:", booking[3], "| Check-out:",
booking[4], "| Total Cost:", booking[5], "| Status:",
booking[6])
def view_bills():
cursor.execute("""
SELECT bl.bill_id, g.guest_name, r.room_type,
bl.total_room_cost, bl.total_food_cost, bl.grand_total,
bl.payment_status
FROM bills bl
JOIN bookings b ON bl.booking_id = b.booking_id
JOIN guests g ON b.guest_id = g.guest_id
JOIN rooms r ON b.room_id = r.room_id
""")
for bill in cursor.fetchall():
print("Bill ID:", bill[0], "| Guest Name:", bill[1], "|
Room Type:", bill[2],
"| Room Cost:", bill[3], "| Food Cost:", bill[4], "|
Grand Total:", bill[5], "| Payment Status:", bill[6])
# Main Menu
def main_menu():
while True:
print("\n***** HOTEL MANAGEMENT SYSTEM
*****")
print("1. Add Guest")
print("2. Add Room")
print("3. Book Room")
print("4. Add Food Item")
print("5. Room Service")
print("6. Check-Out")
print("7. View Rooms")
print("8. View Guests")
print("9. View Bookings")
print("10. View Bills")
print("11. Exit")
try:
choice = int(input("Enter your choice: "))
except ValueError:
print("Invalid choice! Please enter a number
between 1 and 11.")
continue
if choice == 1:
add_guest()
elif choice == 2:
add_room()
elif choice == 3:
book_room()
elif choice == 4:
add_food_item()
elif choice == 5:
room_service()
elif choice == 6:
check_out()
elif choice == 7:
view_rooms()
elif choice == 8:
view_guests()
elif choice == 9:
view_bookings()
elif choice == 10:
view_bills()
elif choice == 11:
print("Exiting the system.")
break
else:
print("Invalid choice! Please try again.")
Computer science:
-New Saraswathi house
[Publisher]