-
Notifications
You must be signed in to change notification settings - Fork 0
/
G-Hub Main Python Code.py
1103 lines (909 loc) · 48.9 KB
/
G-Hub Main Python Code.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
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Importing Modules
import csv
import mysql.connector as sqltor
import sys
from prettytable import PrettyTable
#Store Initialisation
StorePIN = 1104
StoreDiscount = 0
SpecialMessage = "Happy Chinese New Year!!!"
SpecialMessage1="Discount of {} % on all products".format(StoreDiscount)
WelcomeMessage = "Welcome to G-Hub!"
WelcomeMessageUser = "One stop for all your gaming needs!"
ExitMessage="Thank You for Visiting G-Hub! Come Back Again! :))"
Genre=["Open-World", "Adventure", "Sports", "FPS", "Platformer"]
mycon=sqltor.connect(host="localhost", user="root", passwd="12345678", database="ghub2")
gamecursor=mycon.cursor()
buycursor=mycon.cursor()
browsecursor=mycon.cursor()
consolecursor=mycon.cursor()
developercursor=mycon.cursor()
developercursor2=mycon.cursor()
managercursor=mycon.cursor()
approvecursor=mycon.cursor()
showcursor1=mycon.cursor()
showcursor2=mycon.cursor()
listcursor=mycon.cursor()
print(r''' _______ ___ .___ ___. _______ __ __ __ __ .______ __ __
/ _____| / \ | \/ | | ____| | | | | | | | | | _ \ | | | |
| | __ / ^ \ | \ / | | |__ ______| |__| | | | | | | |_) | | | | |
| | |_ | / /_\ \ | |\/| | | __| |______| __ | | | | | | _ < | | | |
| |__| | / _____ \ | | | | | |____ | | | | | `--' | | |_) | |__| |__|
\______| /__/ \__\ |__| |__| |_______| |__| |__| \______/ |______/ (__) (__) ''')
print()
print()
def MemberSignIn():
UserName=input("Enter your UserName : ")
UserPassword=input("Enter your Password : ")
UD=open("UserData.txt","r+")
for i in UD:
if i.split()[0] == UserName:
if i.split()[1] == UserPassword:
print("Welcome {}!!".format(UserName))
UD.close()
return ("success")
else:
for y in (0,3): #3 Tries for Password
print("Incorrect Password!! Try Again! Enter 0 to go back")
UserPassword=input("Enter your Password Again: ")
if UserPassword=="0":
UD.close()
return ("fail") #Take Back to Main Menu
elif i.split()[1] == UserPassword:
print("Welcome {}!!".format(UserName))
UD.close()
return ("success")
else:
print("Too many wrong attempts! Impostor Detected :<") #Take Back to Main Menu
UD.close()
sys.exit()
break
else:
print("UserName does not exist... You will be taken back to Main Menu")
UD.close()
return ("fail")
def MemberSignUp():
UserName=input("Enter a UserName: ")
UD=open("UserData.txt","r+")
c=1
for i in UD:
c+=1
if i.split()[0] == UserName:
print("UserName exists already! Please LogIn or choose another UserName!!")
return None
else:
UserPassword=input("UserName available, Enter a Password: ")
UD.write("\n")
UD.write("{} {}".format(UserName,UserPassword))
UD.close()
print("Member Account created!! Please LogIn again!")
return None
def DeveloperSignIn():
DeveloperName=input("Enter your DeveloperName : ")
DeveloperPassword=input("Enter your Password : ")
DD=open("DeveloperData.txt","r+")
for i in DD:
if i.split("-")[1] == DeveloperName:
if (i.split("-")[2]) == (DeveloperPassword+"\n"):
print("Welcome {}!!".format(DeveloperName))
return (DeveloperName)
else:
for y in (0,3): #3 Tries for Password
print("Incorrect Password!! Try Again! Enter 0 to go back")
DeveloperPassword=input("Enter your Password Again: ")
if int(DeveloperPassword)==0:
DD.close()
return ("fail") #Take Back to Main Menu
break
elif i.split("-")[2] == DeveloperPassword+"\n":
print("Welcome {}!!".format(DeveloperName))
DD.close()
return (DeveloperName)
break
else:
print("Too many wrong attempts! Impostor Detected :<") #Take Back to Main Menu
DD.close()
sys.exit()
break
else:
print("DeveloperName does not exist... You will be taken back to Main Menu")
DD.close()
return ("fail")
def AddToCart(y):
z=int(input("""Enter ID to Select Product
Enter 0 to Go Back
--->"""))
if z==0:
return None
elif z not in y.keys():
print("Please Select Valid Choice!")
AddToCart(y)
else:
if y[z][0]=="Console":
z1=int(input("""You Have Selected {}
1. Buy Product
2. Add to Cart
0. Exit
--->""".format(y[z][2])))
if z1==0:
return None
elif z1==1:
BuyProduct(y[z])
elif z1==2:
cart.append(y[z])
z2=int(input(("""{} successfully added! Cart has {} items.
0. Return and Shop
1. View Cart
--->""".format(y[z][2],len(cart)))))
if z2==0:
return None
elif z2==1:
GoToCart()
elif y[z][0]=="Game":
a1=int(input("""Select Console
1. PS
2. XBOX
3. NINTENDO
--->"""))
if a1==1:
browsecursor.execute("select Stock_PS from Games where ID={}".format(y[z][1]))
s=browsecursor.fetchone()
if s[0]==0:
print("NO STOCK AVAILABLE FOR PS\n")
return None
else:
y[z][0]="Game-PS"
z1=int(input("""You Have Selected {}
1. Buy Product
2. Add to Cart
0. Exit
--->""".format(y[z][2])))
if z1==0:
return None
elif z1==1:
BuyProduct(y[z])
elif z1==2:
cart.append(y[z])
z2=int(input(("""{} successfully added! Cart has {} items.
0. Return and Shop
1. View Cart
--->""".format(y[z][2],len(cart)))))
if z2==0:
return None
elif z2==1:
GoToCart()
elif a1==2:
browsecursor.execute("select Stock_XBOX from Games where ID={}".format(y[z][1]))
s=browsecursor.fetchone()
if s[0]==0:
print("NO STOCK AVAILABLE FOR XBOX\n")
return None
else:
y[z][0]="Game-XBOX"
z1=int(input("""You Have Selected {}
1. Buy Product
2. Add to Cart
0. Exit
--->""".format(y[z][2])))
if z1==0:
return None
elif z1==1:
BuyProduct(y[z])
elif z1==2:
cart.append(y[z])
z2=int(input(("""{} successfully added! Cart has {} items.
0. Return and Shop
1. View Cart
--->""".format(y[z][2],len(cart)))))
if z2==0:
return None
elif z2==1:
GoToCart()
elif a1==3:
browsecursor.execute("select Stock_Nintendo from Games where ID={}".format(y[z][1]))
s=browsecursor.fetchone()
if s[0]==0:
print("NO STOCK AVAILABLE FOR Nintendo\n")
return None
else:
y[z][0]="Game-Nintendo"
z1=int(input("""You Have Selected {}
1. Buy Product
2. Add to Cart
0. Exit
--->""".format(y[z][2])))
if z1==0:
return None
elif z1==1:
BuyProduct(y[z])
elif z1==2:
cart.append(y[z])
z2=int(input(("""{} successfully added! Cart has {} items.
0. Return and Shop
1. View Cart
--->""".format(y[z][2],len(cart)))))
if z2==0:
return None
elif z2==1:
GoToCart()
def GoToCart():
print("Your Cart --> ")
cx=PrettyTable()
cx.field_names=["No.", "Type", "ID", "Item", "Price"]
z=1
for i in cart:
cx.add_row([z]+i)
z+=1
print(cx)
while True:
c1=int(input("""Actions:
1. Checkout Now
2. Delete One Item
3. Clear Cart
0. Go to User Main Menu
--->"""))
if c1==0:
print()
return None
elif c1==1:
total=0
for i in cart:
total+=i[3]
print("Total Amount is ${} for {} items".format(total*((100-StoreDiscount)/100), len(cart)))
for i in range(0,len(cart)):
BuyProduct(cart[i])
cart.clear()
print("Thank you for visiting G-Hub!! :)")
print("You will now be taken to the Previous Menu")
print()
return None
elif c1==2:
dc=int(input("Enter Product No. to Delete -->"))
if dc>len(cart):
print("Please enter valid choice! :<")
continue
else:
del cart[dc-1]
print("Item Deleted Successfully!")
print()
continue
elif c1==3:
print("Are you sure you want to clear your cart?")
c22=int(input('''1.Yes
2.No
--->'''))
if c22==2:
continue
elif c22==1:
cart.clear()
print()
def BuyProduct(a):
if a[0]=="Game-PS":
price=a[3]*((100-StoreDiscount)/100)
print("Stock is available!! Price is $",price)
buycursor.execute("update Games set Stock_PS=Stock_PS-1, Stock_Overall=Stock_Overall-1, Sales_PS=Sales_PS+1, Sales_Overall=Sales_Overall+1, Revenue_PS=Revenue_PS+{}, Revenue_Overall=Revenue_Overall+{} where ID={}".format(price,price,a[1]))
print("{} PURCHASE SUCCESSFUL!!".format(a[2]))
mycon.commit()
print()
return None
elif a[0]=="Game-XBOX":
price=a[3]*((100-StoreDiscount)/100)
print("Stock is available!! Price is $",price)
buycursor.execute("update Games set Stock_XBOX=Stock_XBOX-1, Stock_Overall=Stock_Overall-1, Sales_XBOX=Sales_XBOX+1, Sales_Overall=Sales_Overall+1, Revenue_XBOX=Revenue_XBOX+{}, Revenue_Overall=Revenue_Overall+{} where ID={}".format(price,price,a[1]))
print("{} PURCHASE SUCCESSFUL!!".format(a[2]))
mycon.commit()
print()
return None
elif a[0]=="Game-Nintendo":
price=a[3]*((100-StoreDiscount)/100)
print("Stock is available!! Price is $",price)
buycursor.execute("update Games set Stock_Nintendo=Stock_Nintendo-1, Stock_Overall=Stock_Overall-1, Sales_Nintendo=Sales_Nintendo+1, Sales_Overall=Sales_Overall+1, Revenue_Nintendo=Revenue_Nintendo+{}, Revenue_Overall=Revenue_Overall+{} where ID={}".format(price,price,a[1]))
print("{} PURCHASE SUCCESSFUL!!".format(a[2]))
mycon.commit()
print()
return None
elif a[0]=="Console":
browsecursor.execute("select Stock from Consoles where ID = {}".format(a[1]))
atemp=browsecursor.fetchall()
if atemp==0:
print("Sorry, No stock available!!")
print()
else:
price=a[3]*((100-StoreDiscount)/100)
print("Stock is available!! Price is $",price)
buycursor.execute("update Consoles set Stock=Stock-1, Sales=Sales+1, Revenue=Revenue+{} where ID={}".format(price,a[1]))
print("{} PURCHASE SUCCESSFUL!!".format(a[2]))
mycon.commit()
print()
return None
cart = []
GameProduct={}
ConsoleProduct={}
while True: #Main Menu
print("Welcome to G-Hub.........",SpecialMessage1,".", SpecialMessage)
i=int(input("""1. User Login/Sign Up
2. Developer LogIn
3. Store Manager LogIn
0. Exit Store
----> """))
if i==0:
print("Thank You for Visiting G-Hub!")
break
elif i==1:
i1=int(input("""Welcome!!
1. Sign In
2. Sign Up
0. Exit
-----> """))
if i1 == 0:
print("Thank You!!")
continue
elif i1 == 1:
i1a=MemberSignIn()
if i1a == "fail" :
continue
elif i1a == "success" :
while True:
print()
i1b = int(input(""" Welcome !!
1. Buy Games
2. Buy Consoles
3. Check Cart
0. Log Out
-----> """))
if i1b==0:
print("Thanks for visiting G-Hub!\n")
break
elif i1b==1:
while True:
i1b1 = input("""1. List All Games
2. List By Genre
To sort by price, add P after choice. (1P)
To sort by release year, add Y after choice. (1Y)
0. Exit
------> """).upper()
if "1" in i1b1:
if "P" in i1b1:
gamecursor.execute("select ID, Game_Name, Store_Price, Game_Genre, Release_Year, List_Status from Games order by Store_Price")
data=gamecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Game","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
GameProduct[i[0]]=["Game",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(GameProduct)
if gxx==None:
continue
elif "Y" in i1b1:
gamecursor.execute("select ID, Game_Name, Store_Price, Game_Genre, Release_Year, List_Status from Games order by Release_Year desc")
data=gamecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Game","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
GameProduct[i[0]]=["Game",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(GameProduct)
if gxx==None:
continue
else:
gamecursor.execute("select ID, Game_Name, Store_Price, Game_Genre, Release_Year, List_Status from Games")
data=gamecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Game","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
GameProduct[i[0]]=["Game",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(GameProduct)
if gxx==None:
continue
elif "2" in i1b1:
gen=int((input("""Enter Genre
1. Open-World
2. Adventure
3. Sports
4. FPS
5. Platformer
0. Exit
-------> """)))
if gen==0:
continue
else:
if "P" in i1b1:
gamecursor.execute("select ID, Game_Name, Store_Price, Game_Genre, Release_Year, List_Status from Games where Game_Genre='{}' order by Store_Price".format(Genre[gen-1]))
data=gamecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Game","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
GameProduct[i[0]]=["Game",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(GameProduct)
if gxx==None:
continue
elif "Y" in i1b1:
gamecursor.execute("select ID, Game_Name, Store_Price, Game_Genre, Release_Year, List_Status from Games where Game_Genre='{}' order by Release_Year desc".format(Genre[gen-1]))
data=gamecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Game","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
GameProduct[i[0]]=["Game",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(GameProduct)
if gxx==None:
continue
else:
gamecursor.execute("select ID, Game_Name, Store_Price, Game_Genre, Release_Year, List_Status from Games where Game_Genre='{}';".format(Genre[gen-1]))
data=gamecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Game","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
GameProduct[i[0]]=["Game",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(GameProduct)
if gxx==None:
continue
elif "0" in i1b1:
print("You will be taken back......")
break
else:
print("Invalid Input, Please Try Again!")
continue
elif i1b==2:
while True:
i1c1=input("""1. List All Consoles
2. HandHeld Consoles
3. Home Consoles
0. Exit
To sort by price, add P after choice. (1P)
To sort by release year, add Y after choice. (1Y)
----->""").upper()
if "0" in i1c1:
print("You will be taken back....")
break
elif "1" in i1c1:
if "P" in i1c1:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles order by Store_Price")
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
elif "Y" in i1c1:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles order by Release_Year desc")
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
else:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles")
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
if "2" in i1c1:
if "P" in i1c1:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles where Console_Type='{}' order by Store_Price".format("Handheld"))
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
elif "Y" in i1c1:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles where Console_Type='{}' order by Release_Year desc".format("Handheld"))
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
else:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles where Console_Type='{}'".format("Handheld"))
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
if "3" in i1c1:
if "P" in i1c1:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles where Console_Type='{}' order by Store_Price".format("Home"))
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
elif "Y" in i1c1:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles where Console_Type='{}' order by Release_Year desc".format("Home"))
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
else:
consolecursor.execute("select ID, Console_Name, Store_Price, Console_Type, Release_Year, List_Status from Consoles where Console_Type='{}'".format("Home"))
data=consolecursor.fetchall()
sx=PrettyTable()
sx.field_names=["ID","Console","Price","Genre","Release Year"]
for i in data:
if i[5]==1:
sx.add_row(i[:5])
ConsoleProduct[i[0]]=["Console",i[0],i[1],i[2]]
print(sx)
gxx=AddToCart(ConsoleProduct)
if gxx==None:
continue
elif i1b==3:
i1bg=GoToCart()
if i1bg==None:
continue
elif i1 == 2:
MemberSignUp()
continue
elif i==2:
while True:
i2=int(input(""" Welcome Developer!!
1. Sign In
0. Exit
----> """))
if i2 == 0:
print("Thank You!!")
break
elif i2 == 1:
i2a=DeveloperSignIn()
if i2a != "fail" :
while True:
ddd=[]
ddc=[]
i2b = int(input(""" Welcome !!
1. Check Sales and Revenue
2. Check and Update Inventory
3. List New Product
0. Log Out
-----> """))
if i2b==0:
print("Thank you for visiting G-Hub!")
break
elif i2b==3:
i2bl=int(input("""List New
1. Game
2. Console
0. Exit
------> """))
if i2bl==0:
print("Hope you have something new for G-Hub next time! :>")
break
elif i2bl==1:
listcursor.execute("select * from Games")
ran=listcursor.fetchall()
GD=i2a
GID=len(ran)+1
GName=input("Enter Game name -->")
GSPrice=0
GDPrice=int(input("Enter Developer Price -->"))
GGenre=input("Enter Game Genre -->")
GYear=int(input("Enter Release Year -->"))
while True:
GStock=eval(input("Enter Stock for Game as list in format [Stock Overall, Stock PS, Stock XBOX, Stock Nintendo] -->"))
if GStock[0]!=GStock[1]+GStock[2]+GStock[3]:
print("Please enter valid stock numbers, and ensure that PS/Xbox/Nintendo Stock total comes to Overall!!")
continue
else:
break
listcursor.execute("insert into Games values ('{}',{},'{}',{},{},'{}',{},{},{},{},{},{},{},{},{},{},{},{},{},{})".format(GD,GID,GName,GSPrice,GDPrice,GGenre,GYear,GStock[0],GStock[1],GStock[2],GStock[3],0,0,0,0,0,0,0,0,0))
mycon.commit()
print("Game Listed Succesfully. Will Soon Be Added By Store Manager")
print()
elif i2bl==2:
listcursor.execute("select * from Consoles")
ran=listcursor.fetchall()
CD=i2a
CID=len(ran)+1
CName=input("Enter Console Name --> ")
CSPrice=0
CDPrice=int(input("Enter Developer Price --> "))
CType=input("Enter Console Type (Handheld/Home) --> ")
CYear=int(input("ENter Release Year -->"))
CStock=int(input("Enter Stock -->"))
listcursor.execute("insert into Consoles values ('{}',{},'{}',{},{},'{}',{},{},{},{},{})".format(CD,CID,CName,CSPrice,CDPrice,CType,CYear,CStock,0,0,0))
mycon.commit()
print("Console Listed Succesfully. Will Soon Be Added By Store Manager")
print()
elif i2b==1:
developercursor2.execute("select ID, Game_Name, Developer_Price, Sales_Overall, Sales_PS, Sales_XBOX, Sales_Nintendo from Games where Developer='{}'".format(i2a))
datag=developercursor2.fetchall()
dgx=PrettyTable()
dgx.field_names=["ID","Game","Dev. Price","Sales Overall","Sales PS","Sales XBOX","Sales Nintendo","Game Revenue"]
gdrevenue=0
for i in datag:
dgx.add_row(list(i[:7])+[i[2]*i[3]])
gdrevenue+=i[2]*i[3]
print(dgx)
print("----------X-----------")
print()
print("Total Revenue from Games --> $",gdrevenue)
developercursor2.execute("Select ID, Console_Name, Developer_Price, Sales from Consoles where Developer='{}'".format(i2a))
datac=developercursor2.fetchall()
dcx=PrettyTable()
dcx.field_names=["ID","Console","Dev. Price","Sales","Console Revenue"]
cdrevenue=0
for i in datac:
dcx.add_row(list(i[:5])+[i[2]*i[3]])
cdrevenue+=i[2]*i[3]
print(dcx)
print("----------X-----------")
print("Total Revenue from Consoles --> $",cdrevenue)
print()
print()
print("----------------------")
print("Total Revenue --> $",cdrevenue+gdrevenue)
print()
print()
continue
elif i2b==2:
i2b1=int(input("""Inventory for.......
1.Games
2.Consoles
0. Go Back
-----> """))
if i2b1==0:
break
elif i2b1==1:
developercursor.execute("select ID, Game_Name, Developer_Price, Stock_Overall, Stock_PS, Stock_Xbox, Stock_Nintendo, List_Status from Games where Developer='{}'".format(i2a))
data=developercursor.fetchall()
dsgx=PrettyTable()
dsgx.field_names=["ID", "Game", "Dev. Price", "Stock Overall", "Stock PS", "Stock XBOX", "Stock Nintendo"]
for i in data:
if i[7]==1:
ddd.append(i[0])
dsgx.add_row(i[:7])
print(dsgx)
while True:
updinput=int(input("Enter 0 to Go Back, Select ID to update stock-->"))
if updinput == 0:
break
elif updinput not in ddd:
print("Enter valid choice!!")
continue
else:
while True:
upd2=eval(input("Enter Stock to be added as a list of format [Stock_Overall, Stock_PS, Stock_Xbox, Stock_Nintendo]"))
if upd2[0]!=upd2[1]+upd2[2]+upd2[3]:
print("Enter valid choice")
continue
else:
developercursor.execute("update Games set Stock_Overall=Stock_Overall+{}, Stock_PS=Stock_PS+{}, Stock_XBOX=Stock_XBOX+{}, Stock_Nintendo=Stock_Nintendo+{} where ID={}".format(upd2[0],upd2[1],upd2[2],upd2[3],updinput))
print("Stock updated successfully!!")
mycon.commit()
print()
break
elif i2b1==2:
developercursor.execute("select ID, Console_Name, Developer_Price, Stock, List_Status from Consoles where Developer='{}'".format(i2a))
data=developercursor.fetchall()
dscx=PrettyTable()
dscx.field_names=["ID","Console","Dev. Price","Stock"]
for i in data:
if i[4]==1:
ddc.append(i[0])
dscx.add_row(i[:4])
print(dscx)
while True:
updcinput=int(input("Enter 0 to Go Back, Select ID to update stock-->"))
if updcinput == 0:
break
elif updcinput not in ddc:
print("Enter valid choice!!")
continue
else:
while True:
updc2=int(input("Enter Stock to be added -->"))
developercursor.execute("update Consoles set Stock=Stock+{} where ID={}".format(updc2,updcinput))
print("Stock updated successfully!!")
mycon.commit()
print()
break
else:
break
elif i==3:
countpin=0
while True:
InputPIN=int(input('''Enter PIN To Continue
Enter 0 To Return To Main Menu
--->'''))
if InputPIN==0:
print()
break
elif InputPIN!=StorePIN:
if countpin==2:
print("Too Many Wrong Entries.You Will Be Taken Back To The Main Menu")
print()
break
else:
print("Wrong PIN, Try Again!")
print()
countpin+=1
continue
else:
while True:
print()
i4=int(input("""Hello Manager!!
1. Update Store Discount
2. Special Message/Notice
3. Approve Listings
4. Console Sales
5. Game Sales
6. Overall Sales
0. Exit
-----> """))
if i4 == 0:
countpin=0
print("Thank You!")
print()
break
elif i4 == 1:
print("{} % is the current storewide discount".format(StoreDiscount))
StoreDiscount = int(input("Enter New Store Discount -->"))
print("{} % is the new Store Discount!".format(StoreDiscount) )
SpecialMessage1="{} % is the new Store Discount!".format(StoreDiscount)
print()
continue
elif i4 == 2:
SpecialMessage=input("Enter Special Message/Notice :")
print("Done!")
print()
continue
elif i4==3:
choice=int(input('''1. Games
2. Consoles
--->'''))
if choice==1:
approvecursor.execute("select ID, Game_Name, Developer_Price, Stock_Overall from games where List_Status=0")
pending=approvecursor.fetchall()
print("ID---Game_Name---Developer_Price---Stock_Overall")
for i in pending:
for j in range(0,4):
print(i[j],end=" -- ")
StorePrice=int(input("Enter Store Price for Game : "))
approvecursor.execute("update Games set Store_Price={},List_Status={} where ID={}".format(StorePrice,1,i[0]))
mycon.commit()
print("All Games Listed!!")
print()
continue
elif choice==2:
approvecursor.execute("select ID, Console_Name, Developer_Price, Stock from Consoles where List_Status=0")
pending=approvecursor.fetchall()
print("ID---Console_Name---Developer_Price---Stock_Overall")
for i in pending:
for j in range(0,4):
print(i[j],end=" -- ")
StorePrice=int(input("Enter Store Price for Game : "))
approvecursor.execute("update Consoles set Store_Price={},List_Status={} where ID={}".format(StorePrice,1,i[0]))
mycon.commit()
print("All Consoles Listed!!")
print()
continue
elif i4==4:
showcursor1.execute("select Developer, ID, Console_Name, Store_Price, Developer_Price, Sales, Revenue from Consoles")
dis=showcursor1.fetchall()
ssc=PrettyTable()
ssc.field_names=["Developer","ID","Console","Price","Dev. Price","Sales","Revenue","Profit"]
crevenue=0
cprofit=0
for i in dis:
crevenue+=i[6]
ssc.add_row(list(i[:7])+[i[6]-i[4]*i[5]])
cprofit+=i[6]-(i[4]*i[5])
print(ssc)
print("Total Revenue from Consoles --> ", crevenue)
print("Total Profit from Consoles --> ", cprofit)
print()