-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEMS.py
182 lines (153 loc) · 7.13 KB
/
EMS.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
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
from db import Database
import subprocess
db = Database("Employee.db")
root = Tk()
root.title("Restaurant Worker Management")
root.geometry("1270x690+0+0")
root.config(bg="pink")
name = StringVar()
age = StringVar()
doj = StringVar()
gender = StringVar()
email = StringVar()
contact = StringVar()
# Entries Frame
entries_frame = Frame(root, bg="pink")
entries_frame.pack(side=TOP, fill=X)
title = Label(entries_frame, text="Restaurant Worker Management", font=("Calibri", 18, "bold"), bg="pink", fg="black")
title.grid(row=0, columnspan=2, padx=10, pady=20, sticky="w")
lblName = Label(entries_frame, text="Name", font=("Calibri", 16), bg="pink", fg="black")
lblName.grid(row=1, column=0, padx=10, pady=10, sticky="w")
txtName = Entry(entries_frame, textvariable=name, font=("Calibri", 16), width=30)
txtName.grid(row=1, column=1, padx=10, pady=10, sticky="w")
lblAge = Label(entries_frame, text="Age", font=("Calibri", 16), bg="pink", fg="black")
lblAge.grid(row=1, column=2, padx=10, pady=10, sticky="w")
txtAge = Entry(entries_frame, textvariable=age, font=("Calibri", 16), width=30)
txtAge.grid(row=1, column=3, padx=10, pady=10, sticky="w")
lbldoj = Label(entries_frame, text="Date of Joining", font=("Calibri", 16), bg="pink", fg="black")
lbldoj.grid(row=2, column=0, padx=10, pady=10, sticky="w")
txtDoj = Entry(entries_frame, textvariable=doj, font=("Calibri", 16), width=30)
txtDoj.grid(row=2, column=1, padx=10, pady=10, sticky="w")
lblEmail = Label(entries_frame, text="Shift", font=("Calibri", 16), bg="pink", fg="black")
lblEmail.grid(row=2, column=2, padx=10, pady=10, sticky="w")
comboShift = ttk.Combobox(entries_frame, font=("Calibri", 16), width=28, textvariable=email, state="readonly")
comboShift['values'] = (" 9 AM-12 PM", " 12 PM-3 PM"," 3 PM-6 PM"," 6 PM-9 PM")
comboShift.grid(row=2, column=3, padx=10, sticky="w")
lblGender = Label(entries_frame, text="Gender", font=("Calibri", 16), bg="pink", fg="black")
lblGender.grid(row=3, column=0, padx=10, pady=10, sticky="w")
comboGender = ttk.Combobox(entries_frame, font=("Calibri", 16), width=28, textvariable=gender, state="readonly")
comboGender['values'] = ("Male", "Female")
comboGender.grid(row=3, column=1, padx=10, sticky="w")
lblContact = Label(entries_frame, text="Contact No", font=("Calibri", 16), bg="pink", fg="black")
lblContact.grid(row=3, column=2, padx=10, pady=10, sticky="w")
txtContact = Entry(entries_frame, textvariable=contact, font=("Calibri", 16), width=30)
txtContact.grid(row=3, column=3, padx=10, sticky="w")
lblAddress = Label(entries_frame, text="Address", font=("Calibri", 16), bg="pink", fg="black")
lblAddress.grid(row=4, column=0, padx=10, pady=10, sticky="w")
txtAddress = Text(entries_frame, width=85, height=4, font=("Calibri", 16))
txtAddress.grid(row=5, column=0, columnspan=4, padx=10, sticky="w")
def getData(event):
selected_row = tv.focus()
data = tv.item(selected_row)
global row
row = data["values"]
#print(row)
name.set(row[1])
age.set(row[2])
doj.set(row[3])
email.set(row[4])
gender.set(row[5])
contact.set(row[6])
txtAddress.delete(1.0, END)
txtAddress.insert(END, row[7])
def dispalyAll():
tv.delete(*tv.get_children())
for row in db.fetch():
tv.insert("", END, values=row)
def add_employee():
if txtName.get() == "" or txtAge.get() == "" or txtDoj.get() == "" or comboShift.get() == "" or comboGender.get() == "" or txtContact.get() == "" or txtAddress.get(
1.0, END) == "":
messagebox.showerror("Erorr in Input", "Please Fill All the Details")
return
db.insert(txtName.get(),txtAge.get(), txtDoj.get() , comboShift.get() ,comboGender.get(), txtContact.get(), txtAddress.get(
1.0, END))
messagebox.showinfo("Success", "Record Inserted")
clearAll()
dispalyAll()
def update_employee():
if txtName.get() == "" or txtAge.get() == "" or txtDoj.get() == "" or comboShift.get() == "" or comboGender.get() == "" or txtContact.get() == "" or txtAddress.get(
1.0, END) == "":
messagebox.showerror("Erorr in Input", "Please Fill All the Details")
return
db.update(row[0],txtName.get(), txtAge.get(), txtDoj.get(), comboShift.get(), comboGender.get(), txtContact.get(),
txtAddress.get(
1.0, END))
messagebox.showinfo("Success", "Record Update")
clearAll()
dispalyAll()
def delete_employee():
db.remove(row[0])
clearAll()
dispalyAll()
def clearAll():
name.set("")
age.set("")
doj.set("")
gender.set("")
email.set("")
contact.set("")
txtAddress.delete(1.0, END)
def logOut():
root.withdraw()
subprocess.run(["python", "main.py"])
def order():
root.withdraw()
subprocess.run(["python", "resorder.py"])
btn_frame = Frame(entries_frame, bg="pink")
btn_frame.grid(row=6, column=0, columnspan=4, padx=10, pady=10, sticky="w")
btnAdd = Button(btn_frame, command=add_employee, text="Add Worker", width=15, font=("Calibri", 16, "bold"), fg="black",
bg="#16a085", bd=0).grid(row=0, column=0)
btnEdit = Button(btn_frame, command=update_employee, text="Update Details", width=15, font=("Calibri", 16, "bold"),
fg="black", bg="#2980b9",
bd=0).grid(row=0, column=1, padx=10)
btnDelete = Button(btn_frame, command=delete_employee, text="Delete Worker", width=15, font=("Calibri", 16, "bold"),
fg="black", bg="#c0392b",
bd=0).grid(row=0, column=2, padx=10)
btnClear = Button(btn_frame, command=clearAll, text="Clear Details", width=15, font=("Calibri", 16, "bold"), fg="black",
bg="#f39c12",
bd=0).grid(row=0, column=3, padx=10)
btnBack = Button(btn_frame, command=logOut, text="Log Out", width=15, font=("Calibri", 16, "bold"), fg="black",
bg="light green",
bd=0).grid(row=0, column=4, padx=10)
btnOrder = Button(btn_frame, command=order, text="Order History", width=15, font=("Calibri", 16, "bold"), fg="black",
bg="light green",
bd=0).grid(row=0, column=5, padx=10)
# Table Frame
tree_frame = Frame(root, bg="#ecf0f1")
tree_frame.place(x=10, y=450, width=1250, height=520)
style = ttk.Style()
style.configure("mystyle.Treeview", font=('Calibri', 18),
rowheight=50) # Modify the font of the body
style.configure("mystyle.Treeview.Heading", font=('Calibri', 18)) # Modify the font of the headings
tv = ttk.Treeview(tree_frame, columns=(1, 2, 3, 4, 5, 6, 7), style="mystyle.Treeview")
tv.heading("1", text="ID")
tv.column("1", width=5)
tv.heading("2", text="Name")
tv.heading("3", text="Age")
tv.column("3", width=5)
tv.heading("4", text="D.O.J")
tv.column("4", width=5)
tv.heading("5", text="Shift")
tv.column("5", width=5)
tv.heading("6", text="Gender")
tv.column("6", width=5)
tv.heading("7", text="Contact")
tv.column("7", width=5)
tv['show'] = 'headings'
tv.bind("<ButtonRelease-1>", getData)
tv.pack(fill=X)
dispalyAll()
root.mainloop()