21
21
EMPLOYEE_SHOW_DETAILS_PAGE2 = 12
22
22
EMPLOYEE_ADD_BALANCE_SEARCH = 13
23
23
EMPLOYEE_ADD_BALANCE_PAGE = 14
24
+ EMPLOYEE_WITHDRAW_MONEY_SEARCH = 15
25
+ EMPLOYEE_WITHDRAW_MONEY_PAGE = 16
24
26
25
27
FONT_SIZE = QtGui .QFont ("Segoe UI" , 12 )
26
28
# -------------------------------------------------------------------------------------------------------------
@@ -773,7 +775,7 @@ def create_show_details_page2(parent, title):
773
775
774
776
return page ,(account_no_field ,name_field ,age_field ,address_field ,balance_field ,mobile_number_field ,account_type_field ,exite_btn )
775
777
776
- def update_user_balance (parent , title ):
778
+ def update_user (parent , title , input_fields_label ):
777
779
page , main_layout = create_page_with_header (parent , title )
778
780
content_frame = create_styled_frame (page )
779
781
content_frame .setSizePolicy (QtWidgets .QSizePolicy .Preferred , QtWidgets .QSizePolicy .Expanding )
@@ -786,7 +788,7 @@ def update_user_balance(parent, title):
786
788
# Define input fields
787
789
user = create_input_field (form_frame , "User Name: " , min_label_size = (180 , 0 ))
788
790
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 ))
790
792
791
793
# Add input fields to the form layout
792
794
form_layout .addWidget (user [0 ])
@@ -816,6 +818,7 @@ def update_user_balance(parent, title):
816
818
main_layout .addWidget (content_frame )
817
819
818
820
return page ,(user_account_name ,user_balance_field ,user_update_balance_field ,submit_button )
821
+
819
822
# -------------------------------------------------------------------------------------------------------------
820
823
# === Main Window Setup ===
821
824
# -------------------------------------------------------------------------------------------------------------
@@ -1017,7 +1020,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
1017
1020
E_Create_Account .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_CREATE_ACCOUNT_PAGE ))
1018
1021
E_Show_Details .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_SHOW_DETAILS_PAGE1 ))
1019
1022
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 ))
1021
1024
# E_Chack_Balanace.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CHECK_BALANCE_PAGE))
1022
1025
# E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE))
1023
1026
# 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):
1102
1105
stacked_widget .setCurrentIndex (EMPLOYEE_SHOW_DETAILS_PAGE2 )
1103
1106
else :
1104
1107
show_popup_message (stacked_widget , "Account not found" , EMPLOYEE_SHOW_DETAILS_PAGE1 )
1105
-
1108
+
1109
+ # Add balance page
1106
1110
add_balance_search_page ,add_balance_search_other = search_result (stacked_widget , "Add Balance" ,"Enter Account Number: " )
1107
1111
add_balance_search_other [1 ].clicked .connect (lambda : add_balance_page_submit_btn (int (add_balance_search_other [0 ].text ().strip ())))
1108
1112
1109
1113
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: " )
1111
1115
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
1113
1116
1114
1117
1115
1118
def add_balance_page_submit_btn (account_number :int ):
@@ -1131,6 +1134,35 @@ def update_user_account_balance(add_money:int):
1131
1134
show_popup_message (stacked_widget , "Balance updated successfully" , EMPLOYEE_MENU_PAGE )
1132
1135
add_balance_search_other [0 ].setText ("" )
1133
1136
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
+
1134
1166
stacked_widget .addWidget (home_page )#0
1135
1167
stacked_widget .addWidget (admin_page )#1
1136
1168
stacked_widget .addWidget (employee_page )#2
@@ -1146,14 +1178,16 @@ def update_user_account_balance(add_money:int):
1146
1178
stacked_widget .addWidget (show_bank_user_data_page2 )#12
1147
1179
stacked_widget .addWidget (add_balance_search_page )#13
1148
1180
stacked_widget .addWidget (add_balance_page )#14
1181
+ stacked_widget .addWidget (withdraw_money_search_page )#15
1182
+ stacked_widget .addWidget (withdraw_money_page )#16
1149
1183
1150
1184
1151
1185
1152
1186
main_layout .addWidget (stacked_widget )
1153
1187
main_window .setCentralWidget (central_widget )
1154
1188
1155
1189
# Set initial page
1156
- stacked_widget .setCurrentIndex (0 )
1190
+ stacked_widget .setCurrentIndex (9 )
1157
1191
1158
1192
return stacked_widget , {
1159
1193
"admin_name" : admin_name ,
0 commit comments