-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathid_generation.py
54 lines (48 loc) · 1.78 KB
/
id_generation.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
from cs50 import SQL
db = SQL("sqlite:///management.db")
key = "PVTLTD786"
def qr_id_generation(passcode):
if passcode != key:
return 0
row = db.execute("SELECT QR_ID FROM constants WHERE key = ?;", key)
count = row[0]["QR_ID"].replace("QR", "")
count = int(count) + 1
new = "QR" + str(count)
db.execute("UPDATE constants SET QR_ID = ? WHERE key = ?;", new, key)
return new
def job_card_generation(passcode):
if passcode != key:
return 0
row = db.execute("SELECT Job_Card FROM constants WHERE key = ?;", key)
count = row[0]["Job_Card"].replace("JC", "")
count = int(count) + 1
new = "JC" + str(count)
db.execute("UPDATE constants SET Job_Card = ? WHERE key = ?;", new, key)
return new
def order_id_generation(passcode):
if passcode != key:
return 0
row = db.execute("SELECT Order_ID FROM constants WHERE key = ?;", key)
count = row[0]["Order_ID"].replace("OD", "")
count = int(count) + 1
new = "OD" + str(count)
db.execute("UPDATE constants SET Order_ID = ? WHERE key = ?;", new, key)
return new
def customer_id_generation(passcode):
if passcode != key:
return 0
row = db.execute("SELECT Customer_ID FROM constants WHERE key = ?;", key)
count = row[0]["Customer_ID"].replace("C", "")
count = int(count) + 1
new = "C" + str(count)
db.execute("UPDATE constants SET Customer_ID = ? WHERE key = ?;", new, key)
return new
def product_id_generation(passcode):
if passcode != key:
return 0
row = db.execute("SELECT Product_ID FROM constants WHERE key = ?;", key)
count = row[0]["Product_ID"].replace("PD", "")
count = int(count) + 1
new = "PD" + str(count)
db.execute("UPDATE constants SET Product_ID = ? WHERE key = ?;", new, key)
return new