Adobe Scan 11 Nov 2024
Adobe Scan 11 Nov 2024
import os
import platform
import mysql.connector
Import pandas as pd
Import datetime
def AddProduct():
L=()
stk=[)
pld=lnput("Enter the Product ID:")
L.append(pld)
IName=lnput("Enter the Product Name : ")
L.append(IName)
brnd=input("Enter the Product Brand Name : ")
L.append(brnd)
fr=input("Enter Male/Female/Kids:")
L.append(fr)
sn=input("Enter Winter/Summer:")
L.append(sn)
rate=lnt(lnput("Enter the Rates for Product :"))
L.append(rate)
product=(L)
sql="lnsert Into product
(product_id,PName,brand,Product_for,Season,rate)values(%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,product)
mydb.commit()
stk.append(pid)
stk.append(0)
stk.append("No")
st=(stk)
sql="lnsert Into stock(ltem_ld, lnstock, status) values(%s,%s,%s)"
mycursor.execute(sql,st)
mydb.commit()
print("One Product inserted ")
def EditProduct():
pid=input("Enter product ID to be edited: ")
sql="select • from product where product_id=%s"
ed=(pid,)
mycursor.execute(sql,ed)
res=mycursor.fetchall()
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 +"="'+val+ "' where product_id="' + pid + "'"
sq=sql
mycursor.execute(sqi)
print("Editing Don : ")
print("After correction the record is: ")
sql="select • from product where product_id=%s"
ed=(pid,)
mycursor.execute(sql,ed)
res=mycursor.fetchall()
for x in res:
print(x)
mydb.commit()
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 product_id=%s"
mycursor.execute(sql,id)
mydb.commit()
print("One Item Deleted")
def ViewProduct():
print("Display Menu: Select the category to display the data")
print("l. All Details")
print("2. Product Name:")
print("3. Product Brand:")
print("4. Product For:")
print("S. Product Season:")
print("6. Product ID:")
x=O
ch=int(input("Enter your choice to display: "))
if ch==l:
sql="select • from product"
mycursor.execute(sqi)
res=mycursor.fetchall()
for x in res:
print(x)
x=l
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= 1Product_for1
val=input("Enter Male/Femal/Kids : ")
elif ch==S:
var='season'
def PurchaseProduct():
11
mn= "
dy=""
now=datetlme.datetime.now()
purchaselD="P"+str(now.year)+str(now.month)+str(now.day)+str(now.hour)+str(now.minute)+str(n
ow.second)
L=(]
Lst=(]
L.append(purchaselD)
itemld=input("Enter Product ID : ")
L.append(itemld)
itemNo=int(input("Enter the number of Items:"))
L.append(itemNo)
sql="select rate from product where product_ld=%s"
pid=(itemld,)
mycursor.execute(sql,pid)
res=mycursor.fetchone()
for x in res:
print("rate is:", x)
amount=x•itemNo
print("Amount is:", amount}
L.append(amount)
mnth=now.month
if mnth<=9:
mn="O"+str(mnth)
else:
mn=str(mnth)
day=now.day
if day<=9:
dy="O"+str(day)
else:
dy=str(day)
dt=str( now.year)+"-"+mn+"-"+dy
L.append(dt)
tp=(L)
sql="lnsert Into
purchase( purchase_id,ltem_id,no_ of_ltems,a mount,Purchase_date)values(%s,%s,%s,%s,
%s)"
mycu rsor .execute(sql,tp)
mydb.commit()
sql="Select lnstock from stock where item_id=%s"
mycursor.execute(sql,pid)
res=mycursor.fetchall()
status="No"
for x in res:
print(x)
instock=x(OJ+itemNo
if instock>O:
status="Yes"
Lst.append(instock)
Lst.append(status)
Lst.append(itemld)
tp=(Lst)
sql="update stock set lnstock=%s,status=%s where item_id=%s"
mycursor.execute(sql,tp)
mydb.commit()
print("l Item purchased and saved in Database")
def ViewPurchase():
item=input("Enter Product Name: ")
sql="select product.product_ld,
product.PName,product.brand,purchase.no_of_items,purchase.purchase_date,purchase.am
ount from product INNER JOIN purchase ON product.product_ld=purchase.ltem_id and
product.PName=%s"
itm=(item,)
mycursor.execute(sql,itm)
res=mycursor.fetchall()
for x in res:
prlnt(x)
def ViewStock():
item=input("Enter Product Name: ")
sql="select product.product_id,product.PName,stock.lnstock,\
stock.status from stock, product where\
product.product_id=stock.item_id and product.PName=%s"
itm=(item,)
mycursor.execute(sql,itm)
res=mycursor.fetchall()
for x in res:
print(x)
def SaleProduct():
now•datetime.datetime.now()
salelD•"S''+str(now.year)+str(now.month)+str(now.day)+str(now.hour)+str(now.minute)+str(now.se
cond)
l•[)
L.append(salelD)
ltemld•lnput("Enter Product ID:")
L.append(ltemld)
itemNo•int(input("Enter the number of Items : "))
L.append(itemNo)
sql•"select rate from product where product_id•%s"
pid•(itemld,)
mycursor.execute(sql,pid)
res•mycursor.fetchall()
for x In res:
prlnt("The rate of item is :",x)
dis•int(lnput("Enter the discount : "))
saleRate=x[O)•(x[O]•dis/100)
L.append(saleRate)
amount•itemNo•saleRate
L.append(amount)
mnth•now.month
If mnth<•9:
mn="O"+str(mnth)
else:
mn•str(mnth)
day=now.day
if day<•9:
dy•"O"+str(day)
else:
dy=str(day)
dt=str( now.year)+"•"+mn+"•"+dy
L.append(dt)
tp=(L)
sql="lnsert into sales (sale_ld, ltem_ld,no_of_item_sold,\
sale_rate,amount,date_of_sale) values(%s,%s,%s,%s,%s,%s)"
mycursor.execute(sql,tp)
mydb.commit()
sql="Select lnstock from stock where ltem_id=%s"
mycursor.execute(sql,pld)
res=mycursor.fetchall()
for x In res:
print("Total Items in Stock are : ",x)
instock=x[O]•itemNo
if instock>O:
status•"Yes"
tp=(instock,status,itemld)
sql="update stock set instock=%s,status=%s where item_id=%s"
print("Remaining Items in Stock are: ",instock)
mycursor.execute(sql,tp)
mydb.commit()
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,)
mycursor.execute(sql,itm)
res=mycursor.fetchall()
for x in res:
print(x)
MenuSet()
def runAgain():
runAgn = input("\nwant To Run Again Y/n: ")
whlle(runAgn.lower() == 'y'):
if(platform.system() == "Windows"):
prlnt(os.system('cls'))
else:
prlnt(os.system('clear'))
MenuSet()
runAgn = input("\nwant To Run Again Y/n: ")
runAgaln()
• • • • • • • Welcome lo th• Project of F'ashion Store • • • • • • •
Add product:
Edit product:
Enter 1 TO Add Product
Enter 2 To Edit Product
Enter 3 To Delete Product
Enter 4 To View Product
Enter 5 To Purcha~e Product
Enter 6 To view Purchases
Enter 7 To View Stock Dotiuls
Enter 8 To sale the Jtem
Enter 9 : To View Sales Detials
Please Select An Above Option: 2
Delete product:
Enter 1 To Add Product
Enter 2 TO Edit Product
Enter 3 TO Delete Product
Enter 4 TO view Product
Enter 5 To Purcha3e Product
Enter 6 TO View Purcha.ses
Enter 7 TO View stock Detial,s
Enter 8 TO sale the item
Enter 9 To View Sales Detials
Please Select An Above Option: 3
View product:
Purchase product:
Enter 1 To Add Product
Enter 2 To Edit Product
Enter 3 To Delete Product
Enter 4 TO View Product
Enter 5 TO Purcha:,e Product
Enter 6 To View Purcha:se!S
Enter 7 TO View Stock Detial:,
Enter 8 To sal.e the item
Enter 9 To View Sale:, Detial:,
Pl.ea:,e sel.ect An Above Option: 5
View purchase:
Enter 1 To Add Product
Enter 2 TO Edit Product
Enter 3 TO Delete Product
Enter 4 TO view Product
Enter 5 TO Purchase Product
Enter 6 TO View Purchases
Enter 7 To view Stock Detials
Enter 8 To Sale the item
Enter 9 To View Sale!! Detial!!
Please Select An Above Option: 6
Sale Item:
Enter 1 To Add Product
Enter 2 To Edit Product
Enter 3 To Delete Product
Enter 4 TO View Product
Enter 5 To Purchase Product
Enter 6 To View Purchases
Enter 7 TO View stock Detials
Enter 8 To Sale the item
Enter 9 TO View Sales Detials
Please Select An Above Option: 8