-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.py
145 lines (133 loc) · 4.72 KB
/
Main.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
from EduMart import Store
import time
import os
os.system('cls')
# Setting up database environment
while True:
print("Setting up database environment...")
time.sleep(2)
print("\nDefault database settings: ")
print("Host: localhost")
print("User: root")
print("Password: Johnleo1152003.")
choice = input("\nWould you like to use the default database settings? (Y/N): ").lower()
if choice == "n":
user = input("\nEnter your MySQL username: ")
password = input("Enter your MySQL password: ")
# Create a Store object
store = Store(user, password)
break
elif choice == "y":
# Create a Store object
store = Store()
break
else:
print("Invalid input. Please try again.")
time.sleep(2)
os.system('cls')
# Login as an admin or customer
while True:
os.system('cls')
print('Welcome to EduMart!')
print('\nPlease login to continue.')
print('\nLogin as: ')
print('[1] Admin')
print('[2] Customer')
print('[3] Exit')
user_type = input('\nChoose an action: ')
os.system('cls')
if user_type == "1":
admin_login = store.admin_login()
if admin_login == True:
os.system('cls')
while True:
print('Admin Actions:')
# View Products, View Sales, View Customers, View Admins, Add Product, Add Admin,
# Remove Product, Update Product, Restock Product
print("[1] View Products")
print("[2] View Sales")
print("[3] View Customers")
print("[4] View Admins")
print("[5] Add Product")
print("[6] Add Admin")
print("[7] Remove Product")
print("[8] Update Product")
print("[9] Restock Product")
print("[10] Logout")
admin_action = int(input("\nEnter an action: "))
os.system('cls')
if admin_action == 1:
store.view_products()
os.system('cls')
elif admin_action == 2:
store.view_sales()
os.system('cls')
elif admin_action == 3:
store.view_customers()
os.system('cls')
elif admin_action == 4:
store.view_admins()
os.system('cls')
elif admin_action == 5:
store.add_product()
os.system('cls')
elif admin_action == 6:
store.add_admin()
os.system('cls')
elif admin_action == 7:
store.remove_product()
os.system('cls')
elif admin_action == 8:
store.update_product()
os.system('cls')
elif admin_action == 9:
store.restock_product()
os.system('cls')
elif admin_action == 10:
os.system('cls')
break
elif user_type == "2":
while True:
os.system('cls')
type = input("Are you registered? (Y/N): ").lower()
if type == "y":
customer_login = store.customer_login()
break
elif type == "n":
store.customer_register()
else:
print("Invalid input. Please try again.")
time.sleep(2)
os.system('cls')
if customer_login == True:
os.system('cls')
while True:
print('Customer Actions:')
# Add To Cart, Remove From Cart, Pay, Edit Cart, Edit Profile, Logout
print("[1] Buy Product")
print("[2] Edit Account")
print("[3] Search Product")
print("[4] Logout")
customer_action = int(input("\nEnter an action: "))
os.system('cls')
if customer_action == 1:
store.customer_buy()
os.system('cls')
elif customer_action == 2:
store.customer_edit()
os.system('cls')
elif customer_action == 3:
store.custom_search()
os.system('cls')
elif customer_action == 4:
os.system('cls')
break
elif user_type == "3":
print("Exiting...")
time.sleep(2)
os.system('cls')
break
else:
print("Invalid input. Please try again.")
time.sleep(2)
os.system('cls')