Skip to content

Commit 133a295

Browse files
committed
update user data through employee
1 parent 82b57c9 commit 133a295

File tree

1 file changed

+60
-4
lines changed

1 file changed

+60
-4
lines changed

bank_managment_system/QTFrontend.py

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
EMPLOYEE_WITHDRAW_MONEY_PAGE = 16
2626
EMPLOYEE_CHECK_BALANCE_SEARCH = 17
2727
EMPLOYEE_CHECK_BALANCE_PAGE = 18
28+
EMPLOYEE_UPDATE_ACCOUNT_SEARCH = 19
29+
EMPLOYEE_UPDATE_ACCOUNT_PAGE = 20
2830

2931
FONT_SIZE = QtGui.QFont("Segoe UI", 12)
3032
# -------------------------------------------------------------------------------------------------------------
@@ -606,7 +608,7 @@ def create_employee_menu_page(parent, title):
606608

607609
return page, *buttons # Unpack as add_button, update_employee, etc.
608610

609-
def create_account_page(parent, title):
611+
def create_account_page(parent, title,update_btn=False):
610612
page, main_layout = create_page_with_header(parent, title)
611613

612614
content_frame = create_styled_frame(page)
@@ -675,8 +677,10 @@ def create_account_page(parent, title):
675677
button_frame = create_styled_frame(form_frame, style="padding: 7px;")
676678
button_layout = QtWidgets.QVBoxLayout(button_frame)
677679

678-
679-
submit_button = create_styled_button(button_frame, "Submit", min_size=(100, 50))
680+
if update_btn:
681+
submit_button = create_styled_button(button_frame, "Update", min_size=(100, 50))
682+
else:
683+
submit_button = create_styled_button(button_frame, "Submit", min_size=(100, 50))
680684
button_layout.addWidget(submit_button, 0, QtCore.Qt.AlignHCenter)
681685

682686

@@ -1046,7 +1050,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
10461050
E_add_Balance.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_ADD_BALANCE_SEARCH))
10471051
E_Withdraw_Money.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_WITHDRAW_MONEY_SEARCH))
10481052
E_Chack_Balanace.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CHECK_BALANCE_SEARCH))
1049-
# E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE))
1053+
E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_SEARCH))
10501054
# E_list_of_all_Members.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_LIST_OF_ALL_MEMBERS_PAGE))
10511055
# E_Delete_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_DELETE_ACCOUNT_PAGE))
10521056
# E_Back.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_MENU_PAGE))
@@ -1236,6 +1240,56 @@ def find_and_hide_submit_button(page):
12361240
break
12371241

12381242
find_and_hide_submit_button(check_balance_page)
1243+
1244+
# Update Employee details
1245+
update_empolyee_search_page,update_empolyee_search_other = search_result(stacked_widget, "Update Employee Details", "Enter Employee ID: ")
1246+
update_employee_page,update_employee_other = create_account_page(stacked_widget, "Update Employee", True)
1247+
name_edit = update_employee_other[0]
1248+
Age_edit = update_employee_other[1]
1249+
Address_edit = update_employee_other[2]
1250+
Balance_edit = update_employee_other[3]
1251+
Mobile_number_edit = update_employee_other[4]
1252+
account_type_dropdown = update_employee_other[5]
1253+
# name_edit, Age_edit,Address_edit,Balance_edit,Mobile_number_edit, account_type_dropdown ,submit_button
1254+
1255+
update_empolyee_search_other[1].clicked.connect(lambda:update_employee_search_submit())
1256+
update_employee_other[6].clicked.connect(lambda:update_employee_submit())
1257+
def update_employee_search_submit():
1258+
try:
1259+
user_data = backend.get_details(int(update_empolyee_search_other[0].text().strip()))
1260+
print("Featch data: ",user_data)
1261+
name_edit.setText(str(user_data[1]))
1262+
Age_edit.setText(str(user_data[2]))
1263+
Address_edit.setText(str(user_data[3]))
1264+
Balance_edit.setText(str(user_data[4]))
1265+
Mobile_number_edit.setText(str(user_data[6]))
1266+
Balance_edit.setDisabled(True)
1267+
account_type_dropdown.setCurrentText(str(user_data[5]))
1268+
stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE)
1269+
except ValueError:
1270+
show_popup_message(stacked_widget, "Enter valid numeric employee ID.", EMPLOYEE_MENU_PAGE)
1271+
1272+
def update_employee_submit():
1273+
try:
1274+
user_data = backend.get_details(int(update_empolyee_search_other[0].text().strip()))
1275+
name=name_edit.text().strip()
1276+
age = int(Age_edit.text().strip())
1277+
address = Address_edit.text().strip()
1278+
mobile_number = int(Mobile_number_edit.text().strip())
1279+
account_type = account_type_dropdown.currentText()
1280+
print(name,age,address,mobile_number,account_type)
1281+
backend.update_name_in_bank_table(name,user_data[0])
1282+
backend.update_age_in_bank_table(age,user_data[0])
1283+
backend.update_address_in_bank_table(address,user_data[0])
1284+
backend.update_address_in_bank_table(address,user_data[0])
1285+
backend.update_mobile_number_in_bank_table(mobile_number,user_data[0])
1286+
backend.update_acc_type_in_bank_table(account_type,user_data[0])
1287+
1288+
show_popup_message(stacked_widget, "Employee details updated successfully", EMPLOYEE_MENU_PAGE)
1289+
stacked_widget.setCurrentIndex(EMPLOYEE_MENU_PAGE)
1290+
except ValueError as e:
1291+
print(e)
1292+
show_popup_message(stacked_widget, "Enter valid numeric employee ID.", EMPLOYEE_MENU_PAGE)
12391293

12401294

12411295
stacked_widget.addWidget(home_page)#0
@@ -1257,6 +1311,8 @@ def find_and_hide_submit_button(page):
12571311
stacked_widget.addWidget(withdraw_money_page)#16
12581312
stacked_widget.addWidget(check_balance_search_page)#17
12591313
stacked_widget.addWidget(check_balance_page)#18
1314+
stacked_widget.addWidget(update_empolyee_search_page)#19
1315+
stacked_widget.addWidget(update_employee_page)#20
12601316

12611317

12621318

0 commit comments

Comments
 (0)