Fashion Store
Management
Computer Science
investigatory Project
2024-25
done by : Haya Muhammed
Class : X11 -A
PCMC
register no:
This is to certify the bonafide record of the Project Work in Computer Science done
by Mr/Miss Haya Muhammed Kabeer with Register No: of the
CBSE Grade XII with the title Fashion Store Management for the academic year
2024-2025
Contents
1. Acknowledgment
2. Introduction
3. Flowchart
4. Source Code
5. Output
6. Bibliography
Acknowledgment
I would like to express my sincere gratitude to
everyone who supported me throughout this
project. First and foremost, I am deeply
grateful to my teacher, Mrs Anjula Sharma,
for her invaluable guidance, encouragement,
and patience. Her insights and expertise have
been instrumental in helping me understand
complex concepts and complete this project
successfully.
I would also like to thank my school and its
wonderful staff and faculty, who provided me
with a nurturing and inspiring environment
that fostered my curiosity and growth. My
heartfelt thanks to my classmates, family,
and friends for their encouragement and
motivation, which helped me stay focused
and driven throughout this journey.
Thank you all for your support and belief in
my abilities.
Introduction
This project is a Fashion Store Management System
developed using Python and MySQL connectivity. The
system allows users to efficiently add, update, delete, and
display information related to products in the store. It is
designed to streamline the management of fashion
inventory, making it easier for store owners to keep track
of their products. By utilizing Python for the application
logic and MySQL for database management, the system
ensures smooth and reliable data handling, helping store
managers improve operational efficiency and make
informed decisions. This project is useful for automating
routine tasks, reducing manual errors, and providing a
user-friendly interface for managing store data.
By leveraging Python for application logic and MySQL for
secure and reliable database management, the system
ensures smooth data handling and quick access to
information. Additionally, it supports real-time updates,
making it easy to monitor changes in inventory and sales.
This project is useful for small and medium-sized fashion
stores, allowing them to manage their operations more
effectively, improve customer satisfaction, and make
informed decisions based on up-to-date product data.
FLOWCHART
Start
display main menu
(1-9)
User input
(Enter Option
“Is the input a
valid number?”
select action (1-9)
YeYess No
Yes
Process user Show error message
selection “That’s not a number”
Option 1 add_product()
Option 2 edit_product()
Option 3 delete_product()
Option 4 view_products()
Option 5 purchase_product()
Option 6 view_purchase()
Option 7 view_stock()
Option 8 sale_product()
Option 9 view_sales()
“Run again?
(Yes/No)”
Yes No
Connector
“Run Again?
(Yes/No)”
END
PYTHON CODE
import os
import platform
import mysql.connector
# Database connection setup
mydb = mysql.connector.connect(
host="localhost",
user="haya",
passwd="1234",
database="fashion",
auth_plugin='mysql_native_password'
mycursor = mydb.cursor()
def clear_screen():
"""Clear the console screen based on the operating system."""
os.system('cls' if platform.system() == "Windows" else 'clear')
def execute_query(query, params=None):
"""Utility function to execute a SQL query."""
try:
if params:
mycursor.execute(query, params)
else:
mycursor.execute(query)
mydb.commit()
except mysql.connector.Error as e:
print(f"Error: {e}")
def add_product():
# Implementation of adding a product
product_details = [
input("Enter the Product Name: "),
input("Enter the Product Brand Name: "),
input("Enter Male/Female/Kids: "),
input("Enter Winter/Summer: "),
float(input("Enter the price for Product: "))
sql = "INSERT INTO product (name, brand, Product_for, Season, price)
VALUES (%s, %s, %s, %s, %s)"
execute_query(sql, tuple(product_details))
print("Product added successfully.")
def edit_product():
# Implementation of editing a product
product_id = input("Enter the Product ID to edit: ")
new_price = float(input("Enter the new price: "))
sql = "UPDATE product SET price = %s WHERE id = %s"
execute_query(sql, (new_price, product_id))
print("Product updated successfully.")
def delete_product():
# Implementation of deleting a product
product_id = input("Enter the Product ID to delete: ")
sql = "DELETE FROM product WHERE id = %s"
execute_query(sql, (product_id,))
print("Product deleted successfully.")
def view_products():
# Implementation of viewing products
mycursor.execute("SELECT * FROM product")
for row in mycursor.fetchall():
print(row)
def MenuSet():
# Your menu code here
print("Menu options go here.")
def main():
# Welcome message
print("*" * 80)
print("* * * * * * * Welcome to the Project of Fashion Store * * * * * * * ")
print("* * * * Developed by: Haya Muhammed, Alpine public school,
banglore * * * * ")
print("*" * 80)
print("")
# Call the menu function
MenuSet()
if __name__ == "__main__":
main()
def ViewProduct():
print("Display Menu: Select the category to display the data")
print("1. All Details")
print("2. Product Name:")
print("3. Product description:")
print("4. Product For:")
print("5. Product Season:")
print("6. Product ID:")
x=0
ch=int(input("Enter your choice to display : "))
if ch==1:
sql="select * from product"
mycursor.execute(sql)
res=mycursor.fetchall()
for x in res:
print(x)
x=1
elif ch==2:
var='name'
val=input("Enter the name of Product : ")
elif ch==3:
var='description'
val=input("Enter the name of description : ")
elif ch==4:
var='Product_for'
val=input("Enter Male/Femal/Kids : ")
elif ch==5:
var='season'
val=input("Enter the Season : ")
elif ch==6:
var='id'
val=input("Enter the id : ")
if x==0:
sql="select * from product where " + var + " = %s"
sq=sql
tp=(val,)
mycursor.execute(sq,tp)
res=mycursor.fetchall()
for x in res:
print(x)
ViewProduct()
def EditProduct():
try:
pid = input("Enter product ID to be edited: ")
sql = "SELECT * FROM product WHERE id = %s"
mycursor.execute(sql, (pid,))
res = mycursor.fetchall()
if not res:
print("No product found with that ID.")
return
for x in res:
print(x)
print("")
fld = input("Enter the field which you want to edit: ")
val = input("Enter the value you want to set: ")
# Update product
sql = f"UPDATE product SET {fld} = %s WHERE id = %s"
mycursor.execute(sql, (val, pid))
mydb.commit()
print("Editing done:")
# Fetch and display the updated product
sql = "SELECT * FROM product WHERE id = %s" # Correct SQL statement to
fetch updated record
mycursor.execute(sql, (pid,))
res = mycursor.fetchall() # Fetch the updated record
if res: # Check if the result is not empty
for x in res:
print(x)
else:
print("No updated product found with that ID.")
except Exception as e:
print(f"An error occurred: {e}")
def DelProduct():
pid=input("Enter the Product)id to be deleted : ")
sql="delete from sales where item_id=%s"
id=(pid,)
mycursor.execute(sql,id)
mydb.commit()
sql="delete from purchase where item_id=%s"
mycursor.execute(sql,id)
mydb.commit()
sql="delete from stock where item_id=%s"
mycursor.execute(sql,id)
mydb.commit()
sql="delete from product where id=%s"
mycursor.execute(sql,id)
mydb.commit()
print("One Item Deleted")
def PurchaseProduct():
# Initialize variables
now = datetime.datetime.now()
# Geneprice a unique purchase ID
purchaseID = "P" + str(now.year) + str(now.month).zfill(2) +
str(now.day).zfill(2) + \
str(now.hour).zfill(2) + str(now.minute).zfill(2) +
str(now.second).zfill(2)
# Create lists to hold purchase details
purchase_details = [purchaseID]
# Get product ID from user
itemId = input("Enter Product ID: ")
purchase_details.append(itemId)
# Get number of items from user
itemNo = int(input("Enter the number of Items: "))
purchase_details.append(itemNo)
# Fetch the product price from the database
sql = "SELECT price FROM product WHERE id=%s"
pid = (itemId,)
mycursor.execute(sql, pid)
res = mycursor.fetchone()
if res is None:
print("Product not found.")
return # Exit if product does not exist
price = res[0]
print("price is: ", price)
# Calculate total amount
amount = price * itemNo
print("Amount is: ", amount)
purchase_details.append(amount)
# Format the purchase date
dt = now.strftime("%Y-%m-%d")
purchase_details.append(dt)
# Insert purchase details into the database
sql = "INSERT INTO purchase(purchase_id, item_id, no_of_items, amount,
Purchase_date) VALUES (%s, %s, %s, %s, %s)"
mycursor.execute(sql, tuple(purchase_details))
mydb.commit()
# Check current stock and update it
sql = "SELECT Instock FROM stock WHERE item_id=%s"
mycursor.execute(sql, pid)
stock_res = mycursor.fetchone()
if stock_res is None:
print("Stock information not found for the given item ID.")
return # Exit if stock information does not exist
instock = stock_res[0]
instock_after_purchase = instock - itemNo # Update stock after purchase
# Determine stock status
if instock_after_purchase >= 0:
status = "Yes"
# Update stock in the database
sql = "UPDATE stock SET instock=%s, status=%s WHERE item_id=%s"
mycursor.execute(sql, (instock_after_purchase, status, itemId))
mydb.commit()
print("Items purchased and saved in Database")
else:
print("Not enough stock available. Purchase cannot be completed.")
def ViewPurchase():
sql = """
SELECT product.id, product.name, product.description,
purchase.no_of_items, purchase.Purchase_date, purchase.amount
FROM product
INNER JOIN purchase ON product.id = purchase.item_id
WHERE product.name = %s
"""
itm=(iter,)
mycursor.execute(sql,itm)
res=mycursor.fetchall()
for x in res:
print(x)
def ViewStock():
item=input("Enter Product Name : ")
sql="select product.id,product.name,stock.Instock,\
stock.status from stock, product where \
product.id=stock.item_id and product.name=%s"
itm=(item,)
mycursor.execute(sql,itm)
res=mycursor.fetchall()
for x in res:
print(x)
def SaleProduct():
now = datetime.datetime.now()
saleID = "S" + str(now.year) + str(now.month).zfill(2) + str(now.day).zfill(2) +
\
str(now.hour).zfill(2) + str(now.minute).zfill(2) +
str(now.second).zfill(2)
L = []
L.append(saleID)
itemId = input("Enter Product ID: ")
L.append(itemId)
itemNo = int(input("Enter the number of Items: "))
L.append(itemNo)
sql = "SELECT price FROM product WHERE id=%s"
pid = (itemId,)
mycursor.execute(sql, pid)
res = mycursor.fetchall()
if not res: # Check if the result is empty
print("The product with the given ID does not exist.")
return # Exit the function if no product is found
# If the product exists, assign the price
x = res[0] # Get the first result
print("The price of the item is:", x[0])
dis = int(input("Enter the discount: "))
saleprice = x[0] - (x[0] * dis / 100)
L.append(saleprice)
amount = itemNo * saleprice
L.append(amount)
dt = now.strftime("%Y-%m-%d")
L.append(dt)
tp = tuple(L)
sql = "INSERT INTO sales (sale_id, item_id, no_of_item_sold, sale_price,
amount, date_of_sale) VALUES (%s, %s, %s, %s, %s, %s)"
mycursor.execute(sql, tp)
mydb.commit()
sql = "SELECT Instock FROM stock WHERE item_id=%s"
mycursor.execute(sql, pid)
stock_res = mycursor.fetchall()
if not stock_res: # Check if the stock information is available
print("Stock information not found for the given item ID.")
return # Exit if stock information does not exist
for x in stock_res:
print("Total Items in Stock are:", x)
instock = x[0] - itemNo
if instock >= 0:
status = "Yes"
tp = (instock, status, itemId)
sql = "UPDATE stock SET instock=%s, status=%s WHERE item_id=%s"
mycursor.execute(sql, tp)
mydb.commit()
print("Sale completed successfully.")
else:
print("Not enough stock available. Sale cannot be completed.")
def ViewSales():
item=input("Enter Product Name : ")
sql="select product.id, product.name,product.description,\
sales.no_of_item_sold,sales.date_of_sale,sales.amount \
from sales, product where product.id=sales.item_id \
and product.name=%s"
itm=(item,)
mycursor.execute(sql,itm)
res=mycursor.fetchall()
for x in res:
print(x)
try: #Using Exceptions For Validation
userInput = int(input("Please Select An Above Option: ")) #Will Take Input
From User
except ValueError:
exit("\nHy! That's Not A Number") #Error Message
else:
print("\n") #Print New Line
if(userInput == 1):
AddProduct()
elif(userInput == 2):
EditProduct()
elif (userInput==3):
DelProduct()
elif (userInput==4):
ViewProduct()
elif (userInput==5):
PurchaseProduct()
elif (userInput==6):
ViewPurchase()
elif (userInput==7):
ViewStock()
elif (userInput==8):
SaleProduct()
elif (userInput==9):
ViewSales()
else:
print("Enter correct choice. . . ")
def clear_screen():
"""Clear the console screen based on the operating system."""
if platform.system() == "Windows":
os.system('cls') # For Windows
else:
os.system('clear') # For Unix/Linux/Mac
def MenuSet():
print("Enter 1 : To Add Product ")
print("Enter 2 : To Edit Product ")
print("Enter 3 : To Delete Product ")
print("Enter 4 : To View Product ")
print("Enter 5 : To Purchase Product")
print("Enter 6 : To View Purchases")
print("Enter 7 : To View Stock Details")
print("Enter 8 : To Sale the item")
print("Enter 9 : To View Sales Details")
def runAgain():
while True:
clear_screen() # Clear the screen before showing the menu
MenuSet() # Show the menu
try:
userInput = int(input("Please Select An Above Option: ")) # Take input
from user
except ValueError:
print("\nHy! That's Not A Number") # Error message
continue # Skip to the next iteration to allow retry
print("\n") # Print new line
if userInput == 1:
add_product()
elif userInput == 2:
edit_product()
elif userInput == 3:
delete_product()
elif userInput == 4:
view_products()
elif userInput == 5:
purchase_product()
elif userInput == 6:
view_purchase()
elif userInput == 7:
view_stock()
elif userInput == 8:
sale_product()
elif userInput == 9:
view_sales()
else:
print("Enter correct choice. . . ")
runAgn = input("\nWant To Run Again Y/n: ")
if runAgn.lower() != 'y':
break # Exit the loop if the user does not want to run again
if __name__ == "__main__":
main() # Start the main program flow
runAgain() # Start the loop for running again
def runAgain():
while True:
runAgn = input("\nWant To Run Again Y/n: ")
if runAgn.lower() == 'y':
clear_screen() # Clear the screen before showing the menu again
MenuSet() # Show the menu again
# You can also call the function that processes the user's choice here
else:
break # Exit the loop if the user does not want to run again
runAgain()
clear_screen()
Connectivity code
import os
import platform
import mysql.connector
# Database connection setup
mydb = mysql.connector.connect(
host="localhost",
user="haya",
passwd="1234",
database="fashion",
auth_plugin='mysql_native_password'
mycursor = mydb.cursor()
SQL DATABASE AND TABLES
Database:
Tables:
TABLE DESCRIPTION:
OUTPUT FOR PYTHON
SQL DATABASE OUTPUT
BIBLIOGRAPHY
for completing the project I have taken help from the following
websites and books:
1. hhtps://stackoverflow.com/
2. https://github.com/
3. sumita arora
THANK YOU