-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathEditController.py
50 lines (43 loc) · 1.52 KB
/
EditController.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
from tkinter import messagebox
from models.Customers import Customers
from core.Controller import Controller
"""
Responsible for EditView behavior.
"""
class EditController(Controller):
#-----------------------------------------------------------------------
# Constructor
#-----------------------------------------------------------------------
def __init__(self):
self.editView = self.loadView("edit")
self.customers = Customers()
#-----------------------------------------------------------------------
# Methods
#-----------------------------------------------------------------------
"""
@Override
"""
def main(self, customer, showView):
self.showView = showView
self.customer = customer
self.editView.main()
"""
@return Customer being edited
"""
def getCustomer(self):
return self.customer
"""
Saves customer edited
@param fields Customer data edited
"""
def btnSave(self, fields):
response = self.customers.update(fields)
self.showView.attributes("-topmost", False)
if response > 0:
messagebox.showinfo("Update customer", "Customer updated with success!")
else:
messagebox.showerror("Update customer", "Error while updating")
self.showView.attributes("-topmost", True)
self.showView.update()
self.editView.close()
self.showView.attributes("-topmost", False)