0% found this document useful (0 votes)
13 views10 pages

Hotel Management System Documentation

Uploaded by

Amrita Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views10 pages

Hotel Management System Documentation

Uploaded by

Amrita Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Hotel Management System Documentation

Overview
The Hotel Management System is a graphical user interface (GUI) application built using
Tkinter and SQLite in Python. It allows hotel administrators to manage guest bookings,
perform check-ins and check-outs, export booking details, and manage user authentication.

Features
1. Guest Management
o Add new guests with name, room number, check-in, and check-out dates.
o Display all guests currently checked into the hotel.
o Check out guests and remove them from the database.
2. Export Bookings
o Export all booking details to a text file for record keeping.
3. User Management
o Secure login system with username and password authentication.
o Ability to create new user accounts for hotel administrators.

Modules
1. Main Module: hotel_management.py

 Functionality:
o Establishes a connection to SQLite database (hotel_management.db).
o Defines GUI elements using Tkinter for guest management, booking export,
and user authentication.
o Implements functions to interact with the database (add, delete guests) and
handle user login/authentication.

2. Database Schema: hotel_management.db

 Tables:
o guests: Stores guest information including id, name, room_number,
check_in_date, and check_out_date.

3. User Authentication: login_credentials.txt

 Stores usernames and hashed passwords for user authentication purposes.

GUI Components
Dark Theme Colors

 BG_COLOR: Background color (#2b2b2b)


 FG_COLOR: Foreground (text) color (#ffffff)
 BTN_COLOR: Button color (#444444)
 ENTRY_BG_COLOR: Entry widget background color (#333333)

Widgets

 Labels, Entries, Buttons, and Listbox widgets are styled using the defined dark theme
colors to provide a visually cohesive user interface.

Usage
1. Login
oLaunch the application and enter valid credentials to access the main interface.
oCreate new user accounts if necessary using the provided interface.
2. Main Interface
o Add guests by filling in the required fields and clicking the "Check-In" button.
o View current guests, perform check-outs, and export bookings as needed.

Dependencies
 Python Libraries:
o sqlite3: Database interaction.
o tkinter: GUI development.
o datetime: Handling date inputs and comparisons.
o os: File and directory operations.
Known Issues
 No known issues at the time of documentation.
Future Enhancements
 Implement data validation for date inputs (e.g., valid date formats, range checks).
 Enhance user interface with additional features such as room status visualization and
booking statistics.

Author
 Author Names: Aditya Mishra, Vedant Vasaikar
 Version: 1.0
 Date:
import sqlite3

import tkinter as tk

from tkinter import messagebox, filedialog

import os

import datetime

# Establish SQLite connection and create tables if they don't exist

conn = sqlite3.connect('hotel_management.db')

cursor = conn.cursor()

cursor.execute('''

CREATE TABLE IF NOT EXISTS guests (

id INTEGER PRIMARY KEY,

name TEXT,

room_number INTEGER,

check_in_date DATE,

check_out_date DATE

''')

# Define Dark Theme Colors

BG_COLOR = '#2b2b2b' # Background color

FG_COLOR = '#ffffff' # Foreground (text) color

BTN_COLOR = '#444444' # Button color

ENTRY_BG_COLOR = '#333333' # Entry widget background color

# Function to add a guest to the database

def add_guest():

try:

name = name_entry.get()

room_number = int(room_entry.get())

check_in_date_str = check_in_entry.get()
check_out_date_str = check_out_entry.get()

# Basic validation

if not name or not check_in_date_str or not check_out_date_str:

messagebox.showerror("Error", "Please fill in all fields.")

return

# Convert dates to date objects for comparison

check_in_date = datetime.datetime.strptime(check_in_date_str, "%Y-%m-%d").date()

check_out_date = datetime.datetime.strptime(check_out_date_str, "%Y-%m-%d").date()

# Ensure check-out date is not earlier than check-in date

if check_out_date < check_in_date:

messagebox.showerror("Error", "Check-out date cannot be earlier than check-in date.")

return

# Ensure check-in date is not earlier than current date

current_date = datetime.date.today()

if check_in_date < current_date:

messagebox.showerror("Error", "Check-in date cannot be earlier than current date.")

return

# Insert into database

cursor.execute('INSERT INTO guests (name, room_number, check_in_date, check_out_date)


VALUES (?, ?, ?, ?)', (name, room_number, check_in_date_str, check_out_date_str))

conn.commit()

messagebox.showinfo("Check-In", "Guest checked in successfully.")

# Clear entry fields and update guest list

name_entry.delete(0, tk.END)

room_entry.delete(0, tk.END)

check_in_entry.delete(0, tk.END)

check_out_entry.delete(0, tk.END)

display_guests()

except ValueError:

messagebox.showerror("Error", "Room number must be a valid integer.")

except sqlite3.Error as e:
messagebox.showerror("Database Error", f"Error inserting guest: {e}")

except Exception as e:

messagebox.showerror("Error", f"An unexpected error occurred: {e}")

# Function to display all guests in the listbox

def display_guests():

try:

cursor.execute('SELECT * FROM guests')

guests = cursor.fetchall()

guest_list.delete(0, tk.END)

for guest in guests:

guest_list.insert(tk.END, f"ID: {guest[0]}, Name: {guest[1]}, Room: {guest[2]}, Check-in:


{guest[3]}, Check-out: {guest[4]}")

except sqlite3.Error as e:

messagebox.showerror("Database Error", f"Error fetching guests: {e}")

# Function to check out a guest

def check_out_guest():

try:

selected = guest_list.get(tk.ACTIVE)

if not selected:

messagebox.showerror("Error", "Please select a guest to check out.")

return

guest_id = int(selected.split(',')[0].split(': ')[1])

cursor.execute('DELETE FROM guests WHERE id = ?', (guest_id,))

conn.commit()

messagebox.showinfo("Check-Out", "Guest checked out successfully.")

display_guests()

except sqlite3.Error as e:

messagebox.showerror("Database Error", f"Error checking out guest: {e}")

# Function to export bookings to a text file


def export_bookings():

try:

file_path = filedialog.asksaveasfilename(defaultextension=".txt", filetypes=[("Text files",


"*.txt")])

if not file_path:

return

with open(file_path, 'w') as file:

cursor.execute('SELECT * FROM guests')

guests = cursor.fetchall()

for guest in guests:

file.write(f"ID: {guest[0]}, Name: {guest[1]}, Room: {guest[2]}, Check-in: {guest[3]}, Check-


out: {guest[4]}\n")

messagebox.showinfo("Export Complete", "Bookings exported successfully.")

except IOError as e:

messagebox.showerror("Error", f"Error exporting bookings: {e}")

except sqlite3.Error as e:

messagebox.showerror("Database Error", f"Error fetching guests: {e}")

# Function to handle create user button click

def create_user():

try:

new_username = new_username_entry.get()

new_password = new_password_entry.get()

if not new_username or not new_password:

messagebox.showerror("Error", "Username and password cannot be empty.")

return

# Append new credentials to the file

with open('login_credentials.txt', 'a') as file:

file.write(f"{new_username}:{new_password}\n")

messagebox.showinfo("Success", "User created successfully.")

new_username_entry.delete(0, tk.END)

new_password_entry.delete(0, tk.END)

except IOError as e:
messagebox.showerror("Error", f"Error writing to login credentials file: {e}")

# Function to handle login button click

def login():

try:

username = username_entry.get()

password = password_entry.get()

# Read credentials from file

with open('login_credentials.txt', 'r') as file:

credentials = file.readlines()

# Check if credentials match

for credential in credentials:

stored_username, stored_password = credential.strip().split(':')

if username == stored_username and password == stored_password:

messagebox.showinfo("Login Successful", "Welcome!")

login_window.destroy() # Close login window

show_main_window()

return

messagebox.showerror("Login Failed", "Invalid username or password")

username_entry.delete(0, tk.END)

password_entry.delete(0, tk.END)

except IOError as e:

messagebox.showerror("Error", f"Error reading login credentials file: {e}")

# Function to show the main hotel management window

def show_main_window():

global window

window = tk.Tk()

window.title("Hotel Management System")

window.configure(bg=BG_COLOR) # Set background color

# Frame for adding guests

add_frame = tk.Frame(window, bg=BG_COLOR)


add_frame.pack(padx=10, pady=10)

name_label = tk.Label(add_frame, text="Name:", bg=BG_COLOR, fg=FG_COLOR)

name_label.grid(row=0, column=0, padx=5, pady=5)

global name_entry

name_entry = tk.Entry(add_frame, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

name_entry.grid(row=0, column=1, padx=5, pady=5)

room_label = tk.Label(add_frame, text="Room Number:", bg=BG_COLOR, fg=FG_COLOR)

room_label.grid(row=1, column=0, padx=5, pady=5)

global room_entry

room_entry = tk.Entry(add_frame, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

room_entry.grid(row=1, column=1, padx=5, pady=5)

check_in_label = tk.Label(add_frame, text="Check-In Date (YYYY-MM-DD):", bg=BG_COLOR,


fg=FG_COLOR)

check_in_label.grid(row=2, column=0, padx=5, pady=5)

global check_in_entry

check_in_entry = tk.Entry(add_frame, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

check_in_entry.grid(row=2, column=1, padx=5, pady=5)

check_out_label = tk.Label(add_frame, text="Check-Out Date (YYYY-MM-DD):", bg=BG_COLOR,


fg=FG_COLOR)

check_out_label.grid(row=3, column=0, padx=5, pady=5)

global check_out_entry

check_out_entry = tk.Entry(add_frame, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

check_out_entry.grid(row=3, column=1, padx=5, pady=5)

check_in_button = tk.Button(add_frame, text="Check-In", command=add_guest, bg=BTN_COLOR,


fg=FG_COLOR)

check_in_button.grid(row=4, columnspan=2, pady=10)

# Frame for displaying guests

display_frame = tk.Frame(window, bg=BG_COLOR)

display_frame.pack(padx=10, pady=10)

guest_list_label = tk.Label(display_frame, text="Guests:", bg=BG_COLOR, fg=FG_COLOR)

guest_list_label.pack()

global guest_list
guest_list = tk.Listbox(display_frame, width=50, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

guest_list.pack(pady=5)

# Frame for actions (Check-Out and Export)

action_frame = tk.Frame(window, bg=BG_COLOR)

action_frame.pack(padx=10, pady=10)

check_out_button = tk.Button(action_frame, text="Check-Out", command=check_out_guest,


bg=BTN_COLOR, fg=FG_COLOR)

check_out_button.grid(row=0, column=0, padx=5)

export_button = tk.Button(action_frame, text="Export Bookings", command=export_bookings,


bg=BTN_COLOR, fg=FG_COLOR)

export_button.grid(row=0, column=1, padx=5)

# Display initial list of guests

display_guests()

window.mainloop()

# Function to create login window

def show_login_window():

global login_window

login_window = tk.Tk()

login_window.title("Login")

login_window.configure(bg=BG_COLOR)

username_label = tk.Label(login_window, text="Username:", bg=BG_COLOR, fg=FG_COLOR)

username_label.pack(pady=5)

global username_entry

username_entry = tk.Entry(login_window, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

username_entry.pack(pady=5)

password_label = tk.Label(login_window, text="Password:", bg=BG_COLOR, fg=FG_COLOR)

password_label.pack(pady=5)

global password_entry

password_entry = tk.Entry(login_window, show="*", bg=ENTRY_BG_COLOR, fg=FG_COLOR)

password_entry.pack(pady=5)

login_button = tk.Button(login_window, text="Login", command=login, bg=BTN_COLOR,


fg=FG_COLOR)
login_button.pack(pady=10)

# Frame for creating new user

create_user_frame = tk.Frame(login_window, bg=BG_COLOR)

create_user_frame.pack(pady=10)

new_username_label = tk.Label(create_user_frame, text="New Username:", bg=BG_COLOR,


fg=FG_COLOR)

new_username_label.grid(row=0, column=0, padx=5, pady=5)

global new_username_entry

new_username_entry = tk.Entry(create_user_frame, bg=ENTRY_BG_COLOR, fg=FG_COLOR)

new_username_entry.grid(row=0, column=1, padx=5, pady=5)

new_password_label = tk.Label(create_user_frame, text="New Password:", bg=BG_COLOR,


fg=FG_COLOR)

new_password_label.grid(row=1, column=0, padx=5, pady=5)

global new_password_entry

new_password_entry = tk.Entry(create_user_frame, show="*", bg=ENTRY_BG_COLOR,


fg=FG_COLOR)

new_password_entry.grid(row=1, column=1, padx=5, pady=5)

create_button = tk.Button(create_user_frame, text="Create User", command=create_user,


bg=BTN_COLOR, fg=FG_COLOR)

create_button.grid(row=2, columnspan=2, pady=10)

login_window.mainloop()

# Function to initialize the login window

show_login_window()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy