MCPcopy Create free account
hub / github.com/geekcomputers/Python / get_employee_name

Function get_employee_name

bank_managment_system/QTFrontend.py:261–326  ·  view source on GitHub ↗
(parent, name_field_text="Enter Employee Name")

Source from the content-addressed store, hash-verified

259
260
261def get_employee_name(parent, name_field_text="Enter Employee Name"):
262 page, main_layout = create_page_with_header(parent, "Employee Data Update")
263
264 # Content frame
265 content_frame = create_styled_frame(page)
266 content_frame.setSizePolicy(
267 QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding
268 )
269 content_layout = QtWidgets.QVBoxLayout(content_frame)
270
271 # Form frame
272 form_frame = create_styled_frame(
273 content_frame,
274 min_size=(340, 200),
275 style="background-color: #ffffff; border-radius: 15px; padding: 10px;",
276 )
277 form_layout = QtWidgets.QVBoxLayout(form_frame)
278
279 # Form fields
280 name_label, name_field = create_input_field(form_frame, name_field_text)
281 search_button = create_styled_button(form_frame, "Search", min_size=(100, 30))
282 form_layout.addWidget(name_label)
283 form_layout.addWidget(search_button)
284 content_layout.addWidget(
285 form_frame, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter
286 )
287 main_layout.addWidget(content_frame)
288
289 def on_search_button_clicked():
290 global employee_data
291 entered_name = name_field.text().strip()
292 print(f"Entered Name: {entered_name}")
293 if not entered_name:
294 QtWidgets.QMessageBox.warning(
295 parent, "Input Error", "Please enter an employee name."
296 )
297 return
298
299 try:
300 employee_check = backend.check_name_in_staff(entered_name)
301 print(f"Employee Check: {type(employee_check)},{employee_check}")
302 if employee_check:
303 cur = backend.cur
304 cur.execute("SELECT * FROM staff WHERE name = ?", (entered_name,))
305 employee_data = cur.fetchone()
306 print(f"Employee Data: {employee_data}")
307 parent.setCurrentIndex(UPDATE_EMPLOYEE_PAGE2)
308
309 # if employee_data:
310 # QtWidgets.QMessageBox.information(parent, "Employee Found",
311 # f"Employee data:\nID: {fetch[0]}\nName: {fetch[1]}\nDept: {fetch[2]}\nRole: {fetch[3]}")
312
313 else:
314 QtWidgets.QMessageBox.information(
315 parent, "Not Found", "Employee not found."
316 )
317 except Exception as e:
318 QtWidgets.QMessageBox.critical(

Callers 1

setup_main_windowFunction · 0.85

Calls 4

create_page_with_headerFunction · 0.85
create_styled_frameFunction · 0.85
create_input_fieldFunction · 0.85
create_styled_buttonFunction · 0.85

Tested by

no test coverage detected