0% found this document useful (0 votes)
19 views19 pages

Hotel Management System Code

Uploaded by

hihdigamer
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)
19 views19 pages

Hotel Management System Code

Uploaded by

hihdigamer
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

import datetime

import os

import time

# ============================================================

# HOTEL MANAGEMENT SYSTEM PROJECT

# CLASS 12 PROJECT

# ============================================================

DATA_FILE = "hotel_records.txt"

EXIT_LOG = "exit_log.txt"

ADMIN_PASSWORD = "admin123"

# ------------------ ROOM DATABASE ---------------------------

rooms = {

101: {'type': 'Single', 'AC': 'Yes', 'price': 2000, 'available': True},

102: {'type': 'Double', 'AC': 'Yes', 'price': 3000, 'available': True},

103: {'type': 'Single', 'AC': 'No', 'price': 1500, 'available': True},

104: {'type': 'Double', 'AC': 'No', 'price': 2500, 'available': True},

105: {'type': 'Suite', 'AC': 'Yes', 'price': 5000, 'available': True},

106: {'type': 'Family', 'AC': 'Yes', 'price': 4500, 'available': True}

# ============================================================

# BANNER

# ============================================================

def banner():

print("\n" + "=" * 60)

print(" WELCOME TO GRAND HOTEL SYSTEM")


print("=" * 60)

# ============================================================

# DISPLAY ROOMS

# ============================================================

def display_rooms():

print("\nROOM STATUS\n" + "-" * 50)

for rno, info in [Link]():

status = "Available" if info["available"] else "BOOKED"

print(f"Room {rno}: {info['type']} | AC: {info['AC']} | ₹{info['price']} | {status}")

# ============================================================

# CUSTOMER INFORMATION

# ============================================================

def get_customer():

name = input("Full Name : ")

phone = input("Phone Number : ")

email = input("Email Address : ")

add = input("Full Address : ")

while True:

try:

days = int(input("Stay Duration : "))

break

except:

print(" Enter valid number.")

return name, phone, email, add, days

# ============================================================
# SAVE CUSTOMER TO FILE

# ============================================================

def save_record(rec):

with open(DATA_FILE, "a") as f:

[Link](",".join(str(i) for i in rec) + "\n")

# ============================================================

# LOAD CUSTOMER DATA

# ============================================================

def load_data():

if not [Link](DATA_FILE):

return []

return [[Link]().split(",") for line in open(DATA_FILE)]

# ============================================================

# BOOK A ROOM

# ============================================================

def book_room():

display_rooms()

try:

r = int(input("\nEnter Room No to Book: "))

if r not in rooms:

print(" Room Not Found!")

return

if not rooms[r]['available']:

print(" Room Already Booked!")

return
name, ph, em, ad, days = get_customer()

price = rooms[r]['price']

total = price * days

cin = [Link]().strftime("%Y-%m-%d %H:%M:%S")

cout = "-"

rooms[r]["available"] = False

rec = [name, ph, em, ad, r, price, days, total, cin, cout]

save_record(rec)

print(f"\n✔ ROOM {r} booked for ₹{total}")

except:

print(" Invalid Input")

# ============================================================

# VIEW CUSTOMERS

# ============================================================

def view_customers():

data = load_data()

if not data:

print("\nNo Customer Data Found!")

return

print("\nCUSTOMER LIST\n" + "-" * 40)

for r in data:

print(f"Name : {r[0]}")

print(f"Phone : {r[1]}")

print(f"Room No : {r[4]}")

print(f"Bill : ₹{r[7]}")
print("-" * 40)

# ============================================================

# SEARCH CUSTOMER

# ============================================================

def search_customer():

name = input("Enter Name: ").lower()

for r in load_data():

if r[0].lower() == name:

print("\n✔ CUSTOMER FOUND")

print(r)

return

print(" NO MATCHING CUSTOMER")

# ============================================================

# CHECKOUT CUSTOMER

# ============================================================

def checkout_customer():

name = input("Enter Checkout Name: ").lower()

updated = []

found = False

data = load_data()

for r in data:

if r[0].lower() == name and r[9] == "-":

r[9] = [Link]().strftime("%Y-%m-%d %H:%M:%S")

rooms[int(r[4])]["available"] = True

found = True

[Link](r)
if found:

with open(DATA_FILE, "w") as f:

for i in updated:

[Link](",".join(i) + "\n")

print("✔ Checkout Successful!")

else:

print(" No Active Booking Found")

# ============================================================

# ADMIN LOGIN

# ============================================================

def admin_login():

pwd = input("Admin Password: ")

if pwd == ADMIN_PASSWORD:

print("✔ Login Successful")

return True

print(" Wrong Password")

return False

# ============================================================

# UPDATE ROOM PRICE (ADMIN)

# ============================================================

def update_price():

if not admin_login():

return

r = int(input("Enter Room No: "))

if r not in rooms:
print(" Invalid Room")

return

new = int(input("Enter New Price: "))

rooms[r]["price"] = new

print("✔ PRICE UPDATED")

# ============================================================

# DELETE ALL RECORDS (ADMIN)

# ============================================================

def delete_records():

if not admin_login(): return

if [Link](DATA_FILE): [Link](DATA_FILE)

for r in rooms: rooms[r]["available"] = True

print("✔ ALL RECORDS DELETED")

# ============================================================

# HOTEL SUMMARY

# ============================================================

def summary():

data = load_data()

print("\nSUMMARY REPORT\n" + "=" * 40)

print("Total Guests :", len(data))

print("Total Revenue (₹) :", sum(int(r[7]) for r in data))

print("Rooms Occupied :", sum(not rooms[r]['available'] for r in rooms))

print("Rooms Available :", sum(rooms[r]['available'] for r in rooms))

print("=" * 40)

# ============================================================

# HELP
# ============================================================

def help_menu():

print("\nHELP MENU")

print("- Book Rooms")

print("- Checkout Guests")

print("- View Records")

print("- Admin Update Options")

# ============================================================

# EXIT LOG

# ============================================================

def exit_log():

with open(EXIT_LOG, "a") as log:

[Link]("Exited on: " + [Link]().strftime("%Y-%m-%d %H:%M:%S") + "\n")

# ============================================================

# MAIN MENU

# ============================================================

def menu():

while True:

banner()

print("""

1. Display Rooms

2. Book Room

3. View Customers

4. Search Customer

5. Checkout Customer

6. Admin: Update Price


7. Admin: Delete All Records

8. Summary Report

9. Help

10. Exit

""")

ch = input("Enter Choice: ")

if ch == "1": display_rooms()

elif ch == "2": book_room()

elif ch == "3": view_customers()

elif ch == "4": search_customer()

elif ch == "5": checkout_customer()

elif ch == "6": update_price()

elif ch == "7": delete_records()

elif ch == "8": summary()

elif ch == "9": help_menu()

elif ch == "10":

exit_log()

print("THANK YOU FOR USING HOTEL SYSTEM ❣")

break

else:

print(" INVALID INPUT")

input("\nPress ENTER to continue...")

# ============================================================

# PROGRAM ENTRY

# ============================================================

menu()

You might also like