SOURCE CODE
import os
import platform
import [Link]
import datetime
mydb = [Link](
host="localhost",
user="root",
passwd="nara1913",
database="fashion"
mycursor = [Link]()
def AddProduct():
L = []
stk = []
pid = input("Enter the Product ID : ")
[Link](pid)
lName = input("Enter the Product Name : ")
[Link](lName)
brnd = input("Enter the Product Brand Name : ")
[Link](brnd)
fr = input("Enter Male/Female/Kids : ")
[Link](fr)
sn = input("Enter Winter/Summer : ")
[Link](sn)
rate = int(input("Enter the Rates for Product :"))
[Link](rate)
product = tuple(L)
sql = "Insert into product (product_id,PName,brand,Product_for,Season,rate)
values(%s,%s,%s,%s,%s,%s)"
[Link](sql, product)
[Link]()
[Link](pid)
[Link](0)
[Link]("No")
st = tuple(stk)
sql = "insert into stock(item_id,Instock,status) values(%s,%s,%s)"
[Link](sql, st)
[Link]()
print("One Product inserted ")
def EditProduct():
pid = input("Enter product ID to be edited : ")
sql = "select * from product where product_id=%s"
ed = (pid,)
[Link](sql, ed)
res = [Link]()
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 : ")
sql = "Update product set " + fld + "=%s where product_id=%s"
[Link](sql, (val, pid))
[Link]()
print("Editing Done : ")
print("After correction the record is : ")
[Link]("select * from product where product_id=%s", ed)
for x in [Link]():
print(x)
def DelProduct():
pid = input("Enter the Product ID to be deleted : ")
id = (pid,)
for table in ["sales", "purchase", "stock", "product"]:
if table == "product":
sql = "delete from product where product_id=%s"
else:
sql = f"delete from {table} where item_id=%s"
[Link](sql, id)
[Link]()
print("One Item Deleted")
def ViewProduct():
print("Display Menu: Select the category to display the data")
print("1. All Details")
print("2. Product Name:")
print("3. Product Brand:")
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"
[Link](sql)
for x in [Link]():
print(x)
x=1
elif ch == 2:
var = 'PName'
val = input("Enter the name of Product : ")
elif ch == 3:
var = 'brand'
val = input("Enter the name of Brand : ")
elif ch == 4:
var = 'Product_for'
val = input("Enter Male/Female/Kids : ")
elif ch == 5:
var = 'season'
val = input("Enter the Season : ")
elif ch == 6:
var = 'product_id'
val = input("Enter the Product ID : ")
if x == 0:
sql = "select * from product where " + var + "=%s"
[Link](sql, (val,))
for x in [Link]():
print(x)
def PurchaseProduct():
now = [Link]()
purchaseID = "P" + str([Link]) + str([Link]) + str([Link]) + str([Link]) +
str([Link]) + str([Link])
L = []
Lst = []
[Link](purchaseID)
itemId = input("Enter Product ID : ")
[Link](itemId)
itemNo = int(input("Enter the number of Items : "))
[Link](itemNo)
sql = "select rate from product where product_id=%s"
[Link](sql, (itemId,))
res = [Link]()
rate = res[0]
print("rate is :", rate)
amount = rate * itemNo
print("Amount is :", amount)
[Link](amount)
dt = [Link]("%Y-%m-%d")
[Link](dt)
[Link]("insert into
purchase(purchase_id,item_id,no_of_items,amount,Purchase_date) values(%s,%s,%s,%s,%s)",
tuple(L))
[Link]()
[Link]("Select Instock from stock where item_id=%s", (itemId,))
res = [Link]()
instock = res[0] + itemNo
status = "Yes" if instock > 0 else "No"
[Link]("update stock set instock=%s,status=%s where item_id=%s", (instock,
status, itemId))
[Link]()
print("1 Item purchased and saved in Database")
def ViewPurchase():
item = input("Enter Product Name : ")
sql = "select
product.product_id,[Link],[Link],purchase.no_of_items,purchase.purchase_
date,[Link] from product INNER JOIN purchase ON
product.product_id=purchase.item_id and [Link]=%s"
[Link](sql, (item,))
for x in [Link]():
print(x)
def ViewStock():
item = input("Enter Product Name : ")
sql = "select product.product_id,[Link],[Link],[Link] from stock,
product where product.product_id=stock.item_id and [Link]=%s"
[Link](sql, (item,))
for x in [Link]():
print(x)
def SaleProduct():
now = [Link]()
saleID = "S" + str([Link]) + str([Link]) + str([Link]) + str([Link]) +
str([Link]) + str([Link])
L = []
[Link](saleID)
itemId = input("Enter Product ID : ")
[Link](itemId)
itemNo = int(input("Enter the number of Items : "))
[Link](itemNo)
[Link]("select rate from product where product_id=%s", (itemId,))
res = [Link]()
rate = res[0]
print("The rate of item is :", rate)
dis = int(input("Enter the discount : "))
saleRate = rate - (rate * dis / 100)
[Link](saleRate)
amount = itemNo * saleRate
[Link](amount)
dt = [Link]("%Y-%m-%d")
[Link](dt)
sql = "insert into sales (sale_id, item_id,no_of_item_sold,sale_rate,amount,date_of_sale)
values(%s,%s,%s,%s,%s,%s)"
[Link](sql, tuple(L))
[Link]()
[Link]("Select Instock from stock where item_id=%s", (itemId,))
res = [Link]()
instock = res[0] - itemNo
status = "Yes" if instock > 0 else "No"
print("Remaining Items in Stock are :", instock)
[Link]("update stock set instock=%s,status=%s where item_id=%s", (instock,
status, itemId))
[Link]()
def ViewSales():
item = input("Enter Product Name : ")
sql = "select product.product_id, [Link], [Link], sales.no_of_item_sold,
sales.date_of_sale, [Link] from sales, product where product.product_id=sales.item_id
and [Link]=%s"
[Link](sql, (item,))
for x in [Link]():
print(x)
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")
try:
userInput = int(input("Please Select An Above Option: "))
except ValueError:
exit("\nHy! That's Not A Number")
print("\n")
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...")
print("*" * 80)
print("******* Welcome to the Project of Fashion Store *********")
print("*" * 80)
print("")
MenuSet()
def runAgain():
runAgn = input("\nWant To Run Again Y/n: ")
while [Link]() == 'y':
if [Link]() == "Windows":
[Link]('cls')
else:
[Link]('clear')
MenuSet()
runAgn = input("\nWant To Run Again Y/n: ")
runAgain()