Skip to content

Commit da00681

Browse files
committed
add withdraw_money_page page working
1 parent 799cedb commit da00681

File tree

1 file changed

+41
-7
lines changed

1 file changed

+41
-7
lines changed

bank_managment_system/QTFrontend.py

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
EMPLOYEE_SHOW_DETAILS_PAGE2 = 12
2222
EMPLOYEE_ADD_BALANCE_SEARCH = 13
2323
EMPLOYEE_ADD_BALANCE_PAGE = 14
24+
EMPLOYEE_WITHDRAW_MONEY_SEARCH = 15
25+
EMPLOYEE_WITHDRAW_MONEY_PAGE = 16
2426

2527
FONT_SIZE = QtGui.QFont("Segoe UI", 12)
2628
# -------------------------------------------------------------------------------------------------------------
@@ -773,7 +775,7 @@ def create_show_details_page2(parent, title):
773775

774776
return page,(account_no_field,name_field,age_field,address_field,balance_field,mobile_number_field,account_type_field,exite_btn)
775777

776-
def update_user_balance(parent, title):
778+
def update_user(parent, title,input_fields_label):
777779
page, main_layout = create_page_with_header(parent, title)
778780
content_frame = create_styled_frame(page)
779781
content_frame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
@@ -786,7 +788,7 @@ def update_user_balance(parent, title):
786788
# Define input fields
787789
user = create_input_field(form_frame, "User Name: ", min_label_size=(180, 0))
788790
user_balance = create_input_field(form_frame, "Balance: ", min_label_size=(180, 0))
789-
user_update_balance = create_input_field_V(form_frame, "Add amount: ", min_label_size=(180, 0))
791+
user_update_balance = create_input_field_V(form_frame, input_fields_label, min_label_size=(180, 0))
790792

791793
# Add input fields to the form layout
792794
form_layout.addWidget(user[0])
@@ -816,6 +818,7 @@ def update_user_balance(parent, title):
816818
main_layout.addWidget(content_frame)
817819

818820
return page,(user_account_name,user_balance_field,user_update_balance_field,submit_button)
821+
819822
# -------------------------------------------------------------------------------------------------------------
820823
# === Main Window Setup ===
821824
# -------------------------------------------------------------------------------------------------------------
@@ -1017,7 +1020,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
10171020
E_Create_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CREATE_ACCOUNT_PAGE))
10181021
E_Show_Details.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_SHOW_DETAILS_PAGE1))
10191022
E_add_Balance.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_ADD_BALANCE_SEARCH))
1020-
# E_Withdraw_Money.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_WITHDRAW_MONEY_PAGE))
1023+
E_Withdraw_Money.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_WITHDRAW_MONEY_SEARCH))
10211024
# E_Chack_Balanace.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CHECK_BALANCE_PAGE))
10221025
# E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE))
10231026
# E_list_of_all_Members.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_LIST_OF_ALL_MEMBERS_PAGE))
@@ -1102,14 +1105,14 @@ def show_bank_user_data_page1_submit_btn(name:int):
11021105
stacked_widget.setCurrentIndex(EMPLOYEE_SHOW_DETAILS_PAGE2)
11031106
else:
11041107
show_popup_message(stacked_widget, "Account not found", EMPLOYEE_SHOW_DETAILS_PAGE1)
1105-
1108+
1109+
# Add balance page
11061110
add_balance_search_page,add_balance_search_other = search_result(stacked_widget, "Add Balance","Enter Account Number: ")
11071111
add_balance_search_other[1].clicked.connect(lambda: add_balance_page_submit_btn(int(add_balance_search_other[0].text().strip())))
11081112

11091113

1110-
add_balance_page,add_balance_other =update_user_balance(stacked_widget, "Add Balance User Account")
1114+
add_balance_page,add_balance_other =update_user(stacked_widget, "Add Balance User Account","Enter Ammount: ")
11111115
add_balance_other[3].clicked.connect(lambda:update_user_account_balance(add_balance_other[2].text().strip()))
1112-
# user_account_name,user_balance_field,user_update_balance_field,submit_button
11131116

11141117

11151118
def add_balance_page_submit_btn(account_number:int):
@@ -1131,6 +1134,35 @@ def update_user_account_balance(add_money:int):
11311134
show_popup_message(stacked_widget, "Balance updated successfully", EMPLOYEE_MENU_PAGE)
11321135
add_balance_search_other[0].setText("")
11331136

1137+
# Withdraw money page
1138+
withdraw_money_search_page,withdraw_money_search_other = search_result(stacked_widget, "Withdraw Money","Enter Account Number: ")
1139+
withdraw_money_search_other[1].clicked.connect(lambda: withdraw_money_page_submit_btn(int(withdraw_money_search_other[0].text().strip())))
1140+
1141+
1142+
withdraw_money_page,withdraw_money_other =update_user(stacked_widget, "Withdraw Money From User Account","Withdraw Amount: ")
1143+
withdraw_money_other[3].clicked.connect(lambda:update_user_account_withdraw(withdraw_money_other[2].text().strip()))
1144+
1145+
def withdraw_money_page_submit_btn(account_number:int):
1146+
print(account_number)
1147+
check = backend.check_acc_no(account_number)
1148+
print(check)
1149+
if check:
1150+
account_data = backend.get_details(account_number)
1151+
withdraw_money_other[0].setText(str(account_data[1]))
1152+
withdraw_money_other[1].setText(str(account_data[4]))
1153+
stacked_widget.setCurrentIndex(16)
1154+
return account_data
1155+
else:
1156+
show_popup_message(stacked_widget, "Account not found", EMPLOYEE_WITHDRAW_MONEY_SEARCH,show_cancel=True,cancel_page=EMPLOYEE_MENU_PAGE)
1157+
1158+
def update_user_account_withdraw(withdraw_money:int):
1159+
account_number=int(withdraw_money_search_other[0].text().strip())
1160+
backend.deduct_balance(int(withdraw_money),int(account_number))
1161+
withdraw_money_other[0].setText("")
1162+
withdraw_money_other[1].setText("")
1163+
show_popup_message(stacked_widget, "Balance updated successfully", EMPLOYEE_MENU_PAGE)
1164+
withdraw_money_search_other[0].setText("")
1165+
11341166
stacked_widget.addWidget(home_page)#0
11351167
stacked_widget.addWidget(admin_page)#1
11361168
stacked_widget.addWidget(employee_page)#2
@@ -1146,14 +1178,16 @@ def update_user_account_balance(add_money:int):
11461178
stacked_widget.addWidget(show_bank_user_data_page2)#12
11471179
stacked_widget.addWidget(add_balance_search_page)#13
11481180
stacked_widget.addWidget(add_balance_page)#14
1181+
stacked_widget.addWidget(withdraw_money_search_page)#15
1182+
stacked_widget.addWidget(withdraw_money_page)#16
11491183

11501184

11511185

11521186
main_layout.addWidget(stacked_widget)
11531187
main_window.setCentralWidget(central_widget)
11541188

11551189
# Set initial page
1156-
stacked_widget.setCurrentIndex(0)
1190+
stacked_widget.setCurrentIndex(9)
11571191

11581192
return stacked_widget, {
11591193
"admin_name": admin_name,

0 commit comments

Comments
 (0)