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

Document 31

Uploaded by

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

Document 31

Uploaded by

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

COMPUTER SCIENCE

PROJECT
(2024-25)

-Hotel Management system

Name: Syed Ali Iqbal


Class: 12th-F
Certificate

This is to certify that the project on Hotel


Managment System; has been successfully
completed by Syed Ali Iqbal from IISD, under my
supervision and guidance in partial fulfilment of
the requirements for the Computer Science
curriculum prescribed by the Central Board of
Secondary Education (CBSE) for the academic
year 2024-25. This project reflects the creativity,
knowledge, and understanding of the subject by
the student. It has been thoroughly reviewed and
found to meet the standards set by CBSE, NEW
DELHI.
I extend my best wishes to Syed Ali Iqbal for his
future academic endeavours.

INTERNAL EXAMINER EXTERNAL


EXAMINER
ACKNOWLEDGEMENT
I would like to express my heartfelt gratitude to
everyone who contributed to the successful completion
of my Computer Science project, Hotel Management
System First and foremost, I am deeply thankful to my
Computer Science teacher, Ms.SMITHA NARASIMHAN,
for her invaluable guidance, encouragement, and
constructive feedback throughout the project. Their
expertise and support have been instrumental in
helping me understand and apply key concepts
effectively. I would also like to extend my sincere
thanks to our Principal, Mr SUNIL PETER, for providing a
conducive learning environment and ensuring all
necessary resources were available to complete this
project successfully. A special thanks to my parents
and family for their constant support, motivation, and
encouragement during this journey. Their faith in my
abilities has always inspired me to give my best. Lastly,
I am grateful to my classmates and friends who shared
their insights, feedback, and ideas, making this project
an enriching and collaborative experience. This project
has been a significant learning experience, and I am
grateful for the opportunity to explore and apply my
knowledge in a practical and meaningful way.

Name: Syed Ali Iqbal


Class: XII-F
Roll Number: 20
Admission No : 81543

PYTHON CODE ON HOTEL MANAGMENT


SYSTEM

CREATE DATABASE hotel_management;

USE hotel_management;

CREATE TABLE guests

( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100),


check_in_date DATE, check_out_date DATE, room_number INT, status
VARCHAR(20) );

pip install mysql-connector

import mysql.connector

from mysql.connector import Error

# Function to connect to the database

def create_connection():

try:

conn = mysql.connector.connect(

host="localhost",
user="root", # Replace with your MySQL username

password="", # Replace with your MySQL password

database="hotel_management"

if conn.is_connected():

print("Connected to MySQL Server")

return conn

except Error as e:

print(f"Error: {e}")

return None

# Function to add guest details

def add_guest(conn):

cursor = conn.cursor()

name = input("Enter guest name: ")

check_in_date = input("Enter check-in date (YYYY-MM-DD): ")

check_out_date = input("Enter check-out date (YYYY-MM-DD): ")

room_number = int(input("Enter room number: "))

status = 'Checked In'

query = "INSERT INTO guests (name, check_in_date,


check_out_date, room_number, status) VALUES (%s, %s, %s, %s, %s)"

values = (name, check_in_date, check_out_date, room_number,


status)

cursor.execute(query, values)

conn.commit()

print("Guest added successfully!")

# Function to view all guests

def view_guests(conn):

cursor = conn.cursor()

query = "SELECT * FROM guests"


cursor.execute(query)

guests = cursor.fetchall()

print("\n--- Guest List ---")

for guest in guests:

print(f"ID: {guest[0]}, Name: {guest[1]}, Check-in:


{guest[2]}, Check-out: {guest[3]}, Room: {guest[4]}, Status:
{guest[5]}")

# Function to update guest status to 'Checked Out'

def check_out_guest(conn):

guest_id = int(input("Enter guest ID to check out: "))

cursor = conn.cursor()

query = "UPDATE guests SET status = 'Checked Out' WHERE id =


%s"

cursor.execute(query, (guest_id,))

conn.commit()

print("Guest checked out successfully!")

# Function to delete a guest record

def delete_guest(conn):

guest_id = int(input("Enter guest ID to delete: "))

cursor = conn.cursor()

query = "DELETE FROM guests WHERE id = %s"

cursor.execute(query, (guest_id,))

conn.commit()

print("Guest record deleted successfully!")

# Main program loop

def hotel_management_system():

conn = create_connection()

if conn is None:

return

while True:
print("\n--- Hotel Management System ---")

print("1. Add Guest")

print("2. View Guests")

print("3. Check-out Guest")

print("4. Delete Guest")

print("5. Exit")

choice = input("Enter your choice: ")

if choice == '1':

add_guest(conn)

elif choice == '2':

view_guests(conn)

elif choice == '3':

check_out_guest(conn)

elif choice == '4':

delete_guest(conn)

elif choice == '5':

print("Exiting the system...")

conn.close()

break

else:

print("Invalid choice. Please try again.")

if __name__ == "__main__":

hotel_management_system()
SAMPLE OUTPUT

Connected to MySQL Server

--- Hotel Management System ---

1. Add Guest

2. View Guests

3. Check-out Guest

4. Delete Guest

5. Exit

Enter your choice: 1


Enter guest name: John Doe

Enter check-in date (YYYY-MM-DD): 2024-11-25

Enter check-out date (YYYY-MM-DD): 2024-11-30

Enter room number: 101

Guest added successfully!

--- Hotel Management System ---

1. Add Guest

2. View Guests

3. Check-out Guest

4. Delete Guest

5. Exit

Enter your choice: 2

--- Guest List ---

ID: 1, Name: John Doe, Check-in: 2024-11-25, Check-out: 2024-11-30,


Room: 101, Status: Checked In

--- Hotel Management System ---

1. Add Guest

2. View Guests

3. Check-out Guest

4. Delete Guest

5. Exit

Enter your choice: 3

Enter guest ID to check out: 1

Guest checked out successfully!

--- Hotel Management System ---


1. Add Guest

2. View Guests

3. Check-out Guest

4. Delete Guest

5. Exit

Enter your choice: 4

Enter guest ID to delete: 1

Guest record deleted successfully!

--- Hotel Management System ---

1. Add Guest

2. View Guests

3. Check-out Guest

4. Delete Guest

5. Exit

Enter your choice: 5

Exiting the system...

You might also like