-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupplier.py
309 lines (190 loc) · 9.72 KB
/
supplier.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
from tkinter import *
from tkinter import ttk
import datetime
import test3
date_and_time = datetime.date.today()
date1 = str(date_and_time)
def supplier(x, lbl):
global my_tree6
label1 = lbl(x, text="Supplier Record Book")
label1.grid(column=0, row=0)
# add some style
style = ttk.Style()
# pick a theme
style.theme_use('default')
# configure the treeview colors
style.configure("Treeview", background="black", foreground="white", rowheight=25, fieldbackground="grey")
# change selected color
style.map("Treeview", background=[('selected', "green")])
# create a treeview
tree_frame6 = Frame(x)
tree_frame6.grid(padx=10, pady=10, row=1, column=0, rowspan=11)
# create scroll bar
tree_scroll6 = Scrollbar(tree_frame6)
tree_scroll6.pack(side=RIGHT, fill=Y)
# create the treeview
my_tree6 = ttk.Treeview(tree_frame6, yscrollcommand=tree_scroll6.set, selectmode="extended")
my_tree6.pack()
# configure the scroll bar
tree_scroll6.config(command=my_tree6.yview)
# define our columns
my_tree6['columns'] = ("id","date_and_time", "supplier_name", "address", "phone", "pincode")
# format our columns
my_tree6.column("#0", width=0, stretch=NO)
my_tree6.column("id", anchor=CENTER, width=50)
my_tree6.column("date_and_time", anchor=W, width=140)
my_tree6.column("supplier_name", anchor=W, width=140)
my_tree6.column("address", anchor=CENTER, width=100 )
my_tree6.column("phone", anchor=CENTER, width=140)
my_tree6.column("pincode", anchor=CENTER, width=140)
# create Headings
my_tree6.heading("#0", text="", anchor=W)
my_tree6.heading("id", text="ID", anchor=CENTER)
my_tree6.heading("date_and_time", text="Date", anchor=W)
my_tree6.heading("supplier_name", text="Customer Name", anchor=W)
my_tree6.heading("address", text="Address", anchor=CENTER)
my_tree6.heading("phone", text="Phone", anchor=CENTER)
my_tree6.heading("pincode", text="Pincode", anchor=CENTER)
# create striped row tags
my_tree6.tag_configure('oddrow', background="white", foreground="darkgreen")
my_tree6.tag_configure('evenrow', background="white", foreground="darkblue")
def supplier1(lbl, ent, btn, b):
def datetoday():
date2 = datetime.date.today()
date3 = str(date2)
dateentry6.insert(0, date3)
date_label = lbl(b,
text="Execute Above Mentioned Details Here ------------>",
text_font=("Roboto Medium", -16)) # font name and size in px
date_label.grid(row=7, column=0,)
dateentry6 = ent(b,
width=10,
placeholder_text="Date")
dateentry6.grid(row=3, column=0, columnspan=1, pady=0, padx=20, sticky="we")
datetoday()
# date_entry = Entry(data_frame)
# date_entry.grid(row=0, column=1, padx=10, )
name_entry6 = ent(b,
width=10,
placeholder_text="Supplier Name")
name_entry6.grid(row=4, column=0, columnspan=1, pady=0, padx=20, sticky="we")
address_entry6 = ent(b,
width=10,
placeholder_text="Address")
address_entry6.grid(row=5, column=0, columnspan=4, pady=0, padx=20, sticky="we")
phone_entry6 = ent(b,
width=10,
placeholder_text="Phone")
phone_entry6.grid(row=4, column=1, columnspan=1, pady=0, padx=20, sticky="we")
pincode_entry6 = ent(b,
width=10,
placeholder_text="Pincode")
pincode_entry6.grid(row=4, column=2, columnspan=1, pady=0, padx=20, sticky="we")
# functions
test3.dbconnectsup()
class supplier_handling:
def select_record(self, e):
# clear box
dateentry6.delete(0, END)
name_entry6.delete(0, END)
address_entry6.delete(0, END)
phone_entry6.delete(0, END)
pincode_entry6.delete(0, END)
# Grab record number
selected = my_tree6.focus()
values = my_tree6.item(selected, "values")
#output entrybox
dateentry6.insert(0, values[1])
name_entry6.insert(0, values[2])
address_entry6.insert(0, values[3])
phone_entry6.insert(0, values[4])
pincode_entry6.insert(0, values[5])
#output listbox
# mylb.insert(1, values[2])
# mylb.insert(2, values[3])
def clearentrybox(self):
# clear box
dateentry6.delete(0, END)
name_entry6.delete(0, END)
address_entry6.delete(0, END)
phone_entry6.delete(0, END)
pincode_entry6.delete(0, END)
datetoday()
def entering(self):
# try:
test3.dbentrysup(dateentry6.get(), name_entry6.get(), address_entry6.get(), phone_entry6.get(), pincode_entry6.get())
my_tree6.delete(*my_tree6.get_children())
record6.fetching()
dateentry6.delete(0, END)
name_entry6.delete(0, END)
address_entry6.delete(0, END)
phone_entry6.delete(0, END)
pincode_entry6.delete(0, END)
# except:
# mylb.insert(0, "Boxes Cannot be Blank")
datetoday()
def deleting(self):
selected = my_tree6.focus()
values = my_tree6.item(selected, "values")
test3.dbdeletesup(values[0])
my_tree6.delete(*my_tree6.get_children())
record6.fetching()
dateentry6.delete(0, END)
name_entry6.delete(0, END)
address_entry6.delete(0, END)
phone_entry6.delete(0, END)
pincode_entry6.delete(0, END)
datetoday()
def updating(self):
selected = my_tree6.focus()
values = my_tree6.item(selected, "values")
test3.dbupdatesup(dateentry6.get(), name_entry6.get(), address_entry6.get(), phone_entry6.get(), pincode_entry6.get(), values[0])
my_tree6.delete(*my_tree6.get_children())
record6.fetching()
dateentry6.delete(0, END)
name_entry6.delete(0, END)
address_entry6.delete(0, END)
phone_entry6.delete(0, END)
pincode_entry6.delete(0, END)
datetoday()
def fetching(self):
data = test3.dbfetchsup()
count = 0
for i in data:
if count % 2 == 0:
my_tree6.insert(parent="", index="end", iid=count, text="", values=(i[0], i[1], i[2], i[3], i[4], i[5]), tags=("evenrow",))
else:
my_tree6.insert(parent="", index="end", iid=count, text="", values=(i[0], i[1], i[2], i[3], i[4], i[5]), tags=("oddrow",))
# increment counter
count += 1
record6 = supplier_handling()
# bind
my_tree6.bind("<ButtonRelease-1>", record6.select_record)
# buttons
add_button6 = btn(b,
text="Add",
border_width=2, # <- custom border_width
fg_color=None, # <- no fg_color
command=record6.entering)
add_button6.grid(row=7, column=2, padx=10)
del_button6 = btn(b,
text="Remove",
border_width=2, # <- custom border_width
fg_color=None, # <- no fg_color
command=record6.deleting)
del_button6.grid(row=7, column=3, padx=10)
update_button6 = btn(b,
text="Update",
border_width=2, # <- custom border_width
fg_color=None, # <- no fg_color
command=record6.updating)
update_button6.grid(row=7, column=4, padx=10)
clear_button6 = btn(b,
text="Clear Boxes",
border_width=2, # <- custom border_width
fg_color=None, # <- no fg_color
command=record6.clearentrybox)
clear_button6.grid(row=7, column=5, padx=10)
# show_button = Button(data_frame, text="Show", width=10, command=record1.fetching)
# show_button.grid(row=5, column=5, padx=10)
record6.fetching()