-
Notifications
You must be signed in to change notification settings - Fork 0
/
schoolprojupdated_final1.py
441 lines (395 loc) · 16.4 KB
/
schoolprojupdated_final1.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
## Declaring functions
def inventory():
import mysql.connector as x
mycon=x.connect(host='localhost',user="root",passwd="Tanisha29@",database="abc")
if mycon.is_connected()==False:
print("Error connecting to mysql database")
while True:
print('''
Choose one of the following operation:
1.View all items
2.View items by stock
3.Add or delete items
4.Modify item
''')
ch=int(input("Enter your choice:"))
if ch==1:#view all items
cursor=mycon.cursor()
print("ITEM DETAILS")
print("Itemid, Name, Itemcateg, Stock, Lastupd, Expdate, CP, SP")
cursor.execute("Select * from inventory")
data=cursor.fetchall()
for row in data:
print(row)
ans=input("Do you want to continue?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif ch==2:#view items by stock
print('''
In which order?
1.ascending
2.descending''')
a=input("Enter option(asc/desc):")
if a=='asc':
cursor=mycon.cursor()
print("ITEM DETAILS IN ASC ORDER (BY STOCK)")
print("Itemid, Name, Stock")
cursor.execute("Select itemid, name, stock from inventory order by stock")
data=cursor.fetchall()
for row in data:
print(row)
ans=input("Do you want to continue?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif a=="desc":
cursor=mycon.cursor()
print("ITEM DETAILS IN DESC ORDER (BY STOCK)")
print("Itemid, Name, Itemcateg, Stock, Lastupd, Expdate, CP, SP")
cursor.execute("Select * from inventory order by stock desc")
data=cursor.fetchall()
for row in data:
print(row)
ans=input("Do you want to continue?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
else:
print("incorrect input")
ans=input("Do you want to try again?(yes/no):")
if ans=='yes':
continue
elif ans=='no':
print("Thank you for visiting")
break
elif ch==3:#add or delete items
print('''Do you want to :
1.add
2.delete''')
y=int(input("Enter choice:"))
print()
if y==1:
while True:
cursor=mycon.cursor()
itid=input("Enter itemid:")
itname=input("Enter item name:")
itcateg=input("Enter item category:")
itstock=input("Enter amount in stock")
itupd=input("Enter updating date")
itexp=input("Enter item expiry date:")
itcp=input("Enter item cost price:")
itsp=input("Enter item selling price:")
cursor.execute('''insert into inventory values('{}','{}','{}',{},'{}',
'{}',{},{})'''.format(itid,itname,itcateg,itstock,itupd,
itexp,itcp,itsp))
mycon.commit()
print("successfully added")
ans=input("Do you want to add more items?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==2:
while True:
cursor=mycon.cursor()
itid=input("Enter item id:")
cursor.execute("delete from inventory where itemid='{}'".format(itid))
mycon.commit()
print("deleted successfully")
ans=input("Do you want to delete another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
else:
print("invalid input")
elif ch==4:#modify item
itid=input("Enter item id:")
print('''What do you want to modify?-
1.name
2.category
3.amount in stock
4.updation date
5.expiry date
6.CP
7.SP''')
while True:
y=int(input("enter choice:"))
if y==1:
cursor=mycon.cursor()
new=input("Enter new name:")
cursor.execute('''Update inventory set name='{}'
where itemid='{}' '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==2:
cursor=mycon.cursor()
new=input("Enter new category:")
cursor.execute('''Update inventory set itemcateg='{}'
where itemid='{} '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==3:
cursor=mycon.cursor()
new=int(input("Enter new stock amount:"))
cursor.execute('''Update inventory set stock={}
where itemid='{}' '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==4:
cursor=mycon.cursor()
new=input("Enter new updation date:")
cursor.execute('''Update inventory set lastupd='{}'
where itemid='{}' '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==5:
cursor=mycon.cursor()
new=input("Enter new expiry date:")
cursor.execute('''Update inventory set expdate='{}'
where itemid='{}' '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==6:
cursor=mycon.cursor()
new=int(input("Enter new cost price:"))
cursor.execute('''Update inventory set cp={}
where itemid='{}' '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==7:
cursor=mycon.cursor()
new=int(input("Enter new sellipng price:"))
cursor.execute('''Update inventory set sp={}
where itemid='{}' '''.format(new,itid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to modify another item?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
else:
print("invalid input")
ans=input("Do you want to try again?(yes/no):")
if ans=='yes':
continue
elif ans=='no':
print("Thank you for visiting")
break
break
#################################
def supplier():
import mysql.connector as x
mycon=x.connect(host='localhost',user="root",passwd="Tanisha29@",database="abc")
if mycon.is_connected()==False:
print("Error connecting to mysql database")
while True:
print('''Choose one of the following operations:
1.View all suppliers
2.View suppliers item wise
3.add or remove supplier
4.modify supplier name''')
ch=int(input("Enter choice:"))
#view all suppliers
if ch==1:
cursor=mycon.cursor()
print("SUPPLIER DETAILS")
print("Supid, Name")
cursor.execute("Select * from supplier order by ID")
data=cursor.fetchall()
for row in data:
print(row)
ans=input("Do you want to continue?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
#view suppliers item wise
elif ch==2:
cursor=mycon.cursor()
print("ITEM AND SUPPLIER DETAILS")
print("Itemid, ItemName, Supid, Supplier")
cursor.execute('''select inventory.itemid,inventory.name as 'itemname',ID,
supplier.name as 'supplier name' from inventory,supplier,
itemsup where inventory.itemid=itemsup.itemid and ID=supid;''')
data=cursor.fetchall()
for row in data:
print(row)
ans=input("Do you want to continue?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
#add or remove supplier
elif ch==3:
print('''Do you want to :
1.add
2.remove''')
y=int(input("Enter choice:"))
print()
if y==1:
while True:
cursor=mycon.cursor()
sid=input("Enter supplier id")
sname=input("Enter supplier name")
cursor.execute("Insert into supplier values('{}','{}')".format(sid,sname))
mycon.commit()
print("successfully added")
ans=input("Do you want to add more?(yes/no):")
if ans=="yes":
continue
else:
break
elif y==2:
while True:
cursor=mycon.cursor()
sid=input("Enter supplier id:")
cursor.execute("delete from supplier where ID='{}'".format(sid))
mycon.commit()
print("removed successfully")
ans=input("Do you want to remove more?(yes/no):")
if ans=="yes":
continue
else:
break
#modify supplier
elif ch==4:
while True:
cursor=mycon.cursor()
sid=input("Enter supplier id:")
new=input("Enter new name:")
cursor.execute("update supplier set name='{}' where ID='{}'".format(new,sid))
mycon.commit()
print("updated successfully")
ans=input("Do you want to update another supplier?(yes/no):")
if ans=="yes":
continue
else:
return
###################################
def orders():
import mysql.connector as x
mycon=x.connect(host='localhost',user="root",passwd="Tanisha29@",database="abc")
if mycon.is_connected()==False:
print("Error connecting to mysql database")
while True:
print('''Choose one of the following operations:
1.View orders
2.add or delete order
''')
ch=int(input("Enter choice:"))
#view order
if ch==1:
cursor=mycon.cursor()
print("ORDER DETAILS")
print("itemid, itemName, curorder, orddate")
cursor.execute('''select orders.itemid,name,ordcnt,orddate from inventory,
orders where inventory.itemid=orders.itemid order by orddate''')
data=cursor.fetchall()
for row in data:
print(row)
ans=input("Do you want to continue?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
#add or delete order
elif ch==2:
cursor=mycon.cursor()
print('''Do you want to :
1.add
2.delete''')
y=int(input("Enter choice:"))
print()
if y==1:
while True:
cursor=mycon.cursor()
itid=input("Enter item id:")
curord=int(input("Enter current orders of this item:"))
orddate=input("Enter order date:")
cursor.execute('''Insert into orders values('{}',{},'{}')
'''.format(itid,curord,orddate))
mycon.commit()
print("successfully added")
ans=input("Do you want to add more?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
elif y==2:
while True:
cursor=mycon.cursor()
itid=input("Enter item id:")
cursor.execute("delete from orders where itemid='{}'".format(itid))
mycon.commit()
print("deleted successfully")
ans=input("Do you want to delete another order?(yes/no):")
if ans=="yes":
continue
elif ans=="no":
break
else:
print("invalid input")
#main
import mysql.connector as x
mycon=x.connect(host='localhost',user="root",passwd="Tanisha29@",database="abc")
if mycon.is_connected()==False:
print("Error connecting to mysql database")
while True:
print('''
********************!!!!! TPT MARKET !!!!!**********************
GREETINGS!!
WELCOME TO TPT MARKET...
What would you like to manage?
1.Inventory
2.Supplier
3.Orders
4.Exit
''')
op=int(input("Enter option:"))
if op==1:
inventory()
elif op==2:
supplier()
elif op==3:
orders()
elif op==4:
print("Thank You for visiting!")
break
else:
print("Wrong input")