Python Code
Python Code
import os
import platform
import mysql.connector
import pandas as pd
import datetime
def AddProduct():
L = []
stock = []
pid = input(“Enter the product ID: ”)
L.append(pid)
Name = input(“Enter the product name: ”)
L.append(Name)
Brand = input(“Enter the product’s brand name: ”)
L.append(Brand)
for = input(“Enter for Men/Women/Kids: ”)
L.append(for)
Season = input(“Enter the season (winter/summer): “)
L.append(season)
rate = int(input(“Enter the rates for products: ”))
L.append(rate)
product = (L)
sql = “Insert into product(pid, Name, Brand, for, season, rate)
tinga.commit()
stock.append(pid)
stock.append(0)
stock.append(“No”)
st = (stock)
def EditProduct():
for x in res:
print(x)
print(“”)
sq = sql
cursor.execute(sql)
print(“Editing done.”)
print(“After correction, the record is: “)
sql = “select * from where product_id = %s”
ed = (pid,)
cursor.execute(sql, ed)
res = cursor.fetchall()
for x in res:
print(x)
tinga.commit()
def DelProduct():
cursor.execute(sql,id)
tinga.commit()
x=0
ch = int(input("Enter your choice to display : "))
if ch==1:
sql = "select * from product"
cursor.execute(sql)
res=cursor.fetchall()
for x in res:
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"
sq=sql
tp = (val,)
cursor.execute(sq,tp)
res =cursor.fetchall()
for x in res:
print(x)
def PurchaseProduct():
mn = ""
dy = ""
now=datetime.datetime.now()
purchaseID="P" + str(now.year) + str(now.month) + str(now.day)+
str(now.hour) + str(now.minute) + str(now.second)
L = []
Lst = []
L.append(purchaseID)
for x in res:
print("rate is : ", x)
amount = x*itemNo
print("Amount is : ", amount)
L.append(amount)
month = now.month
if month<=9:
mn = "0" + str(month)
else:
mn = str(month)
day = now.day
if day <= 9:
dy = "0" + str(day)
else:
dy = str(day)
dt = str(now.year) + "-" + mn + "-" + dy
L.append(dt)
tp=(L)
cursor.execute(sql,tp)
tinga.commit()
for x in res:
print(x)
instock=x[0]+itemNo
if instock>0:
status="Yes"
Lst.append(instock)
Lst.append(status)
Lst.append(itemId)
tp=(Lst)
def ViewPurchase():
item = input("Enter Product Name : ")
purchase.no_of_items, purchase.purchase_date,
purchase.amount from product INNER JOIN purchase ON
itm = (item,)
cursor.execute(sql,itm)
res = cursor.fetchall()
for x in res:
print(x)
def ViewStock():
item=input("Enter Product Name : ")
sql="select product.product_id, product.PName, stock.Instock,\
stock.status from stock, product where\
product.product_id=stock.item_id and product.PName=%s "
itm = (item,)
cursor.execute(sql,itm)
res = cursor.fetchall()
for x in res:
print(x)
def SaleProduct():
now=datetime.datetime.now()
for x in res:
print("The rate of item is: ",x)
dis = int(input("Enter the discount: "))
saleRate = x[0] - (x[0]*dis/100)
L.append(saleRate)
amount = itemNo*saleRate
L.append(amount)
mnth = now.month
if mnth<=9:
mn = "0" + str(mnth)
else:
mn = str(mnth)
day = now.day
if day<=9:
dy = "0" + str(day)
else:
dy = str(day)
cursor.execute(sql,tp)
tinga.commit()
for x in res:
print("Total Items in Stock are : ",x)
def ViewSales():
item = input("Enter Product Name : ")
sql = "select product.product_id, product.PName,product.brand,\
sales.no_of_item_sold,sales.date_of_sale,sales.amount \
from sales, product where product.product_id=sales.item_id \
and product.PName=%s"
itm=(item,)
cursor.execute(sql,itm)
res=cursor.fetchall()
for x in res:
print(x)
print("*"*80)
print("* * * * * * * Welcome to the Central Fashion Store * * * * * * * ")
print("* * * * Created By: Saaim Hayat : * * * * ")
print("*"*80)
print("")
MenuSet()
def runAgain():
runAgn = input("\nwant To Run Again Y/n: ")
while(runAgn.lower() == 'y'):
if(platform.system() == "Windows"):
print(os.system('cls'))
else:
print(os.system('clear'))
MenuSet()
runAgn = input("\nwant To Run Again Y/n: ")
runAgain()+