Hotel Management Py1
Hotel Management Py1
connector
import random
cursor = db.cursor()
cursor.execute(create_rooms_table)
cursor.execute(create_room_and_guests_table)
db.commit()
except mysql.connector.Error as e:
print(f"Error: {e}")
exit(1)
def display_details():
try:
print("Here are some of the services and amenities we offer:")
print("\nRestaurant Menu:")
print("1. Vegetarian Combo -------> Rs. 300")
print("2. Non-Vegetarian Combo -> Rs. 800")
print("3. Snacks or desserts —----> Rs 300")
print("\nGaming Options:")
print("1. Table Tennis —--> 150 Rs./hr")
print("2. Bowling —--------> 100 Rs./hr")
print("3. Snooker —-------> 250 Rs./hr")
print("4. Billiards —--------> 400 Rs./hr")
print("5. Video Games —-> 300 Rs./hr")
print("6. WaterSports —---> 350 Rs./hr")
except Exception as e:
print(f"Error: {e}")
def add_room(room_no):
try:
cursor.execute('INSERT INTO Hotel (room_no, status) VALUES (%s, %s)',
(room_no, "Available"))
db.commit()
except mysql.connector.Error as e:
print(f"Error: {e}")
def view_available_rooms():
try:
cursor.execute("SELECT room_no FROM Hotel WHERE status = 'Available'")
available_rooms = cursor.fetchall()
if available_rooms:
print("Available rooms:")
for room in available_rooms:
print(f"Room {room[0]}")
else:
print("Sorry, there are no available rooms.")
except mysql.connector.Error as e:
print(f"Error: {e}")
def view_booked_rooms():
try:
cursor.execute("SELECT room_no FROM Hotel WHERE status = 'Booked'")
booked_rooms = cursor.fetchall()
if booked_rooms:
print("Booked rooms:")
for room in booked_rooms:
print(f"Room {room[0]}")
else:
print("Sorry, there are no booked rooms.")
except mysql.connector.Error as e:
print(f"Error: {e}")
ns=0
def book_room():
try:
room_type = input("Enter room type(A/B/C/D): ")
room_no = room_type + input("Enter room number to book: ")
name = input("Enter guest name: ")
address = input("Enter guest address: ")
age = input("Enter guest age: ")
nationality = input("Enter guest nationality: ")
phone = int(input("Enter guest phone number: "))
email = input("Enter guest email ID: ")
check_in = input("Enter check-in date (YYYY-MM-DD): ")
check_out = input("Enter check-out date (YYYY-MM-DD): ")
guest_id = ''
for i in range(2):
num1 = random.randint(48, 57)
num2 = random.randint(65, 90)
num3 = random.randint(97, 122)
guest_id = guest_id + chr(num1) + chr(num2) + chr(num3)
print("Your Guest ID is:", guest_id)
except mysql.connector.Error as e:
print(f"Error: {e}")
db.commit()
print(f"Room Rent for Room {room_no} added to the total amount.")
except mysql.connector.Error as e:
print(f"Error: {e}")
def calculate_restaurant_bill(guest_id):
try:
r_bill = 0
while True:
print("Restaurant Menu:")
print("1. Vegetarian Combo -------> Rs. 300")
print("2. Non-Vegetarian Combo -> Rs. 800")
print("3. Snacks or desserts —----> Rs 300")
db.commit()
print("Restaurant bill added to the total amount.")
except mysql.connector.Error as e:
print(f"Error: {e}")
def calculate_gaming_bill(guest_id):
try:
g_bill = 0
while True:
print("\nGaming Options:")
print("1. Table Tennis —--> 150 Rs./hr")
print("2. Bowling —--------> 100 Rs./hr")
print("3. Snooker —-------> 250 Rs./hr")
print("4. Billiards —--------> 400 Rs./hr")
print("5. Video Games —-> 300 Rs./hr")
print("6. Water Sports —--> 350 Rs./hr")
db.commit()
print("Gaming bill added to the total amount.")
except mysql.connector.Error as e:
print(f"Error: {e}")
def book_cars_for_sightseeing(guest_id):
try:
print("\nCars available for sightseeing per hour:")
print("1. Swift Dzire —------> Rs. 200")
print("2. Toyota Innova —--> Rs. 250")
print("3. Nissan Sunny —--> Rs. 310")
print("4. Toyota Fortuner —> Rs. 370")
print("5. Jaguar XF —-------> Rs. 1000")
print("6. Buses —-------------> Rs. 700")
db.commit()
print("Car booking cost added to the total amount")
else:
print("Invalid choice. Please select from 1, 2, 3, 4, 5, 6, or 0 to finish.")
except mysql.connector.Error as e:
print(f"Error: {e}")
# Function to handle final payment, update the main table, and clear guest data by room
number
def final_payment_gateway(guest_id):
try:
cursor.execute("SELECT room_no, pay_total FROM Hotel WHERE guest_id = %s",
(guest_id,))
guest_data = cursor.fetchone()
if guest_data:
total_payment = guest_data[1]
extra_charge = total_payment * 0.1
total_payment += extra_charge
while True:
payment = float(input("Enter the payment amount: "))
if payment >= total_payment:
change = payment - total_payment
print(f"Payment successful. Change: {change} Rs")
except mysql.connector.Error as e:
print(f"Error: {e}")
def queries():
try:
st = input("Enter your queries in proper format: ")
add = eval(input("Enter data for queries: "))
cursor.execute(st, add)
data = cursor.fetchall()
print(data)
except mysql.connector.Error as e:
print(f"Error: {e}")
def main():
while True:
try:
print("\nHotel Management System")
print("Welcome to Star Park Hotel!")
print("Main Menu:")
print("1. To get details")
print("2. Empty the hotel to make a fresh start and add new rooms")
print("3. View available rooms")
print("4. View booked rooms")
print("5. Book a room")
print("6. Calculate room rent")
print("7. Calculate restaurant bill")
print("8. Calculate gaming bill")
print("9. Book cars for sightseeing")
print("10. Final payment gateway and leave the room")
print("11. More queries")
print("0. Exit")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()