-
Notifications
You must be signed in to change notification settings - Fork 0
/
inventory management system.py
131 lines (124 loc) · 4.35 KB
/
inventory management system.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
def addrec():
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root", passwd="kushi1012", database="inventorymanage")
c=db.cursor()
name=input("Enter item name: ")
p=input("Enter mrp of item: ")
id1=input("Enter item id: ")
lrd=input("Enter item last restocking date: yyyy-mm-dd:")
q=input("Enter quantity of item as per last restocking date: ")
str1="("+id1+","+"'"+name+"'"+","+p+","+q+","+"'"+lrd+"'"+");"
c.execute("insert into item values"+str1)
db.commit()
print ("Record added")
def updaterec():
print(" ")
print("ID**********NAME**********PRICE**********QUANTITY**********LASTDATE_OF_RESTOCKING**********")
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root", passwd="jungcock", database="inventorymanage")
c=db.cursor()
c.execute("Select * from item;")
rows=c.fetchall()
for i in rows:
for m in i:
print(m,end='**********')
print ()
print (" ")
toedit=input("Enter item ID of record to edit: ")
print ("a-to edit name")
print ("b-to edit price")
print ("c-to edit item id")
print ("d-to edit last restocking date")
print ("e-to edit stock quantity")
z=input("Enter a-e: ")
if z=='a':
n=input("enter new name:")
str1=("update item set Name='"+n+"' where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
elif z=='b':
n=input("enter new price:")
str1=("update item set Product_price="+n+"where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
elif z=='c':
n=input("enter new ID:")
str1=("update item set ID="+n+"where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
elif z=='d':
n=input("enter new last restocking date (yyyy-mm-dd):")
str1=("update item set Last_restocking_date='"+n+"' where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
elif z=='e':
n=input("enter new quantity:")
str1=("update item set Quantity="+n+"where ID="+toedit+";")
c.execute(str1)
print ("Record updated")
db.commit()
def delrec():
print(" ")
print("ID**********NAME**********PRICE**********QUANTITY**********LASTDATE_OF_RESTOCKING**********")
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root", passwd="kushi1012", database="inventorymanage")
c=db.cursor()
c.execute("Select * from item;")
rows=c.fetchall()
for i in rows:
for m in i:
print(m,end='**********')
print ()
print(" ")
todel=input("Enter item ID of record to delete: ")
str1=("delete from item where ID="+todel+";")
c.execute(str1)
print ("Record deleted")
db.commit()
def showallrecs():
print(" ")
print("ID**********NAME**********PRICE**********QUANTITY**********LASTDATE_OF_RESTOCKING**********")
import mysql.connector
db=mysql.connector.connect(host="localhost", user="root", passwd="kushi1012", database="inventorymanage")
c=db.cursor()
c.execute("Select * from item;")
rows=c.fetchall()
for i in rows:
for m in i:
print(m,end='**********')
print ()
print(" ")
choice=1
while choice!=0:
print ("************************************")
print ("1-Add an item")
print ("2-Remove an item")
print ("3-Edit specefics of an item")
print ("4-Show all items")
print ("5-Help: See all commands again")
print ("0-Quit")
print ("************************************")
choice=int(input("Enter your choice: "))
if choice==1:
addrec()
elif choice==2:
delrec()
elif choice==3:
updaterec()
elif choice==4:
showallrecs()
elif choice==5:
while choice!=0:
print ("1-Add an item")
print ("2-Remove an item")
print ("3-Edit specefics of an item")
print ("4-Show all items")
print ("5-Help: See all commands again")
print ("0-Quit")
choice=int(input("Enter your choice: "))
elif choice==0:
choice=0