Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit 043f3bf

Browse files
committed
Added Inventory Management System Using Mysql
1 parent 693f04d commit 043f3bf

2 files changed

Lines changed: 117 additions & 0 deletions

File tree

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import tkinter
2+
import mysql.connector as q
3+
con=q.connect(host="localhost", user="root", passwd="", database="records")
4+
cursor=con.cursor()
5+
6+
#Adding record to an empty table(inventory)
7+
8+
def ADD():
9+
pid=int(input("Enter the product id:"))
10+
pname=input("Enter the product name: ")
11+
pcost=int(input("Enter the product cost:"))
12+
pqty=int(input("Enter the product quantity:"))
13+
query="insert into inventory values({},'{}',{},{})".format(pid,pname,pcost,pqty)
14+
cursor.execute(query)
15+
con.commit()
16+
print("Data Inserted successfully")
17+
18+
#Displaying record in List form
19+
20+
def Display():
21+
cursor.execute("select * from inventory")
22+
record=cursor.fetchall()
23+
print("ID"," ","Name"," ","Cost","","Quantity")
24+
for i in record:
25+
print(i)
26+
print("Total Number of record=",cursor.rowcount)
27+
28+
#Searching product on the basis of product code
29+
30+
def Search():
31+
val=int(input("Enter the product code to search:"))
32+
flag=0
33+
cursor.execute("select * from inventory")
34+
record=cursor.fetchall()
35+
for i in record:
36+
if i[0]==val:
37+
flag=1
38+
print("ID"," ","Name"," ","Cost","","Quantity")
39+
print(i)
40+
if flag==0:
41+
print("---Record not found---")
42+
43+
# Updating existing record on the basis of product ID
44+
45+
def Update():
46+
code=int(input("Enter the product id to update:"))
47+
pid=int(input("Enter product id:"))
48+
pname=input("Enter product name:")
49+
pcost=int(input("Enter the product cost:"))
50+
pqty=int(input("Enter the product quantity:"))
51+
query="update inventory set PID={},PNAME='{}',PCOST={},PQTY={} where PID={}".format(pid,pname,pcost,pqty,code)
52+
cursor.execute(query)
53+
con.commit()
54+
print("Data Updated SuccessfullY")
55+
56+
# Deleting records
57+
58+
def Delete():
59+
val=int(input("Enter product ID whose records are to be deleted:"))
60+
query="delete from inventory where PID={}".format(val)
61+
cursor.execute(query)
62+
con.commit()
63+
if cursor.rowcount>0:
64+
print("Record Successfully Deleted")
65+
else:
66+
print("Product not found")
67+
68+
def check():
69+
if e1.get()=="Admin" and e2.get()=="1234":
70+
win=tkinter.Tk()
71+
win.title("Inventory")
72+
win.configure(bg="SteelBlue1")
73+
win.geometry('500x400')
74+
login.destroy()
75+
l=tkinter.Label(win,text='Welcome to Super Market',font=('Arial',18,'bold'),bg="SteelBlue1",fg="Black")
76+
l.pack(side="top")
77+
search=tkinter.Button(win,text="Search",font=('Arial',10,'bold'),command=Search,bg="azure")
78+
add=tkinter.Button(win,text=' Add ',font=('Arial',10,'bold'),command=ADD,bg="azure")
79+
update=tkinter.Button(win,text="Update",font=('Arial',10,'bold'),command=Update,bg='azure')
80+
display=tkinter.Button(win,text="Display",font=('Arial',10,'bold'),command=Display,bg="azure")
81+
delete=tkinter.Button(win,text=" Delete ",font=('Arial',10,'bold'),command=Delete,bg="azure")
82+
e=tkinter.Button(win,text=' Exit ',font=('Arial',10,'bold'),command=win.destroy,bg="azure")
83+
add.place(x=90,y=100)
84+
display.place(x=90,y=200)
85+
search.place(x=300,y=100)
86+
update.place(x=195,y=150)
87+
delete.place(x=300,y=200)
88+
e.place(x=200,y=250)
89+
win.mainloop()
90+
91+
92+
else:
93+
l1=tkinter.Label(login,text="Login Unsuccessful!!",font=("Arial",10,"bold"),fg="black",bg="light salmon")
94+
l1.place(x=110,y=170)
95+
96+
97+
login=tkinter.Tk()
98+
login.geometry("400x220")
99+
login.configure(bg="light salmon")
100+
login.title("Authorised Login Only")
101+
o=tkinter.Label(login,text='Login',font=('Arial',18,'bold'),bg='light salmon',fg="black")
102+
o.pack(side='top')
103+
104+
l1=tkinter.Label(login,text="Username",font=("Arial",10,'bold'),bg="white")
105+
l1.place(x=10,y=50)
106+
e1=tkinter.Entry(login,width=25,font=("Arial",10,'bold'))
107+
e1.place(x=150,y=50)
108+
l2=tkinter.Label(login,text= "Password",font=("Arial",10,'bold'),bg="white")
109+
l2.place(x=10,y=80)
110+
e2=tkinter.Entry(login,width=25,font=(10),show="*")
111+
e2.place(x=150,y=80)
112+
q=tkinter.Button(login,text="Submit",font=("Arial",10,"bold"),command=check)
113+
q.place(x=225,y=120)
114+
z=tkinter.Button(login,text="EXIT",font=("Arial",10,"bold"),command=login.destroy)
115+
z.place(x=125,y=120)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mysqlconnector.connect
2+
tkinter

0 commit comments

Comments
 (0)