0% found this document useful (0 votes)
39 views29 pages

MANBODH Da DHABBA

Restaurant management .. All details about the staff, costomer,...

Uploaded by

mohdayaan52348
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)
39 views29 pages

MANBODH Da DHABBA

Restaurant management .. All details about the staff, costomer,...

Uploaded by

mohdayaan52348
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
You are on page 1/ 29

SESSION 2024- 25

CENTRAL ACADEMY SR. SEC.


SCHOOL
INDIRA NAGAR, LUCKNOW

COMPUTER SCIENCE PROJECT ON


RESTRAUNT MANAGEMENT SYSTEM

SUBMITTED BY: Akshat Manbodh


SUBMITTED TO : Mrs. Sweta Gupta
CLASS – XII SEC : A
ROLL NO. 4
CERTIFICATE
This is to certify that the project submitted by
AKSHAT MANBODH on the topic RESTRAUNT
MANAGEMENT SYSTEM in the department of
Computer Science, Central Academy Senior
Secondary, Indira Nagar, Lucknow in the
accordance with the specifications prescribed by
CBSE.

Mrs. Sweta Gupta Mr. D.P. Singh


Project Coordinator Principal
Dept. of Computer Science

External Examiner
ACKNOWLEGDEMENT
I would like to express my heartful gratitude to
my computer teacher, Mrs. Sweta Gupta, who
gave me this opportunity to do this thought-
provoking project on the topic “RESTRAUNT
MANAGEMENT SYSTEM” which enhanced my
knowledge.

I would also like to thank my parents and friends


who helped me in completing this file on time.
Without the guidance and help from each of the
above mentioned, this would not have been
possible.

Teacher’s Signature Submitted By:

Akshat Manbodh
TABLE OF CONTENT

1. Certificate
2. Acknowledgement
3. Introduction
4. Source Code
5. Output
6. Bibliography
Restraunt
management system
Source code
import mysql.connector
from datetime import datetime

# Function to create a connection to the MySQL


database
def create_connection():
"""
Establishes a connection to the MySQL database.
Returns the connection object which can be used
to interact with the database.
"""
return mysql.connector.connect(
host="localhost",
user="root",
password="your_password",
database="restaurant_management"
)

# Function to create necessary tables in the database


def create_tables():
"""
This function creates two tables: menu and orders
in the database.
If the tables already exist, they will not be created
again.
This ensures that the database schema is set up
correctly before we start using it.
"""
db = create_connection()
cursor = db.cursor()

# SQL command to create the menu table


cursor.execute("""
CREATE TABLE IF NOT EXISTS menu (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
price DECIMAL(10, 2),
category VARCHAR(50),
available BOOLEAN DEFAULT TRUE
);
""")

# SQL command to create the orders table


cursor.execute("""
CREATE TABLE IF NOT EXISTS orders (
id INT AUTO_INCREMENT PRIMARY KEY,
item_id INT,
quantity INT,
order_date DATETIME,
FOREIGN KEY (item_id) REFERENCES menu(id)
);
""")

db.commit()
cursor.close()
db.close()
# Function to insert sample data into the menu table
def insert_sample_data():
"""
Inserts predefined sample menu items into the
menu table.
This function is helpful for testing the application
without needing to add items manually.
It will only insert data if the table is empty.
"""
db = create_connection()
cursor = db.cursor()

# Check if the menu table is empty


cursor.execute("SELECT COUNT(*) FROM menu;")
if cursor.fetchone()[0] > 0:
print("Sample data already exists in the menu
table. Skipping insertion.")
cursor.close()
db.close()
return
# List of sample menu items to insert into the
database
sample_menu_items = [
('Pizza', 8.99, 'Main Course'),
('Burger', 5.49, 'Main Course'),
('Ice Cream', 3.99, 'Dessert'),
('Pasta', 7.99, 'Main Course'),
('Salad', 4.99, 'Appetizer'),
('Soda', 1.99, 'Beverage'),
('Coffee', 2.49, 'Beverage'),
('Steak', 14.99, 'Main Course')
]

# Using executemany to insert multiple records at


once
cursor.executemany("INSERT INTO menu (name,
price, category) VALUES (%s, %s, %s)",
sample_menu_items)

db.commit()
cursor.close()
db.close()
print("Sample data inserted into the menu table.")

# Using executemany to insert multiple records at


once
cursor.executemany("INSERT INTO menu (name,
price, category) VALUES (%s, %s, %s)",
sample_menu_items)

db.commit()
cursor.close()
db.close()

# Function to display the current menu


def display_menu():
"""
Fetches and displays all items in the menu from the
database.
This function allows users to see available menu
items and their prices.
"""
db = create_connection()
cursor = db.cursor()

# SQL command to fetch all items from the menu


table
cursor.execute("SELECT * FROM menu;")
menu_items = cursor.fetchall()

print("Menu:")
for item in menu_items:
# Display each menu item with its details
print(
f"ID: {item[0]}, Name: {item[1]}, Price:
{item[2]:.2f}, Category: {item[3]}, Available: {'Yes' if
item[4] else 'No'}")

cursor.close()
db.close()

# Function to place an order


def place_order(item_id, quantity):
"""
Places an order for a specific menu item by
inserting it into the orders table.
Takes item_id and quantity as parameters.
"""
db = create_connection()
cursor = db.cursor()

order_date = datetime.now()
# SQL command to insert a new order into the
orders table
cursor.execute("INSERT INTO orders (item_id,
quantity, order_date) VALUES (%s, %s, %s)",
(item_id, quantity, order_date))

db.commit()
cursor.close()
db.close()
# Notify the user that the order was placed
successfully
print(f"Order placed: Item ID {item_id}, Quantity
{quantity}")
# Function to view all orders placed
def view_orders():
"""
Fetches and displays all orders from the orders
table.
This function allows users to see a list of their past
orders.
"""
db = create_connection()
cursor = db.cursor()

# SQL command to fetch all orders along with the


corresponding menu item names
cursor.execute("SELECT o.id, m.name, o.quantity,
o.order_date FROM orders o JOIN menu m ON
o.item_id = m.id;")
orders = cursor.fetchall() # Fetch all rows returned
by the query

print("Orders:")
for order in orders:
# Display each order with its details
print(f"Order ID: {order[0]}, Item: {order[1]},
Quantity: {order[2]}, Date: {order[3]}")

cursor.close()
db.close()

# Function to update an existing menu item


def update_menu_item(item_id, name=None,
price=None, category=None, available=None):
"""
Updates the details of a menu item based on user
input.
Parameters:
- item_id: The ID of the menu item to update
- name: New name for the menu item (optional)
- price: New price for the menu item (optional)
- category: New category for the menu item
(optional)
- available: New availability status for the menu
item (optional)
"""
db = create_connection()
cursor = db.cursor()

# Prepare updates based on user input


updates = []
params = []

# Check if the name needs to be updated


if name is not None:
updates.append("name = %s")
params.append(name)

# Check if the price needs to be updated


if price is not None:
updates.append("price = %s")
params.append(price)

# Check if the category needs to be updated


if category is not None:
updates.append("category = %s")
params.append(category)
if available is not None:
updates.append("available = %s")
params.append(available)

# Execute the update if any changes were


specified
if updates:
# Prepare the final SQL update command
query = f"UPDATE menu SET {', '.join(updates)}
WHERE id = %s"
params.append(item_id)
cursor.execute(query, params)

db.commit()
cursor.close()
db.close()

# Notify the user that the menu item was updated


print(f"Menu item with ID {item_id} has been
updated.")
# Function to delete a menu item
def delete_menu_item(item_id):
"""
Deletes a menu item from the menu table based on
the item ID provided.
"""
db = create_connection()
cursor = db.cursor()

# SQL command to delete a menu item


cursor.execute("DELETE FROM menu WHERE id =
%s", (item_id,))

db.commit()
cursor.close()
db.close()

# Notify the user that the menu item was deleted


print(f"Menu item with ID {item_id} has been
deleted.")
# Function to search for a menu item by name

def search_menu_item(name):
"""
Searches for a menu item by its name.
Returns the details of the menu item if found.
"""
db = create_connection()
cursor = db.cursor()

# SQL command to search for a menu item by


name
cursor.execute("SELECT * FROM menu WHERE name
LIKE %s", ('%' + name + '%',))
menu_items = cursor.fetchall()

if menu_items:
print("Search Results:")
for item in menu_items:
print(
f"ID: {item[0]}, Name: {item[1]}, Price:
{item[2]:.2f}, Category: {item[3]}, Available: {'Yes' if
item[4] else 'No'}")
else:
print("No items found.")

cursor.close()
db.close()

# Function to view total sales


def view_total_sales():
"""
Calculates and displays the total sales amount
from all orders placed.
"""
db = create_connection()
cursor = db.cursor()

# SQL command to calculate total sales


cursor.execute("""
SELECT SUM(m.price * o.quantity) AS total_sales
FROM orders o
JOIN menu m ON o.item_id = m.id;
""")
total_sales = cursor.fetchone()[0]

print(f"Total Sales: ${total_sales:.2f}")

cursor.close()
db.close()

# Function to view orders within a specific date range

def view_orders_by_date(start_date, end_date):


"""
Fetches and displays all orders placed within a
specific date range.
"""
db = create_connection()
cursor = db.cursor()
# SQL command to fetch orders within the specified
date range
cursor.execute("""
SELECT o.id, m.name, o.quantity, o.order_date
FROM orders o
JOIN menu m ON o.item_id = m.id
WHERE o.order_date BETWEEN %s AND %s;
""", (start_date, end_date))

orders = cursor.fetchall()

print(f"Orders from {start_date} to {end_date}:")


for order in orders:
print(f"Order ID: {order[0]}, Item: {order[1]},
Quantity: {order[2]}, Date: {order[3]}")

cursor.close()
db.close()

# Main execution block


if __name__ == "__main__":
create_tables()
insert_sample_data()
while True:
print("\nRestaurant Management System")
print("1. Display Menu")
print("2. Place Order")
print("3. View Orders")
print("4. Update Menu Item")
print("5. Delete Menu Item")
print("6. Search Menu Item")
print("7. View Total Sales")
print("8. View Orders by Date Range")
print("9. Exit")

choice = input("Enter your choice: ")

if choice == '1':
display_menu()
elif choice == '2':
item_id = int(input("Enter item ID to order: "))
quantity = int(input("Enter quantity: "))
place_order(item_id, quantity)
elif choice == '3':
view_orders()
elif choice == '4':
item_id = int(input("Enter item ID to update: "))
name = input("Enter new name (leave blank to
skip): ")
price = input("Enter new price (leave blank to
skip): ")
category = input("Enter new category (leave
blank to skip): ")
available = input("Is it available? (yes/no,
leave blank to skip): ")
available = available.lower() == 'yes' if
available else None
update_menu_item(item_id, name if name
else None, float(price) if price else None,
category if category else None,
available)
elif choice == '5':
item_id = int(input("Enter item ID to delete: "))
delete_menu_item(item_id)
elif choice == '6':
name = input("Enter the name of the menu
item to search for: ")
search_menu_item(name)
elif choice == '7':
view_total_sales()
elif choice == '8':
start_date = input("Enter start date (YYYY-MM-
DD): ")
end_date = input("Enter end date (YYYY-MM-
DD): ")
view_orders_by_date(start_date, end_date)
elif choice == '9':
break
else:
print("Invalid choice. Please try again.")
OUTPUT
1.Display Menu

2.Place Order
3.View Orders

4.Update Menu Item

5.Delete Menu Item


6.Search Menu Item

7.View Total Sale

8.View Order by Date Range


Bibliography

brainycode.org
codingninjas.com
learnpython.org
gitticodingzone.com

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