0% found this document useful (0 votes)
20 views34 pages

Python Dbms Report

Uploaded by

karthika20805
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)
20 views34 pages

Python Dbms Report

Uploaded by

karthika20805
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/ 34

GROCERY STORE MANAGEMENT

SYSEM
MINI PROJECT REPORT

Submitted by

GOBIKA M 9517202309034
KARTHIKA S 9517202309051

in

23AD381-PYTHON PROGRAMMING LABORATORY


AND
23AD352-DATABASE MANAGEMENT SYSTEM DESIGN
LABORATORY

DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

MEPCO SCHLENK ENGINEERING COLLEGE


SIVAKASI
NOVEMBER 2024
MEPCO SCHLENK ENGINEERING COLLEGE,
SIVAKASI
AUTONOMOUS
DEPARTMENT OF ARTIFICIAL INTELLIGENCE AND DATA SCIENCE

BONAFIDE CERTIFICATE

This is to certify that it is the bonafide work of, “GOBIKA M(9517202309034),


KARTHIKA S(9517202309051)” for the mini project titled “GROCERY STORE
MANAGEMENT SYSTEM” in 23AD281-Python Programming Laboratory and
23AD352-Database Management System Design Laboratory during the third semester
July 2024 –December 2024 under my supervision.

SIGNATURE SIGNATURE

DR. P.Thendral, B.E,M.E,PhD Dr.J.Angela Jennifa


Sujana,B.E,M.Tech,PhD
Associate professor Professor & Head,
AI&DS Department, AI&DS Department

Mepco Schlenk Engg. College, Mepco Schlenk Engg. College,

Sivakasi Sivakasi
ACKNOWLEDGEMENT

I would like to express my sincere gratitude to all those who have


contributed to the successful completion of this project report on the
development of our fastest delivery system.

First and foremost, we praise and thank “The Almighty”, the lord of all
creations, who by his abundant grace has sustained us and helped us to work on
this project successfully.

I sincerely thank our respected principal Dr.S.Arivazhagan, for providing


necessary facilities to carry out this work successfully.

I wish to express my sincere gratitude to Dr.J.Angela Jennifa


Sujana,B.E,M.Tech,PhD Professor and Head of the Artificial Intelligence &
Data Science department for her stimulating support and encouragement for the
completion of this project work.

I am grateful to our Project guides Dr.P.Manoj Kumar


B.Tech,M.E,PhD AP(Sr. Grade) and Mrs. D.Monica Seles B.Tech,M.Tech
Assistant Professor (Sr.Grade)

With deep sense of gratitude, I would like to thank our Head of the
Artificial Intelligence & Data Science department for her insightful comments
and valuable suggestions which helped me to complete this project work
successfully.

My sincere thanks to our revered faculty members and lab technicians


for their help over this project work.

Last but not the least, I extend my indebtedness towards my beloved


family and friends for their support which made this project a successful one.
ABSTRACT

The Grocery Store Management System serves as a comprehensive solution for grocery store
owners and customers, integrating various aspects of retail operations into a unified platform.
Developed using Python, the system leverages Tkinter for the graphical user interface (GUI) and
SQLite as a lightweight yet efficient database for storing and managing store data. The primary goal
of the system is to simplify day-to-day operations in grocery stores, improving efficiency and
enhancing customer experience.

This system provides an easy-to-use interface for both customers and store managers. For customers,
the application allows them to browse available items, add products to their shopping cart, specify
quantities in different units (e.g., kilograms, liters, pieces), and calculate the total price based on
selected items. The checkout process is seamless, allowing for the generation of a final bill and
facilitating the payment process. Upon successful payment, the system records the transaction in the
purchase history, which customers can review at any time.

For store owners, the system provides key functionalities to manage the store's inventory, including
adding new items, updating prices, and tracking stock levels. The system’s database ensures that
every transaction, whether it is a purchase or a stock update, is accurately recorded, helping owners
maintain real-time visibility into their store's operations.

The database design includes three primary tables: groceries, which stores product information;
purchases, which stores customer cart data before payment; and purchase_history, which stores
completed transactions. This database structure ensures smooth tracking of products, quantities,
prices, and customer information.

In addition to core functionalities, the system enables users to search for products, view a list of
available items, and filter the products by name. The application also provides a secure and efficient
mechanism for storing and retrieving transaction records, with detailed information on previous
purchases, including item names, quantities, units, prices, and the date of purchase. Future
improvements also include the potential for integrating online payment systems and expanding the
database to support multi-store operations.
TABLE OF CONTENTS
CHAPTER NO TITLE PAGE NO.
ABSTRACT 4

1 INTRODUCTION 7

1.1 Overview 7

1.2 Aim 7

1.3 Objective 7

1.4 Scope of the Project 8

2 PROJECT DESCRIPTION 9

2.1 Tools and Technologies Used 10

2.2 Modules Used 10

2.3 Use Cases 11

3 SYSTEM ARCHIETECTURE 12

3,1 Database Setup 13

3.2 Frontend Design 15

4 SYSTEM FUNCTIONALITY 17

5 SOURCE CODE 18

6 RESULTS 27

7 CONCLUSION 32

REFERENCES 33
LIST OF FIGURES

F.NO TITLE PAGE NO


6.1 Welcome Page 27
6.2 Customer Name Entry Page 27
Item name from the drop
6.3 28
down menu
Units of measurement from
6.4 28
the drop down menu
6.5 Messagebox after adding the 28
item to the cart
6.6 Viewing the cart items 29

6.7 Checkout Button 30

6.8 Message Box Displaying the 30


Total Bill

6.9 Message Box Displaying the 30


message Payment Successful

6.10 View Purchase History 31


Button
Purchase History of the
6.11 31
Customers
CHAPTER 1

INTRODUCTION
1.1.OVERVIEW

The Grocery Store Management System is a Python-based application designed to streamline


grocery store operations, including inventory management, customer purchases, and transaction tracking.
It allows store owners to add, update, and manage grocery items, while customers can browse, select, and
purchase products with ease. The system uses an SQLite database to store and manage data, ensuring
accurate stock and purchase records. It provides a user-friendly interface for both customers and store
owners. The system can be expanded with features like sales reports, stock alerts, and online payment
integration.

The aim and objectives of the project, "SMART GROCERY STORE


MANAGEMENT SYSTEM" can be summarized as follows:

1.2.AIM :

The aim of this project is to develop a Grocery Store Management System that automates
the management of inventory, customer purchases, and sales transactions. The system will streamline store
operations by efficiently tracking stock, processing purchases, and providing a user-friendly interface for
both customers and store owners. It aims to enhance business efficiency and improve the overall shopping
experience.

1.3.OBJECTIVE :

The objectives of the Grocery Store Management System are to automate inventory tracking,
facilitate customer purchases, and streamline sales transactions. It aims to provide a user-friendly interface
for customers and enable store owners to manage stock levels, update prices, and view purchase histories.
The system ensures real-time updates, improving overall store efficiency and enhancing the shopping
experience.

8
1.4.SCOPE OF THE PROJECT:

The Grocery Store Management System aims to streamline and optimize various aspects of grocery
store operations by providing an integrated platform for inventory management, purchase processing, and
transaction tracking. The scope of this project is designed to address both the operational needs of the store
and the user experience of customers.

1. Inventory Management: The system provides an organized way to manage the store’s inventory.
It allows for easy addition, update, and deletion of grocery items. Store managers can monitor
stock levels, prices, and product details, ensuring that the store is always well-stocked and offering
accurate pricing.
2. Customer Purchase Management: The system supports the entire purchasing process, from
browsing items to completing a transaction. Customers can view available items, add them to their
cart, and proceed to checkout. The application calculates the total cost of the purchase, ensuring the
pricing is accurate based on the quantity and type of items purchased.
3. Sales and Purchase History Tracking: Each purchase is recorded with details such as item
names, quantities, prices, and dates. This purchase history can be used for analysis and reporting
purposes, enabling store managers to track sales trends, identify popular products, and manage
customer relationships. Customers also benefit from having a record of their past transactions for
reference.
4. Real-time Data Updates: As purchases are made, the system updates the inventory and
transaction records in real time. This ensures that the data remains current, and the system always
reflects the latest stock levels and sales data.
5. User-friendly Interface: The project features an intuitive graphical user interface (GUI) built with
Tkinter. Customers and store managers can interact with the system easily, without requiring
technical expertise. The interface is designed to be simple, with clear navigation paths for
inventory management, checkout, and purchase history viewing.
6. Scalability and Future Enhancements: The system is designed with scalability in mind, allowing
for future updates and enhancements. Potential future improvements include:
o User authentication: Adding roles such as Admin and Cashier, each with different access
levels.
o Stock Management: Implementing automatic stock updates and low-stock alerts.
o Sales Reporting: Generating reports based on dates, product categories, or customer data.
o Online Payment Integration: Enabling secure online payments for customers through
integrated payment gateways.

9
CHAPTER 2

PROJECT DESCRIPTION

The Grocery Store Management System is a comprehensive software application developed


to simplify the operational tasks of grocery stores. The primary goal of this system is to streamline various
functions, including managing inventory, processing customer purchases, and maintaining detailed
transaction histories. This project offers a robust and user-friendly solution that allows grocery store
managers to handle the daily store operations more efficiently while providing customers with a seamless
shopping experience. By utilizing a graphical user interface (GUI) and an efficient backend database, the
system automates manual tasks such as stock tracking, price calculation, and bill generation, enabling the
store to run smoothly and reduce human error.

The system's inventory management feature allows store managers to easily add, update, and
delete grocery items, along with their respective quantities and prices. It provides an organized database of
available products, ensuring that stock levels are accurately recorded. The customer purchase
management functionality enables customers to browse the store's inventory, select products, and specify
quantities. Once customers add items to their cart, the system calculates the total price, ensuring that all
costs are clearly displayed before checkout.

Upon checkout, the system generates an invoice with a detailed list of purchased items, along
with their prices and quantities. The purchase history feature records every completed transaction in a
database, allowing customers to access past purchases for future reference. Store managers also benefit
from this feature as it provides valuable insights into customer preferences and sales trends over time.

The user interface (UI) is designed using Tkinter, a Python library that ensures the system is
easy to use for individuals with minimal technical experience.. SQLite is used as the database
management system, which stores the product, purchase, and transaction data. It is a lightweight yet
effective database system that allows efficient data management while maintaining fast response times.

The Grocery Store Management System aims to improve the operational efficiency of grocery
stores, making it easier for store managers to manage inventory and track sales. Customers benefit from an
enhanced shopping experience with transparent pricing and access to their purchase history. The system’s
ability to automate common tasks reduces the administrative workload, improves accuracy, and helps
maintain up-to-date records.
10
2.1.TOOLS AND TECHNOLOGIES USED:

 Programming Language: Python is used for writing the core logic of the application.
 GUI Framework: Tkinter is utilized for creating the graphical user interface (GUI), enabling user
interaction with the system.
 Database: SQLite is used as the database management system to store information such as grocery
items, purchases, and transaction history.
 Database Management: SQL queries are employed to handle tasks like adding, updating, and
retrieving data from the database.
 Date and Time Management: The datetime module in Python is used to record and manage
transaction dates and times.

2.2.MODULES USED:

The following Python modules were used in the development of the Grocery Store Management
System:

Tkinter:

 Used for building the graphical user interface (GUI).


 Provides widgets like buttons, labels, entry fields, and tables for displaying information interactively.

SQLite3:

 Used to manage the local database for storing groceries, purchases, and purchase history.
 SQLite is a serverless, self-contained, and highly reliable database engine, suitable for small to medium-
sized projects.

datetime:

 Used for handling transaction timestamps, which helps in storing and managing the date and time of
each purchase.

os:

 Used for file management, ensuring that the database file is properly created, accessed, and updated.

11
2.3.USE CASES:
The Grocery Store Management System provides a range of functionalities that enhance the user
experience, from managing items in a shopping cart to viewing purchase history. Below are the use cases
that describe the operations in the system:

1. Start Shopping Session


The customer initiates a new shopping session by clicking the "Start Purchasing" button on the
welcome screen. This action starts the shopping process, allowing the customer to enter their name
for the session.
2. Enter Customer Name
The customer is prompted to enter their name to identify themselves during the shopping session.
Once entered, the system saves the name and transitions to the main shopping interface.
3. Search for Items
The customer can search for grocery items by typing keywords into a search bar. The system filters
and displays items that match the search term, making it easier for the customer to find products.
4. Add Items to Cart
The customer selects an item from the available list, specifies the quantity, and chooses the unit
(e.g., Kg, Litre). The system calculates the total price for the item and adds it to the shopping cart.
5. View Shopping Cart
The customer can view the contents of their shopping cart by clicking the "View Cart" button. The
system displays a list of all added items, including the item name, quantity, unit, and price.
6. Checkout and Payment
Once ready, the customer clicks the "Checkout" button to proceed to payment. The system
calculates the total bill and processes the payment, after which the purchased items are moved to
the purchase history.
7. View Purchase History
The customer can view their past purchases by clicking the "View Purchase History" button. The
system displays a detailed history of all previous purchases, including the item names, quantities,
units, prices, and purchase dates.

12
CHAPTER-3
SYSTEM ARCHITECTURE

The Grocery Store Management System is designed using a client-server architecture, which separates
the user interface from the backend database. This approach ensures a streamlined interaction between the
user and the system, while also efficiently managing data.
Components of the System:

 Frontend (User Interface):


o The user interface is built using Tkinter, which is a Python library for creating graphical user
interfaces (GUIs).
o The interface allows customers to:
 Enter their name for identification.
 Search for and select grocery items from a list.
 View their cart to see items added.
 Perform actions like adding items to the cart, checking out, and reviewing past purchases.
o It includes various buttons for actions such as adding items, viewing the cart, and completing the
purchase.
 Backend (Database):
o The backend is powered by an SQLite database, which stores all the essential data for the system.
o The database consists of three main tables:
 Groceries Table: Stores details about available products, such as name, quantity, and price.
 Purchases Table: Tracks the items currently in a customer's shopping cart, including the
customer's name, item details, and quantities.
 Purchase History Table: Logs all completed purchases for each customer, including
transaction details like the items bought, quantities, and prices.
o The SQL queries interact with the database to:
 Fetch available products.
 Update stock quantities.
 Record purchases and transaction histories.

This architecture allows the frontend (GUI) to communicate with the backend (database) through SQL
queries. The user interacts with the GUI, which sends requests to the database for operations like adding
items to the cart, viewing the cart, and processing payments. The separation of frontend and backend
ensures that the system is modular, efficient, and easy to maintain.
13
3.1 DATABASE SETUP:

The database setup is crucial to the functionality of the Grocery Store Management System. Below is a
detailed breakdown of how the database is structured and how the tables are created, modified, and
populated in the system:
1. Connecting to SQLite Database:
The first step in the database setup is establishing a connection to the SQLite database. If the database file
doesn't exist, SQLite automatically creates it.
conn = sqlite3.connect('store.db')
c = conn.cursor()
2. Creating the Tables:
The database consists of three main tables: groceries, purchases, and purchase_history. If
these tables don't already exist, they will be created.

 Groceries Table: This table stores details about the grocery items available for sale in the store.

CREATE TABLE IF NOT EXISTS groceries (


id INTEGER PRIMARY KEY,
name TEXT,
quantity INTEGER,
price REAL
)

 Purchases Table: This table stores information about the items a customer selects to purchase but
has not yet paid for.

CREATE TABLE IF NOT EXISTS purchases (


purchase_id INTEGER PRIMARY KEY,
customer_name TEXT,
item_name TEXT,
quantity INTEGER,
unit TEXT,
price REAL,
purchase_date TEXT
)

14
 Purchase History Table:This table keeps a record of completed transactions after the customer
has made the payment.

CREATE TABLE IF NOT EXISTS purchase_history (


history_id INTEGER PRIMARY KEY,
customer_name TEXT,
item_name TEXT,
quantity INTEGER,
unit TEXT,
price REAL,
purchase_date TEXT
)

3. Checking and Modifying Existing Tables:


Before creating the tables, the code checks whether specific columns (e.g., unit) exist in the purchases
and purchase_history tables. If they are missing, it alters the table to add the required column.
c.execute("PRAGMA table_info(purchases)")
columns = [column[1] for column in c.fetchall()]
if 'unit' not in columns:
c.execute('''ALTER TABLE purchases ADD COLUMN unit TEXT''')
This same check and modification process is done for the purchase_history table.

4. Committing Changes:
After making changes to the database (such as creating tables or altering them), the changes are committed
to ensure they are saved.
conn.commit()
This ensures that all database operations are finalized and persisted in the database.

5. Closing the Connection:


Once all database operations are complete, the connection to the database is closed to free up resources.
conn.close()

15
3.2.FRONTEND DESIGN:

The frontend of the Grocery Store Management System is built using Python's tkinter library, providing
an intuitive and user-friendly graphical user interface (GUI). The frontend includes several key
components, each aimed at enhancing the shopping experience. The application is organized into various
pages, each with specific functionality. Below is a detailed description of the different sections of the
frontend:
1. Welcome Page
The welcome page is the first screen that appears when the user opens the application. It serves as an
introduction to the system and gives the user an option to start the purchasing process. This page includes:

 Title: "Welcome to the Grocery Store," which serves as a greeting.


 Button: "Start Purchasing," which transitions the user to the next page where they can enter the customer’s
name.

2. Customer Name Input Page


The customer name input page appears once the user clicks on the "Start Purchasing" button. This page
prompts the user to enter their name, which will be used to track their shopping session and associate
purchases with a specific customer. The page includes:

 Label: "Enter Customer Name," guiding the user to input their name.
 Text Entry Field: Where the user can type their name.
 Confirm Button: When clicked, it saves the entered name and moves the user to the next page where they
can begin adding items to their cart.

3. Main Shopping Page


The main shopping page is where the user will select items from the grocery list, specify quantities, and
choose the unit of measurement (e.g., Kg, Piece, Litre). It allows users to:

 Item Selection: A dropdown menu displays available items that the user can select from.
 Quantity Input: A field where the user can enter the quantity of the selected item.
 Unit Selection: A dropdown menu to choose the unit (e.g., Kg, Litre, Piece).
 Buttons:
o Add to Cart: Adds the selected item and its quantity to the shopping cart.
o View Cart: Displays the current items in the cart.
o Checkout: Allows the user to proceed to payment.
16
4. Shopping Cart Display
The cart is displayed on the same page as the shopping area, showing the user the items they’ve added to
their cart. This section features:

 Table Format: The cart is displayed using a table-like structure with columns for the item name, quantity,
unit, and price.
 Real-Time Updates: As items are added to the cart, the table automatically updates to reflect the latest
selection.

5. Checkout and Payment


After adding items to the cart, the user can proceed to checkout. The checkout process includes:

 Display Total: The total price of all the items in the cart is calculated and shown.
 Payment Button: When clicked, it finalizes the purchase, moving the items from the cart to the purchase
history and clearing the cart.
 Confirmation Message: After payment, a message confirms the successful transaction and thanks the user
for their purchase.

6. Purchase History
The system allows users to view their past purchases. A separate window is available for the purchase
history, displaying:

 List of Past Purchases: Each entry includes the item name, quantity, unit, price, and the purchase date.
 Button: "View Purchase History" on the main page opens the history window.

Design Features

 Modern and Clean Interface: The overall interface has a light and clean aesthetic, using soft background
colors like light grey and green for a modern feel.
 Intuitive Navigation: Each page is logically arranged, allowing users to move smoothly from one section to
another.
 Responsive UI: The layout is designed to adjust well to different screen sizes, making the application
usable on various devices.

17
CHAPTER-4

SYSTEM FUNCTIONALITY
1. Database Initialization:
o The database is initialized using SQLite, and three tables are created: groceries, purchases, and
purchase_history.
o If the required columns (e.g., unit) are missing in existing tables, they are added dynamically.
2. Grocery Item Management:
o The system allows for adding items to the database (this can be done manually in the database or
extended with features to input items via the UI).
o The grocery list is fetched and displayed dynamically in a combo box for the user to select from.
3. Item Search:
o Customers can search for grocery items by name using the search feature, and the matching results
are displayed in a dropdown combo box.
4. Cart Management:
o Users can add items to their shopping cart by selecting the item, entering the quantity, and choosing
the unit (Kg, Litre, etc.).
o The item’s price is fetched from the database, and the total price is computed.
o The cart is displayed using a treeview, showing the items, their quantities, units, and the total price
for each.
5. Checkout and Payment:
o Once the user is ready to check out, they can view the total bill.
o After confirming the payment, the items are moved from the purchases table to the
purchase_history table, and the cart is cleared.

6. Purchase History:
o Users can view their past purchases in a separate window. The purchase history includes item
names, quantities, units, price, and purchase date.

7.GUI Features:

o Welcome Screen: A welcoming page with a button to start the purchasing process.
o Customer Input Screen: A screen to enter the customer’s name, which is required before
proceeding.
o Main Shopping Interface: Includes options to select items, add to cart, view cart, and checkout.
18
o Purchase History Window: A separate window showing the customer’s past purchases.

CHAPTER-5

SOURCE CODE
import sqlite3
import tkinter as tk
from tkinter import messagebox, ttk
from datetime import datetime

# Initialize the main application window


root = tk.Tk()
root.title("Grocery Store Management System")
root.geometry("1000x750")
root.configure(bg='#F1F1F1') # Lighter background for a modern look

# Connect to the database and create tables if not exists


def init_db():
conn = sqlite3.connect('store.db')
c = conn.cursor()

# Create the groceries table


c.execute('''CREATE TABLE IF NOT EXISTS groceries (
id INTEGER PRIMARY KEY,
name TEXT,
quantity INTEGER,
price REAL)''')

# Create the purchases table, making sure the 'unit' column exists
c.execute('''CREATE TABLE IF NOT EXISTS purchases (
purchase_id INTEGER PRIMARY KEY,
customer_name TEXT,
item_name TEXT,
quantity INTEGER,
19
unit TEXT,
price REAL,
purchase_date TEXT)''')

# Create the purchase_history table, making sure the 'unit' column


exists
c.execute('''CREATE TABLE IF NOT EXISTS purchase_history (
history_id INTEGER PRIMARY KEY,
customer_name TEXT,
item_name TEXT,
quantity INTEGER,
unit TEXT,
price REAL,
purchase_date TEXT)''')

# Check if the 'unit' column exists in the purchases table, if not,


alter the table
c.execute("PRAGMA table_info(purchases)")
columns = [column[1] for column in c.fetchall()]
if 'unit' not in columns:
c.execute('''ALTER TABLE purchases ADD COLUMN unit TEXT''')

# Check if the 'unit' column exists in the purchase_history table,


if not, alter the table
c.execute("PRAGMA table_info(purchase_history)")
columns = [column[1] for column in c.fetchall()]
if 'unit' not in columns:
c.execute('''ALTER TABLE purchase_history ADD COLUMN unit
TEXT''')

conn.commit()
conn.close()

# Fetch available items

20
def fetch_items():
conn = sqlite3.connect('store.db')
c = conn.cursor()
c.execute("SELECT name FROM groceries")
items = [item[0] for item in c.fetchall()]
conn.close()
return items

# Initialize the database


init_db() # Make sure the database is initialized before fetching
items

items = fetch_items() # Fetch items after initializing the database

# Function to add an item to the shopping cart


def add_item():
name = combo_name.get()
quantity = int(entry_quantity.get())
unit = combo_unit.get()
conn = sqlite3.connect('store.db')
c = conn.cursor()
c.execute("SELECT price FROM groceries WHERE name=?", (name,))
result = c.fetchone()
if result is None:
messagebox.showerror("Error", "Item not found in groceries!")
else:
price = result[0]
total_price = price * quantity
c.execute("INSERT INTO purchases (customer_name, item_name,
quantity, unit, price, purchase_date) VALUES (?, ?, ?, ?, ?, ?)",
(customer_name, name, quantity, unit, total_price,
datetime.now().strftime("%Y-%m-%d %H:%M:%S")))
conn.commit()
messagebox.showinfo("Success", f"{name} added to cart!")
21
view_cart()
conn.close()

# Function to view items in the shopping cart


def view_cart():
for row in tree.get_children():
tree.delete(row)
conn = sqlite3.connect('store.db')
c = conn.cursor()
c.execute("SELECT item_name, quantity, unit, price FROM purchases
WHERE customer_name=?", (customer_name,))
rows = c.fetchall()
for row in rows:
tree.insert("", "end", values=row)
conn.close()

# Function to display the total bill


def display_total():
conn = sqlite3.connect('store.db')
c = conn.cursor()
c.execute("SELECT SUM(price) FROM purchases WHERE customer_name=?",
(customer_name,))
total = c.fetchone()[0]
messagebox.showinfo("Total Bill", f"Total bill: {total} Rs")
conn.close()

# Function to handle payment


def payment():
display_total()
conn = sqlite3.connect('store.db')
c = conn.cursor()
c.execute("""INSERT INTO purchase_history (customer_name,
item_name, quantity, unit, price, purchase_date)

22
SELECT customer_name, item_name, quantity, unit,
price, purchase_date
FROM purchases
WHERE customer_name=?""", (customer_name,))
c.execute("DELETE FROM purchases WHERE customer_name=?",
(customer_name,))
conn.commit()
conn.close()
messagebox.showinfo("Success", "Payment successful! Thank you for
shopping.")
root.destroy()

# Customer name input before proceeding


def enter_customer_name():
global customer_name
customer_name = entry_customer_name.get()
if customer_name:
entry_customer_name.config(state='disabled')
button_confirm_customer.config(state='disabled')
frame_main.pack(pady=10)
else:
messagebox.showwarning("Input Error", "Please enter a customer
name.")

# Function to search for an item


def search_item():
search_term = entry_search.get().lower()
filtered_items = [item for item in items if search_term in
item.lower()]
combo_name['values'] = filtered_items

# Function to view purchase history


def view_purchase_history():
for row in tree_history.get_children():
23
tree_history.delete(row)
conn = sqlite3.connect('store.db')
c = conn.cursor()
c.execute("SELECT item_name, quantity, unit, price, purchase_date
FROM purchase_history WHERE customer_name=?", (customer_name,))
rows = c.fetchall()
for row in rows:
tree_history.insert("", "end", values=row)
conn.close()
history_window.deiconify() # Show the history window

# Welcome Page Frame


def show_welcome_page():
frame_welcome.pack(pady=100)

# Function to start purchasing


def start_purchasing():
frame_welcome.pack_forget() # Hide the welcome page
frame_customer.pack(pady=20) # Show the customer name input frame

# Setting up the welcome page


frame_welcome = tk.Frame(root, bg='#4CAF50') # Green background for
the welcome page
frame_welcome.pack(fill='both', expand=True)

welcome_label = tk.Label(frame_welcome, text="Welcome to the Grocery


Store", font=("Arial", 24, "bold"), fg="white", bg="#4CAF50")
welcome_label.pack(pady=50)

start_button = ttk.Button(frame_welcome, text="Start Purchasing",


command=start_purchasing, style='Accent.TButton')
start_button.pack(pady=20)

# Setting up the main frames for customer input and purchasing


24
frame_customer = tk.Frame(root, bg='#F1F1F1')
frame_customer.pack(pady=20)
frame_main = tk.Frame(root, bg='#F1F1F1')

# Customer name entry


ttk.Label(frame_customer, text="Enter Customer Name:",
background='#F1F1F1', foreground='#4CAF50').grid(row=0, column=0,
padx=10, pady=10)
entry_customer_name = ttk.Entry(frame_customer, font=('Arial', 12))
entry_customer_name.grid(row=0, column=1, padx=10, pady=10)
button_confirm_customer = ttk.Button(frame_customer, text="Confirm",
command=enter_customer_name, style='Accent.TButton')
button_confirm_customer.grid(row=0, column=2, padx=10, pady=10)

# Entry and label widgets for main operations


ttk.Label(frame_main, text="Item Name", background='#F1F1F1',
foreground='#4CAF50').grid(row=0, column=0, padx=10, pady=10)
ttk.Label(frame_main, text="Quantity", background='#F1F1F1',
foreground='#4CAF50').grid(row=0, column=1, padx=10, pady=10)
ttk.Label(frame_main, text="Unit", background='#F1F1F1',
foreground='#4CAF50').grid(row=0, column=2, padx=10, pady=10)

combo_name = ttk.Combobox(frame_main, values=items, font=('Arial', 12),


width=20, state="readonly")
combo_name.grid(row=1, column=0, padx=10, pady=10)

entry_quantity = ttk.Entry(frame_main, font=('Arial', 12))


entry_quantity.grid(row=1, column=1, padx=10, pady=10)

# Dropdown for Quantity Units


combo_unit = ttk.Combobox(frame_main, values=["Kg", "Litre", "Piece",
"Pack", "Dozen"], font=('Arial', 12), width=10, state="readonly")
combo_unit.grid(row=1, column=2, padx=10, pady=10)

25
# Buttons for Add to Cart, View Cart, and Payment
button_add_to_cart = ttk.Button(frame_main, text="Add to Cart",
command=add_item)
button_add_to_cart.grid(row=2, column=0, padx=10, pady=10)

button_view_cart = ttk.Button(frame_main, text="View Cart",


command=view_cart)
button_view_cart.grid(row=2, column=1, padx=10, pady=10)

button_checkout = ttk.Button(frame_main, text="Checkout",


command=payment)
button_checkout.grid(row=2, column=2, padx=10, pady=10)

# Treeview for Cart Display


tree = ttk.Treeview(frame_main, columns=("Item Name", "Quantity",
"Unit", "Price"), show="headings", height=5)
tree.heading("Item Name", text="Item Name")
tree.heading("Quantity", text="Quantity")
tree.heading("Unit", text="Unit")
tree.heading("Price", text="Price")
tree.column("Item Name", width=200)
tree.column("Quantity", width=100)
tree.column("Unit", width=100)
tree.column("Price", width=100)
tree.grid(row=3, column=0, columnspan=5, pady=20)

# Purchase History Window (Separate)


history_window = tk.Toplevel(root)
history_window.title("Purchase History")
history_window.geometry("800x400")
history_window.configure(bg='#F1F1F1')
history_window.withdraw()

26
tree_history = ttk.Treeview(history_window, columns=("Item Name",
"Quantity", "Unit", "Price", "Date"), show="headings", height=10)
tree_history.heading("Item Name", text="Item Name")
tree_history.heading("Quantity", text="Quantity")
tree_history.heading("Unit", text="Unit")
tree_history.heading("Price", text="Price")
tree_history.heading("Date", text="Purchase Date")
tree_history.column("Item Name", width=200)
tree_history.column("Quantity", width=100)
tree_history.column("Unit", width=100)
tree_history.column("Price", width=100)
tree_history.column("Date", width=150)
tree_history.pack(pady=20)

# Purchase History Button


button_view_history = ttk.Button(frame_main, text="View Purchase
History", command=view_purchase_history)
button_view_history.grid(row=4, column=0, padx=10, pady=10)

# Start the welcome page


show_welcome_page()

# Run the main application loop


root.mainloop

27
CHAPTER-6

RESULTS

Figure 6.1-Welcome Page

Figure 6.2-Customer Name Entry Page

28
Figure 6.3-Item name from the drop down menu

Figure 6.4-Units of measurement from the drop down menu

Figure6.5-Messagebox after adding the item to the cart

29
Figure 6.6-Viewing the cart items

30
Figure 6.7-Checkout Button

Figure 6.8-Message Box Displaying the Total Bill

Figure 6.9-Message Box Displaying the message Payment Successful


31
Figure 6.10-View Purchase History Button

Figure 6.11-Purchase History of the Customers

32
CHAPTER-7

CONCLUSION
The Grocery Store Management System is an efficient and user-friendly software solution aimed at
improving both the shopping experience for customers and the operational processes of grocery store
management. By utilizing Tkinter for the frontend and SQLite for the database backend, this system
provides a seamless interaction between the user interface and the storage of data. The core functionality
of the system includes features such as item search, shopping cart management, and the ability to view and
process customer purchase histories, all of which make grocery shopping more convenient and efficient.

One of the primary advantages of the system is its simplicity, allowing customers to quickly search for
products, add them to their cart, and proceed to checkout without any complicated procedures. The real-
time inventory tracking feature ensures that customers only see available items, which enhances the
shopping experience and reduces frustration. The purchase history functionality also benefits both the
customers and the store owners, providing customers with easy access to their previous transactions and
enabling store owners to monitor purchasing trends over time.

From an operational standpoint, the system reduces the reliance on paper-based records, making it easier
for store owners to track sales, manage inventories, and generate transaction histories. Furthermore, the
use of SQLite as the database allows for quick and reliable data storage, with the ability to easily add,
modify, and retrieve items, prices, and purchase records.

The Grocery Store Management System is designed with scalability in mind, and its modular nature
means that new features, such as discount management, loyalty programs, or even online shopping
capabilities, could be added as the business grows. Additionally, integrating real-time stock updates and
payment gateway solutions would enhance the system's capabilities and provide even more value to both
customers and store owners.

In conclusion, this project successfully integrates essential functionalities that cater to the needs of both
customers and store owners, making it an invaluable tool for grocery stores aiming to modernize their
operations. The system’s simplicity, combined with its potential for future enhancements, offers a solid
foundation for continuous improvement and long-term success.

33
REFERENCES:
1) https://docs.python.org/3/library/sqlite3.html
2) https://docs.python.org/3/library/tkinter.html
3) https://docs.python.org/3/library/tkinter.html
4) https://pythonprogramming.net/tkinter-python-3-tutorial/
5) https://www.pythontutorial.net/tkinter/tkinter-treeview/
6) https://docs.python.org/3/library/csv.html
7) https://github.com/search?q=tkinter

34

You might also like