MCPcopy Index your code
hub / github.com/geekcomputers/Python / on_search_button_clicked

Function on_search_button_clicked

bank_managment_system/QTFrontend.py:289–320  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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(
319 parent, "Error", f"An error occurred: {str(e)}"
320 )
321
322 search_button.clicked.connect(on_search_button_clicked)
323

Callers

nothing calls this directly

Calls 2

warningMethod · 0.80
check_name_in_staffMethod · 0.80

Tested by

no test coverage detected