0% found this document useful (0 votes)
17 views18 pages

Item Module

Uploaded by

dassneha064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views18 pages

Item Module

Uploaded by

dassneha064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

ITEM MODULE

import pandas as pd
from tabulate import tabulate
import mysql.connector as sqlt
import matplotlib.pyplot as plt
con=sqlt.connect(host = "localhost", user = "root",
passwd="sanjay", database ="inventory")
cursor=con.cursor()
def add_item():
try:
ino = int(input("Enter Item No"))
iname = input("Enter Iname")
prate=float(input("Enter Purchase Rate"))
srate=float(input("enter Sale Rate"))
qoh=int(input("Enter Qty On Hand"))
q="insert into item,
values({},'{}',{},{},{});".format(ino,iname,srate,qoh)
cursor.execute(q)
con.commit()
print("Item Added")
except:
print("Wrong Entry..Please check")
def edit_item():
try:
ino=int(input("Enter Item No"))
q="select * from item where ino = {};".format(ino)
cursor.execute(q)
if cursor.fetchone():
iname=input("Enter Item Name")
cursor.execute("update item set iname = '{}'
where ino={};".format(iname,ino))
con.commit()
print("item Edited")
else:
print("Item Not Found")
except:
print("Wrong Entry")
def fix_rate():
ino=int(input("Enter Item No"))
q="select * from item where ino = {};".format(ino)
cursor.execute(q)
if cursor.fetchone():
prate=int(input("enter new purchase rate"))
srate=int(input("Enter new Sale rate"))
cursor.execute("update item set prate={},srate={}
whereino={};".format(prate,srate,ino))
con.commit()
print("New rate applied")
else:
print("Item Not Found")
def search_item():
ino=int(input("Enter Item No"))
q="select * from item where ino = {};".format(ino)
cursor.execute(q)
if cursor.fetchone():

df=pd.read_sql(q,con)print(tabulate(df,headers="ke
ys", tablefmt = "psql", showindex = False))

else:
print("Item Not Found")
def delete_item():
ino=int(input("Enter Item No"))
q="select * from item where ino = {};".format(ino)
cursor.execute(q)
if cursor.fetchone():
cursor.execute("delete from item where
ino={};".format(ino))
con.commit()
print("item deleted")
else:
print("Item Not Found"
CUSTOMER MODULE
import pandas as pd
from tabulate import tabulate
import mysql.connector as sqlt
import matplotlib.pyplot as plt
con=sqlt.connect(host = "localhost", user =
"root", passwd="sanjay", database
= "inventory")cursor=con.cursor()
def add_customer():
cid = int(input("Enter Customer ID"))
cname = input("Enter Customer Name")
cadd=input("Enter Address")mobile=input("Enter
Mobile")
q="insert
into customer values({},'{}','{}','{}');".format(
cid,cname,cadd,mobile)
cursor.execute(q)
con.commit()
print("Customer Added")
def edit_customer():
cid=int(input("Enter Customer ID"))
q="select * from Customer where cid
= {};".format(cid)
cursor.execute(q)
if cursor.fetchone():
cadd=input("Enter Customer Address")
cursor.execute("update customer set cadd = '{}'
where cid={};".format(cadd,cid))
con.commit()
print("Customer Edited")
else:
print("Customer Not Found")
def search_customer():
cname=input("Enter Customer Name")q="select *
from customer where cname like
'%{}%';".format(cname)cursor.execute(q)if cursor.fe
tchall():
df=pd.read_sql(q,con)
print(tabulate(df,headers='keys',tablefmt='psql',sho
windex=False))
else:
print("Customer Not found")
def delete_customer(): cid=int(input("Enter
Customer ID"))
q="select * from customer where cid
= {};".format(cid)
cursor.execute(q)
if cursor.fetchone():
cursor.execute("delete from customer where
cid={};".format(cid))con.commit()print("customer de
leted")
else:
print("customer Not Found")
CUSTOMER MODULE
import pandas as pd
from tabulate import tabulate
import mysql.connector as sqlt
import matplotlib.pyplot as plt
con=sqlt.connect(host = "localhost", user = "root",
passwd="sanjay", database = "inventory")
cursor=con.cursor()
def add_supplier():
sid = int(input("Enter Supplier ID"))
sname = input("Enter Supplier Name")
sadd=input("Enter Address")mobile=input("Enter
Mobile")
q="insert
into supplier values({},'{}','{}','{}');".format(sid,sname,
sadd,mobile)
cursor.execute(q)
con.commit()
print("Supplier Added")
def edit_supplier():
sid=int(input("Enter Supplier ID"))
q="select * from Supplier where sid
= {};".format(sid)
cursor.execute(q)
if cursor.fetchone():
sadd=input("Enter Supplier Address")
cursor.execute("update Supplier set sadd =
'{}' where sid={};".format(sadd,sid))
con.commit()print("Supplier Edited")
else:
print("Supplier Not Found")
def search_supplier():
sid=int(input("Enter Supplier ID"))
q="select * from Supplier where sid =
{};".format(sid)
cursor.execute(q)
if cursor.fetchone():
df=pd.read_sql(q,con)
print(tabulate(df,headers="keys", tablefmt
= "psql", showindex = False))
else:
print("Supplier Not Found")
def delete_supplier():
sid=int(input("Enter Supplier ID"))q="select * from
Supplier where sid = {};".format(sid)
cursor.execute(q)
if cursor.fetchone():
cursor.execute("delete from Supplier where
sid={};".format(sid))
con.commit()print("Supplier deleted")
else:
print("Supplier Not Found")
import pandas as pd
from tabulate import tabulate
import mysql.connector as sqlt
import matplotlib.pyplot as plt
con=sqlt.connect(host = "localhost", user = "root",
passwd="sanjay", database ="inventory")
cursor=con.cursor()
defpurchase():
pid=0
total=0
grand=0
l=[]
ch='y
'q="select max(pid) as largest from pmaster"
cursor.execute(q)
r=cursor.fetchone()[0]
if r:
pid=r+1
else:
pid=1
pdate=input("Enter Purchase date")
sid = int(input("Enter Supplier ID"))
cursor.execute("select * from supplier where
sid={};".format(sid))
if cursor.fetchone():
print("Item Details")
df=pd.read_sql("select * from

item",con)print(tabulate(df,headers='keys',tablefmt
='psql',showindex=False))

while(ch=='y'):
ino=int(input("Enter Item No"))
cursor.execute("select * from item where ino
={};".format(ino))
r1=cursor.fetchone()
if r1:
qty = int(input("Enter qty"))
rate=r1[2]
total=qty*rate
grand=grand+total
t=(pid,ino,qty,rate,total)
l.append(t)
else:
print("Item Not Found")
ch=input("Do you wish to add more Items in
bucket y/n")
q1="insert into pmaster
values({},'{}',{},{});".format(pid,pdate,sid,grand)
cursor.execute(q1)
con.commit()
q2="insert into pdetail
values(%s,%s,%s,%s,%s);"
cursor.executemany(q2,l)
con.commit()
cursor.executemany("insert into ptemp
values(%s,%s,%s,%s,%s);",l)
con.commit()q3="update item join ptemp
using(ino) set item.qoh = item.qoh+ptemp.qty"
cursor.execute(q3)
con.commit()
cursor.execute("delete from ptemp")
con.commit()
print("Item Purchased and Added")
else:
print("Supplier Not Found")
def sale():
saleid=0
total=0
grand=0
l=[]
ch='y'
q="select max(saleid) as largest from smaster"
cursor.execute(q)
r=cursor.fetchone()[0]
if r:
saleid=r+1
else:
saleid=1
sdate=input("Enter Sale date")
sid = int(input("Enter Supplier ID"))
cursor.execute("select * from supplier
where sid={};".format(sid))
if cursor.fetchone():
print("Item Details")
df=pd.read_sql("select * from item",con)
print(tabulate(df,headers='keys',tablefmt='psql',sho
windex=False))
while(ch=='y'):
ino=int(input("Enter Item No"))
cursor.execute("select * from item where ino
={};".format(ino))
r1=cursor.fetchone()
if r1:
qty = int(input("Enter qty"))
rate=r1[2]
total=qty*rate
grand=grand+total
t=(saleid,ino,qty,rate,total)
l.append(t)
else:
print("Item Not Found")
ch=input("Do you wish to add more Items in bucket
y/n")
q1="insert into smaster
values({},'{}',{},{});".format(saleid,sdate,sid,grand)
cursor.execute(q1)
con.commit()
q2="insert into sdetail values(%s,%s,%s,%s,%s);"
cursor.executemany(q2,l)
con.commit()
cursor.executemany("insert into stemp
values(%s,%s,%s,%s,%s);",l)
con.commit()
q3="update item join stemp using(ino) set item.qoh
= item.qoh-stemp.qty"
cursor.execute(q3)
con.commit()
cursor.execute("delete from stemp")
con.commit()
print("Item Purchased and Added")
else:
print("Supplier Not Found")
REPORT MODULE
import mysql.connector as sqlt
import pandas as pd
from tabulate import tabulate
con = sqlt.connect(host = "localhost", user = "root",
passwd = "sanjay", database ="library")
cursor = con.cursor()
def show_item():
df=pd.read_sql("select * from item",con)
print(tabulate(df,headers= 'keys',
tablefmt='psql',showindex = False))
def show_customer():
df=pd.read_sql("select * from customer",con)
print(tabulate(df,headers= 'keys',
tablefmt='psql',showindex = False))
def show_supplier():
df=pd.read_sql("select * from supplier",con)
print(tabulate(df,headers= 'keys',
tablefmt='psql',showindex = False))
def show_sale():
bdate=input("enter beginning date")
edate=input("enter end date")
df=pd.read_sql("select * from smaster where sdate
between '{}' and'{}';".format(bdate,edate),con)
print(tabulate(df,headers= 'keys',
tablefmt='psql',showindex = False))
def show_purchase():
bdate=input("enter beginning date")
edate=input("enter end date")
df=pd.read_sql("select * from pmaster where pdate
between '{}' and'{}';".format(bdate,edate),con)
print(tabulate(df,headers= 'keys',
tablefmt='psql',showindex = False))
def best_product():
s=input("Enter Start date")
e=input("Enter End Date")
q="select s2.ino,sum(s2.qty) as total from smaster
s1,sdetail s2 \where s1.saleid = s2.saleid and
s1.sdate between '{}' and '{}'\group by
s2.ino;".format(s,e)df=pd.read_sql(q,con)print(tabul
ate(df, headers='keys', tablefmt = 'psql',
showindex=False))

You might also like