-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathview.py
273 lines (225 loc) · 12.8 KB
/
view.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
# File: /view.py
import os.path
import controller
def createfiles(*args):
for i1 in args:
if not os.path.exists(i1):
with open(i1, 'w') as file:
file.write('')
createfiles('hd_category.txt',
'hd_customer.txt',
'hd_employee.txt',
'hd_person.txt',
'hd_sale.txt',
'hd_stock.txt',
'hd_supplier.txt')
if __name__ == '__main__':
while True:
ask_global = int(input('Enter 1 to access [Categories]\n'
'Enter 2 to access [Stock]\n'
'Enter 3 to access [Supplier]\n'
'Enter 4 to access [Customer]\n'
'Enter 5 to access [Employee]\n'
'Enter 6 to access [Sales]\n'
'Enter 7 to [exit]: \n'))
if ask_global == 1:
categorycontroller = controller.CategoryController()
while True:
ask_categories = int(input('Enter 1 to [register] a category\n'
'Enter 2 to [remove] a category\n'
'Enter 3 to [change] a category\n'
'Enter 4 to [show] registered categories\n'
'Enter 5 to [exit]: \n'))
if ask_categories == 1:
category = input('Enter the category you want to register: \n')
categorycontroller.register(category)
elif ask_categories == 2:
category = input('Enter the category you want to remove: \n')
categorycontroller.remove(category)
elif ask_categories == 3:
categoryold = input('Enter the category you want to change: \n')
categorynew = input('Enter the new category: \n')
categorycontroller.change(categoryold,
categorynew)
elif ask_categories == 4:
categorycontroller.show()
else:
break
elif ask_global == 2:
stockcontroller = controller.StockController()
while True:
ask_stock = int(input('Enter 1 to [register] a new product\n'
'Enter 2 to [remove] a product\n'
'Enter 3 to [change] a product\n'
'Enter 4 to [view] a product\n'
'Enter 5 to [exit]: \n'))
if ask_stock == 1:
name = input('Enter a new product: \n')
price = input('Enter a price of the product: \n')
category = input('Enter a category of the product: \n')
quantity = input('Enter a quantity of the product: \n')
stockcontroller.register(name,
price,
category,
quantity)
elif ask_stock == 2:
product = input('Enter the product you want to remove: \n')
stockcontroller.remove(product)
elif ask_stock == 3:
nameold = input('Enter a product you want to change: \n')
namenew = input('Enter the new product name: \n')
pricenew = input('Enter the new product price: \n')
categorynew = input('Enter the product category: \n')
quantitynew = input('Enter the product quantity')
stockcontroller.change(nameold,
namenew,
pricenew,
categorynew,
quantitynew)
elif ask_stock == 4:
stockcontroller.show()
else:
break
elif ask_global == 3:
suppliercontroller = controller.SupplierController()
while True:
ask_supplier = int(input('Enter 1 to [register] a supplier: \n'
'Enter 2 to [remove] a supplier: \n'
'Enter 3 to [change] a supplier: \n'
'Enter 4 to [show] suppliers: \n'
'Enter 5 to [exit]: '))
if ask_supplier == 1:
name = input('Enter the supplier you want to register: \n')
cnpj = input('Enter the CNPJ you want to register: \n')
telephone = input('Enter the Telephone number you want to register: \n')
category = input('Enter the category you want to register: \n')
suppliercontroller.register(name,
cnpj,
telephone,
category)
elif ask_supplier == 2:
supplier = input('Enter the supplier you want to remove: \n')
suppliercontroller.remove(supplier)
elif ask_supplier == 3:
nameold = input('Enter the supplier you want to change: \n')
namenew = input('Enter the new supplier you want to register: \n')
cnpjnew = input('Enter the new CNPJ you want to register: \n')
telephonenew = input('Enter the new Telephone you want to register: \n')
categorynew = input('Enter the new category you want to register: \n')
suppliercontroller.change(nameold,
namenew,
cnpjnew,
telephonenew,
categorynew)
elif ask_supplier == 4:
suppliercontroller.show()
else:
break
elif ask_global == 4:
customercontroller = controller.CustomerController()
while True:
ask_customer = int(input('Enter 1 to [register] a customer: \n'
'Enter 2 to [remove] a customer: \n'
'Enter 3 to [change] a customer: \n'
'Enter 4 to [show] customers: \n'
'Enter 5 to [exit]: \n'))
if ask_customer == 1:
name = input('Enter the customer you want to register: \n')
telephone = input('Enter the telephone you want to register: \n')
cpf = input('Enter the CPF you want to register: \n')
email = input('Enter the email you want to register: \n')
address = input('Enter the address you want to register: \n')
customercontroller.register(name,
telephone,
cpf,
email,
address)
elif ask_customer == 2:
name = input('Enter the customer you want to remove: \n')
customercontroller.remove(name)
elif ask_customer == 3:
nameold = input('Enter the customer you want to change: \n')
namenew = input('Enter the new customer you want to change: \n')
telephonenew = input('Enter the telephone you want to change: \n')
cpfnew = input('Enter the new cpf you want to change: \n')
emailnew = input('Enter the new e-mail you want to change: \n')
addressnew = input('Enter the new address you want to change: \n')
customercontroller.change(nameold,
namenew,
telephonenew,
cpfnew,
emailnew,
addressnew)
elif ask_customer == 4:
customercontroller.show()
else:
break
elif ask_global == 5:
employeecontroller = controller.EmployeeController()
while True:
ask_employee = int(input('Enter 1 to [register] a employee: \n'
'Enter 2 to [remove] a employee: \n'
'Enter 3 to [change] a employee: \n'
'Enter 4 to [show] employees: \n'
'Enter 5 to [exit]: \n'))
if ask_employee == 1:
clt = input('Enter the employee CLT: \n')
name = input('Enter a employee name to register: \n')
telephone = input('Enter a Telephone Number to register: \n')
cpf = input('Enter a CPF number to register: \n')
email = input('Enter a e-mail to register: \n')
address = input('Enter the address to register: \n')
employeecontroller.register(clt,
name,
telephone,
cpf,
email,
address)
elif ask_employee == 2:
name = input('Enter the employee you want to remove: \n')
employeecontroller.remove(name)
elif ask_employee == 3:
nameold = input('Enter the employee you want to change: \n')
cltnew = input('Enter the CLT you want to register: \n')
namenew = input('Enter the new name you want to register: \n')
telephonenew = input('Enter the telephone you want to register: \n')
cpfnew = input('Enter the CPF you want to register: \n')
emailnew = input('Enter the e-mail you want to register: \n')
addressnew = input('Enter the address you wanto to register: \n')
employeecontroller.change(nameold,
cltnew,
namenew,
telephonenew,
cpfnew,
emailnew,
addressnew)
elif ask_employee == 4:
employeecontroller.show()
else:
break
elif ask_global == 6:
salescontroller = controller.SalesController()
while True:
ask_sales = int(input('Enter 1 to [register] a new sale: \n'
'Enter 2 to get total sales [report]: \n'
'Enter 3 to get [show] sales by period: \n'
'Enter 4 to [exit]: \n'))
if ask_sales == 1:
nameproduct = input('Enter the product you want to register: \n')
seller = input('Enter the name of the seller: \n')
buyer = input('Enter the name of the buyer: \n')
quantity_sold = input('Enter the quantity sold: \n')
salescontroller.register(nameproduct,
seller,
buyer,
quantity_sold)
elif ask_sales == 2:
salescontroller.report()
elif ask_sales == 3:
startdate = str(input('Enter the start date (D/M/Y): \n'))
enddate = str(input('Enter the end date (D/M/Y): \n'))
salescontroller(startdate, enddate)
else:
break
else:
break