-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate.py
More file actions
71 lines (54 loc) · 2.06 KB
/
update.py
File metadata and controls
71 lines (54 loc) · 2.06 KB
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
import MiniWorld
import colours
import subprocess as sp
def a():
cid = input("Enter Customer ID: ")
amount = float(input("Enter Updated Amount: "))
query = f"UPDATE Customer SET Amount_Received = {amount} where Customer_ID = '{cid}'"
if MiniWorld.executeQuery(query) == 1:
print(f"{colours.bcolors.OKGREEN}Updated Database{colours.bcolors.ENDC}")
print("")
return
def b():
pid = input("Enter Producer ID: ")
amount = float(input("Enter Updated Amount: "))
query = f"UPDATE Producer SET Total_Amount_Paid = {amount} where Producer_ID = '{pid}'"
if MiniWorld.executeQuery(query) == 1:
print(f"{colours.bcolors.OKGREEN}Updated Database{colours.bcolors.ENDC}")
print("")
return
def c():
name = input("Enter Organisation name: ")
value = float(input("Enter Updated Market Value: "))
query = f"UPDATE Organisation SET Market_Value = {value} where Organisation_Name = '{name}'"
if MiniWorld.executeQuery(query) == 1:
print(f"{colours.bcolors.OKGREEN}Updated Database{colours.bcolors.ENDC}")
print("")
return
def update():
while(1):
tmp = sp.call('clear', shell=True)
print("Choose an operation:")
print(f"{colours.bcolors.OKCYAN}")
print("1. Customer Amount")
print("2. Producer Amount")
print("3. Organisation market value")
print(f"{colours.bcolors.ENDC}{colours.bcolors.WARNING}")
print("4. Back")
print("5. Exit")
print(f"{colours.bcolors.ENDC}")
ch = input("Enter choice: ").lower()
tmp = sp.call('clear', shell=True)
if ch == '1' or ch == 'customer amount':
a()
elif ch == '2' or ch == 'producer amount':
b()
elif ch == '3' or ch == 'organisation market value':
c()
elif ch == '4' or ch == 'back':
return
elif ch == '5' or ch == 'exit':
exit()
else:
print(f"{colours.bcolors.RED}Invalid Option{colours.bcolors.ENDC}")
input("Enter any key to continue: ")