0% found this document useful (0 votes)
8 views24 pages

Ip Project

Uploaded by

shuklaanmol1997
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)
8 views24 pages

Ip Project

Uploaded by

shuklaanmol1997
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/ 24

Sagar Public School, Saket Nagar

Bhopal

Project Record
Food Ordering System
(Informatics Practices)
Session: 2024-25

Submitted To:
Ms. Sumita Shrivastava
HOD (IP)
SUBMITTED BY:
Kushagra Katiyar
Adeesh Jain

Class XII A
CERTIFICATE

This is to certify that Mr. Adeesh Jain, Roll Number 2 and


Mr. Kushagra Katiyar, Roll Number 20 of Class XII A has
successfully completed his Practical Work in Informatics
Practices during the Session 2024-25, strictly as per the
guidelines of CBSE.

Date :

_____________________ _____________________
(Principal Signature) (Institution Stamp)

_____________________ _____________________
(Internal Signature) (Examiner Signature)
ACKNOWLEDGEMENT

I express all my sincere thanks to my School Sagar


Public School Saket Nagar, Bhopal for providing all
necessary facilities which were required for the
completion of this Practical assignment.

I also acknowledge the support received from the IP


teacher Ms. Sumati Shrivastava, without her help,
guidance, and support it could have been impossible to
complete this assignment.

Lastly, I would like to thank the Principal of our School


Ms. Pankaj Sharma for providing an opportunity to
initiate ourselves with these kinds of assignments.

Kushagra Katiyar
Adeesh Jain
Class : XII
ABSTRACT

This project introduces a state-of-the-art digital ordering platform


developed using Python’s Tkinter GUI toolkit. The application offers
a highly intuitive and user-friendly interface that facilitates
seamless order placement, management, and tracking. Tkinter’s
flexibility ensures the platform is both visually appealing and
responsive, enhancing user interaction.

The platform is powered by a SQL-based database management


system, providing robust backend support for efficient data storage,
retrieval, and manipulation. Features such as user authentication,
dynamic menu displays, order confirmation, and payment history
tracking ensure functionality and reliability.

A strong focus on modular programming principles makes the


system highly scalable and maintainable. The integration of
Python’s front-end capabilities with SQL’s data management
techniques allows for a structured, robust, and efficient solution,
ideal for demonstrating the power of database-driven application
development.

Designed with simplicity and innovation in mind, this project offers


a practical approach to digital order automation, particularly suited
for industries such as food service and retail. It serves as a valuable
educational tool, blending fundamental and advanced concepts of
GUI design and database management.
Introduction
Efficient management systems have become essential in the
modern era to streamline routine tasks and minimize inefficiencies.
This project focuses on developing a food ordering and
management system, leveraging Python's Tkinter library for a
user-friendly graphical user interface (GUI) and seamless
interaction.

The system integrates with a MySQL database, ensuring secure,


non-redundant, and consistent storage of user credentials, order
details, and payment histories. The GUI allows users to register, log
in, and perform actions like placing orders, viewing payment history,
and managing orders, all within an intuitive interface. The
application emphasizes dynamic interaction by enabling users to
make selections, confirm their choices, and visualize their order
details in real-time.

Designed with scalability in mind, the project can be customized for


a variety of settings, such as small eateries, cafes, or online food
delivery platforms. By combining robust database handling and
responsive GUI elements, this system demonstrates the potential of
Python and SQL in solving real-world challenges.
Implementation
Prerequisites

● Python Libraries: Tkinter, mysql-connector-python.


● MySQL Server Configuration: Username: root, Password: root.

Setup

1. Configure MySQL with a database (db) containing:


○ user_credential: Stores user login details.
○ orders: Logs order information (items, quantities, and user
details).
2. Initialize menu items and categories in the application.

Core Features

● User Authentication: Secure login and registration via MySQL.


● Dynamic Menus: Multi-tab interface for item selection and real-time
subtotal updates.
● Order Confirmation: Summarizes and stores user orders in the
database.
● Payment History: Displays past orders specific to the logged-in user.

Error Handling

● Validates user inputs to prevent duplicates and invalid entries.


● Ensures database consistency with transaction management.

Application Flow

1. Welcome Page: Offers login or registration options.


2. Post-Login Dashboard: Access to order placement and payment
history.
3. Ordering System: Enables item selection, order confirmation, and
database logging.
4. History Viewer: Fetches and displays order records for the user.
CODE

import tkinter as tk
from tkinter import ttk, messagebox
import mysql.connector

class WelcomeWindow(tk.Tk):
def __init__(self):
super().__init__()
self.title("Hungry?")
self.geometry("600x400")
self.resizable(False, False)
self.configure(bg="#f0f0f0")

# Create the welcome label


welcome_label = tk.Label(self, text="Welcome to
Gourmet Express", font=("Arial", 20), bg="#f0f0f0")
welcome_label.pack(pady=20)

# Create the login button


login_button = tk.Button(self, text="Login",
font=("Arial", 16), bg="#4caf50", fg="white", padx=20,
pady=10, command=lambda: self.open_login_page())
login_button.pack(pady=10)

# Create the register button


register_button = tk.Button(self, text="Register",
font=("Arial", 16), bg="#4caf50", fg="white", padx=20,
pady=10, command=self.open_registration_page)
register_button.pack(pady=10)

self.db = mysql.connector.connect(
host="localhost", user="root", password="root",
database="db"
)
self.cursor = self.db.cursor()
self.logged_in_user = None

def center_window(self, width, height, window=None):


"""Centers the given window on the screen."""
window = window or self
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
x = (screen_width - width) // 2
y = (screen_height - height) // 2
window.geometry(f"{width}x{height}+{x}+{y}")

def open_login_page(self):
# Hide the Welcome Window
self.withdraw()

# Create a new window for the login page


login_page = tk.Toplevel(self)
login_page.title("Login")
login_page.geometry("300x200")
login_page.config(bg="#2E2E2E")

# Create a label for the username entry


username_label = ttk.Label(login_page,
text="Username")
username_label.grid(column=0, row=0, padx=10,
pady=10, sticky=tk.W)

# Create an entry for the username


username_entry = ttk.Entry(login_page, width=25)
username_entry.grid(column=1, row=0, padx=10,
pady=10, sticky=tk.E)

# Create a label for the password entry


password_label = ttk.Label(login_page,
text="Password")
password_label.grid(column=0, row=1, padx=10,
pady=10, sticky=tk.W)
# Create an entry for the password
password_entry = ttk.Entry(login_page, show="*",
width=25)
password_entry.grid(column=1, row=1, padx=10,
pady=10, sticky=tk.E)

# Create a button for the login


login_button = ttk.Button(login_page, text="Login",
command=lambda: self.login(username_entry.get(),
password_entry.get(), login_page))
login_button.grid(column=0, row=2, columnspan=2,
pady=20)

def open_registration_page(self):
# Create a new window for the registration page
registration_page = tk.Toplevel(self)
registration_page.title("Register")
registration_page.geometry("300x200")
registration_page.config(bg="#2E2E2E")

# Create a label for the username entry


username_label = ttk.Label(registration_page,
text="Username")
username_label.grid(column=0, row=0, padx=10,
pady=10, sticky=tk.W)

# Create an entry for the username


username_entry = ttk.Entry(registration_page,
width=25)
username_entry.grid(column=1, row=0, padx=10,
pady=10, sticky=tk.E)

# Create a label for the password entry


password_label = ttk.Label(registration_page,
text="Password")
password_label.grid(column=0, row=1, padx=10,
pady=10, sticky=tk.W)

# Create an entry for the password


password_entry = ttk.Entry(registration_page,
show="*", width=25)
password_entry.grid(column=1, row=1, padx=10,
pady=10, sticky=tk.E)

# Create a button for registration


register_button = ttk.Button(registration_page,
text="Register", command=lambda:
self.register_user(username_entry.get(),
password_entry.get(), registration_page))
register_button.grid(column=0, row=2, columnspan=2,
pady=20)

def open_post_login_options(self):
"""Open a popup with options after successful login
or registration."""
options_popup = tk.Toplevel(self)
options_popup.title("Choose an Option")
self.center_window(300, 200, options_popup)
options_popup.config(bg="#2E2E2E")

tk.Label(
options_popup, text="Welcome!",
font=("Helvetica", 16), bg="#2E2E2E", fg="#FFF"
).pack(pady=10)

tk.Button(
options_popup,
text="Order Food",
command=lambda: [self.open_menu_window()],
width=20,
bg="#4caf50",
fg="#FFF",
).pack(pady=5)

tk.Button(
options_popup,
text="Track Order",
command=self.open_track_order(),
width=20,
bg="#4caf50",
fg="#FFF",
).pack(pady=5)

tk.Button(
options_popup,
text="Payment History",
command=self.open_payment_history(),
width=20,
bg="#4caf50",
fg="#FFF",
).pack(pady=5)

def open_track_order(self):
"""Open a popup for tracking orders (currently
empty)."""
track_order_popup = tk.Toplevel(self)
track_order_popup.title("Track Order")
self.center_window(300, 200, track_order_popup)
track_order_popup.config(bg="#2E2E2E")

tk.Label(
track_order_popup,
text="Track Order (Coming Soon)",
font=("Helvetica", 14),
bg="#2E2E2E",
fg="#FFF",
).pack(pady=20)

def open_payment_history(self):
"""Open a popup for payment history displaying user's
orders."""
if not self.logged_in_user:
messagebox.showerror("Error", "You need to log in
first.")
return
payment_history_popup = tk.Toplevel(self)
payment_history_popup.title("Payment History")
self.center_window(600, 400, payment_history_popup)
payment_history_popup.config(bg="#2E2E2E")

# Fetch user order history from the database


self.cursor.execute(
"SELECT orderITEMS, totalAMT FROM orders WHERE
name = %s",
(self.logged_in_user,)
)
orders = self.cursor.fetchall()

if not orders:
tk.Label(payment_history_popup, text="No payment
history found.", font=("Helvetica", 14), bg="#2E2E2E",
fg="#FFF").pack(pady=20)
return

# Display the orders


for order in orders:
orderID, orderITEMS, totalAMT, order_time = order
order_details = f"Order ID: {orderID}\nItems:
{orderITEMS}\nTotal: ₹{totalAMT}\nDate:
{order_time.strftime('%Y-%m-%d %H:%M:%S')}"
tk.Label(payment_history_popup,
text=order_details, font=("Helvetica", 12), bg="#2E2E2E",
fg="#FFF").pack(pady=10)

def login(self, username, password, login_page):


# Execute a SQL query to check if the username and
password match
self.cursor.execute(
"SELECT USER_NAME, USER_PASS FROM user_credential
WHERE USER_NAME = %s AND USER_PASS = %s",
(username, password),
)
login_data = self.cursor.fetchall()
# If the result is not empty, proceed to further
selections
if login_data:
self.logged_in_user = username # Store the
logged-in username
login_page.destroy() # Close the login popup
self.open_post_login_options() # Show the
options after login
else:
messagebox.showerror("Login Failed", "Invalid
username or password")

def register_user(self, username, password,


registration_page):
try:
self.cursor.execute(
"INSERT INTO user_credential (USER_NAME,
USER_PASS) VALUES (%s, %s)",
(username, password),
)
self.db.commit()
messagebox.showinfo("Registration", f"Username:
{username} registered successfully!")
registration_page.destroy() # Close the
registration popup
self.deiconify() # Show the Welcome window again
after registration
except Exception as e:
messagebox.showerror("Error", f"Registration
failed: {e}")

def open_menu_window(self):
"""Open the menu window."""
menu_window = tk.Toplevel(self)
menu_window.title("Menu Ordering Page")
self.center_window(600, 700, menu_window)
menu_window.config(bg="#2E2E2E")
self.create_menu_ui(menu_window)

def create_menu_ui(self, menu_window):


selected_items = []
subtotal_var = tk.StringVar()

def calculate_subtotal():
subtotal = 0
selected_items.clear()
for category_vars in menu_var_lists.values():
for ((item_name, price), item_count_var) in
category_vars:
count = item_count_var.get()
if count > 0:
subtotal += price * count
selected_items.append((item_name,
price, count))
subtotal_var.set(f"{subtotal:.2f}/-")

def confirm_order():
calculate_subtotal()
if not selected_items:
messagebox.showwarning("No Items", "Please
select items to place an order.")
return

confirmation_popup = tk.Toplevel(menu_window)
confirmation_popup.title("Confirm Order")
confirmation_popup.geometry("600x750")
confirmation_popup.config(bg="#2E2E2E")

tk.Label(confirmation_popup, text="Your Order",


font=("Helvetica", 14), bg="#2E2E2E",
fg="#FFF").pack(pady=10)
for item_name, price, count in selected_items:
tk.Label(confirmation_popup,
text=f"{item_name} x {count} = ₹{price * count}",
bg="#2E2E2E", fg="#FFF").pack()
tk.Label(confirmation_popup, text=f"Total:
{subtotal_var.get()}", font=("Helvetica", 12), bg="#2E2E2E",
fg="#FFF").pack(pady=10)

def finalize_order():
confirmation_popup.destroy()
messagebox.showinfo(
"Order Complete",
"Your order is complete. Please pick up
your order from the window number 2.",
)

tk.Button(
confirmation_popup, text="Confirm and Place
Order", command=finalize_order, bg="#444", fg="#FFF"
).pack(pady=20)

user_name = name_entry.get()
user_address = address_entry.get()
user_phone = phone_entry.get()

order_items_str = ", ".join([f"{item_name} x


{count}" for item_name, price, count in selected_items])
total_amount =
float(subtotal_var.get().replace("/-", "").strip())

try:
query = """
INSERT INTO orders (name, address, phone_no,
orderITEMS, totalAMT)
VALUES (%s, %s, %s, %s, %s)
"""
values = (user_name, user_address,
user_phone, order_items_str, total_amount)
self.cursor.execute(query, values)
self.db.commit()
messagebox.showinfo(
"Order Complete",
"Please Confirm Your Order and Proceed
with Payment",
)
except Exception as e:
messagebox.showerror("Database Error", f"An
error occurred while saving the order: {e}")

name_label = tk.Label(menu_window, text="Name:",


bg="#2E2E2E", fg="#FFF")
name_label.grid(row=0, column=0, padx=10, pady=10)
name_entry = tk.Entry(menu_window, width=30)
name_entry.grid(row=0, column=1, padx=10, pady=10)

address_label = tk.Label(menu_window,
text="Address:", bg="#2E2E2E", fg="#FFF")
address_label.grid(row=1, column=0, padx=10, pady=10)
address_entry = tk.Entry(menu_window, width=30)
address_entry.grid(row=1, column=1, padx=10, pady=10)

phone_label = tk.Label(menu_window, text="Phone No:",


bg="#2E2E2E", fg="#FFF")
phone_label.grid(row=2, column=0, padx=10, pady=10)
phone_entry = tk.Entry(menu_window, width=30)
phone_entry.grid(row=2, column=1, padx=10, pady=10)

notebook = ttk.Notebook(menu_window)
notebook.grid(row=3, column=0, columnspan=2, pady=20)

menu_categories = {
"Starters": [
("Tomato Soup", 50), ("Veg Manchow Soup",
60), ("Salad", 60), ("Paneer Tikka", 120), ("Crispy Corn",
110),
("Vegetable Pakora", 80), ("Spring Rolls",
100), ("Hara Bhara Kebab", 90), ("Stuffed Mushrooms", 130),
("Corn Cheese Balls", 120), ("Veg Seekh
Kebab", 150)
],
"Main Course": [
("Paneer Butter Masala", 200), ("Shahi
Paneer", 180), ("Aloo Gobi", 130), ("Dal Makhani", 150),
("Veg Biryani", 150), ("Lemon Rice", 120),
("Mushroom Masala", 180), ("Mix Veg Curry", 160),
("Bhindi Masala", 140), ("Chana Masala",
150), ("Kofta Curry", 170)
],
"Breads": [
("Tava Roti", 15), ("Tandoori Roti", 20),
("Garlic Naan", 30), ("Paratha", 30),
("Butter Naan", 25), ("Stuffed Kulcha", 40),
("Missi Roti", 25), ("Roomali Roti", 30),
("Laccha Paratha", 35), ("Cheese Naan",
50),("Extra Butter", 20)
],
"Desserts": [
("Ice Cream", 50), ("Gulab Jamun", 50),
("Moong Dal Halwa", 60), ("Rasmalai", 60), ("Fruit Custard",
60),
("Chocolate Brownie", 80), ("Carrot Halwa",
70), ("Rasgulla", 50), ("Kulfi (Pista)", 70),
("Shahi Tukda", 80), ("Jalebi", 50)
],
}

menu_var_lists = {}
for category, items in menu_categories.items():
category_frame = ttk.Frame(notebook)
notebook.add(category_frame, text=category)
menu_var_lists[category] = []

for i, (item_name, price) in enumerate(items):


item_label = ttk.Label(category_frame,
text=f"{item_name} - ₹{price}")
item_label.grid(row=i, column=0, padx=10,
pady=5, sticky=tk.W)

item_count_var = tk.IntVar()
item_count_spinbox = ttk.Spinbox(
category_frame, from_=0, to=10, width=5,
textvariable=item_count_var, command=calculate_subtotal
)
item_count_spinbox.grid(row=i, column=1,
padx=10, pady=5)

menu_var_lists[category].append(((item_name,
price), item_count_var))

subtotal_label = ttk.Label(menu_window,
text="Subtotal:")
subtotal_label.grid(row=4, column=0, padx=10,
pady=10, sticky=tk.E)

subtotal_value = ttk.Label(menu_window,
textvariable=subtotal_var, font=("Helvetica", 12, "bold"))
subtotal_value.grid(row=4, column=1, padx=10,
pady=10, sticky=tk.W)

confirm_button = ttk.Button(menu_window,
text="Confirm Order", command=confirm_order)
confirm_button.grid(row=5, column=0, columnspan=2,
pady=20)

if __name__ == "__main__":
welcome_window = WelcomeWindow()
welcome_window.mainloop()
OUTPUT
Conclusion
The Food Ordering and Management System offers a streamlined and
efficient solution for modern-day order management challenges. By
leveraging Python's Tkinter for an intuitive user interface and MySQL for
robust database integration, the project successfully automates and
simplifies key aspects of order processing and tracking.

Key accomplishments of the project include:

● Simplified Order Placement: Users can select items, view


subtotals in real-time, and confirm orders effortlessly.
● Database Management: Secure storage of user credentials and
order history ensures consistency and reliability.
● Dynamic User Experience: A user-friendly interface caters to both
new and returning customers.
● Future-Proof Design: The system is extensible to support
advanced features and wider applications.

This project exemplifies the power of Python for crafting practical,


real-world applications that emphasize simplicity without compromising
functionality. It replaces traditional, manual processes with an
automated, cutting-edge system that improves productivity and
enhances the user experience.

Future enhancements include integration with payment gateways, data


export options (e.g., Excel), and real-time notifications to further elevate
the application’s capabilities and reach. By embracing these
advancements, the system aims to set new standards for order
management solutions.
BIBLIOGRAPHY

● BOOK
○ Sumita Arora, Informatics Practices, Class 12th

● Websites
○ Tkinter Basics & Understanding
■ (43) Bro Code - YouTube

○ -Python & MySQL


Python MySQL

○ -Python Tkinter Documentation


■ Python Tkinter - GeeksforGeeks

You might also like