23
23
EMPLOYEE_ADD_BALANCE_PAGE = 14
24
24
EMPLOYEE_WITHDRAW_MONEY_SEARCH = 15
25
25
EMPLOYEE_WITHDRAW_MONEY_PAGE = 16
26
+ EMPLOYEE_CHECK_BALANCE_SEARCH = 17
27
+ EMPLOYEE_CHECK_BALANCE_PAGE = 18
26
28
27
29
FONT_SIZE = QtGui .QFont ("Segoe UI" , 12 )
28
30
# -------------------------------------------------------------------------------------------------------------
@@ -775,7 +777,7 @@ def create_show_details_page2(parent, title):
775
777
776
778
return page ,(account_no_field ,name_field ,age_field ,address_field ,balance_field ,mobile_number_field ,account_type_field ,exite_btn )
777
779
778
- def update_user (parent , title ,input_fields_label ):
780
+ def update_user (parent , title ,input_fields_label , input_fielf : bool = True ):
779
781
page , main_layout = create_page_with_header (parent , title )
780
782
content_frame = create_styled_frame (page )
781
783
content_frame .setSizePolicy (QtWidgets .QSizePolicy .Preferred , QtWidgets .QSizePolicy .Expanding )
@@ -788,12 +790,14 @@ def update_user(parent, title,input_fields_label):
788
790
# Define input fields
789
791
user = create_input_field (form_frame , "User Name: " , min_label_size = (180 , 0 ))
790
792
user_balance = create_input_field (form_frame , "Balance: " , min_label_size = (180 , 0 ))
791
- user_update_balance = create_input_field_V ( form_frame , input_fields_label , min_label_size = ( 180 , 0 ))
793
+
792
794
793
795
# Add input fields to the form layout
794
796
form_layout .addWidget (user [0 ])
795
797
form_layout .addWidget (user_balance [0 ])
796
- form_layout .addWidget (user_update_balance [0 ])
798
+ if input_fielf :
799
+ user_update_balance = create_input_field_V (form_frame , input_fields_label , min_label_size = (180 , 0 ))
800
+ form_layout .addWidget (user_update_balance [0 ])
797
801
798
802
# Store the input fields in variables
799
803
user_account_name = user [1 ]
@@ -802,22 +806,42 @@ def update_user(parent, title,input_fields_label):
802
806
user_balance_field = user_balance [1 ]
803
807
user_balance_field .setReadOnly (True )
804
808
user_balance_field .setStyleSheet ("background-color: #8a8a8a; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
805
- user_update_balance_field = user_update_balance [1 ]
806
- user_update_balance_field .setStyleSheet ("background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
809
+ if input_fielf :
810
+ user_update_balance_field = user_update_balance [1 ]
811
+ user_update_balance_field .setStyleSheet ("background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
807
812
808
813
809
814
# Set the font size for the input fields
810
815
user_account_name .setFont (FONT_SIZE )
811
816
user_balance_field .setFont (FONT_SIZE )
812
- user_update_balance_field .setFont (FONT_SIZE )
817
+ if input_fielf :
818
+ user_update_balance_field .setFont (FONT_SIZE )
813
819
814
820
# Add a submit button
815
821
submit_button = create_styled_button (form_frame , "Submit" , min_size = (100 , 50 ))
816
822
form_layout .addWidget (submit_button )
817
823
content_layout .addWidget (form_frame , 0 , QtCore .Qt .AlignHCenter | QtCore .Qt .AlignVCenter )
818
824
main_layout .addWidget (content_frame )
819
-
820
- return page ,(user_account_name ,user_balance_field ,user_update_balance_field ,submit_button )
825
+ back_btn = create_styled_button (content_frame , "Back" , min_size = (100 , 50 ))
826
+ back_btn .setStyleSheet ("""
827
+ QPushButton {
828
+ background-color: #6c757d;
829
+ color: white;
830
+ border: none;
831
+ border-radius: 4px;
832
+ padding: 8px 16px;
833
+ font-size: 14px;
834
+ }
835
+ QPushButton:hover {
836
+ background-color: #5a6268;
837
+ }
838
+ """ )
839
+ back_btn .clicked .connect (lambda : parent .setCurrentIndex (EMPLOYEE_MENU_PAGE ))
840
+ backend
841
+ if input_fielf :
842
+ return page ,(user_account_name ,user_balance_field ,user_update_balance_field ,submit_button )
843
+ else :
844
+ return page ,(user_account_name ,user_balance_field ,submit_button )
821
845
822
846
# -------------------------------------------------------------------------------------------------------------
823
847
# === Main Window Setup ===
@@ -1021,7 +1045,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
1021
1045
E_Show_Details .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_SHOW_DETAILS_PAGE1 ))
1022
1046
E_add_Balance .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_ADD_BALANCE_SEARCH ))
1023
1047
E_Withdraw_Money .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_WITHDRAW_MONEY_SEARCH ))
1024
- # E_Chack_Balanace.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CHECK_BALANCE_PAGE ))
1048
+ E_Chack_Balanace .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_CHECK_BALANCE_SEARCH ))
1025
1049
# E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE))
1026
1050
# E_list_of_all_Members.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_LIST_OF_ALL_MEMBERS_PAGE))
1027
1051
# E_Delete_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_DELETE_ACCOUNT_PAGE))
@@ -1116,16 +1140,20 @@ def setup_balance_operation_flow(
1116
1140
backend_action_fn ,
1117
1141
stacked_page_index ,
1118
1142
search_index ,
1119
- page_index
1143
+ page_index ,
1144
+ need_input = True
1120
1145
):
1121
1146
# Create search UI
1122
1147
search_page , search_widgets = search_result (stacked_widget , title_search , placeholder )
1123
1148
search_input = search_widgets [0 ]
1124
1149
search_button = search_widgets [1 ]
1125
1150
1126
1151
# Create update UI
1127
- form_page , form_widgets = update_user (stacked_widget , title_form , action_button_text )
1128
- name_field , balance_field , amount_field , action_button = form_widgets
1152
+ form_page , form_widgets = update_user (stacked_widget , title_form , action_button_text ,need_input )
1153
+ if need_input :
1154
+ name_field , balance_field , amount_field , action_button = form_widgets
1155
+ else :
1156
+ name_field , balance_field , action_button = form_widgets
1129
1157
1130
1158
def on_search_submit ():
1131
1159
try :
@@ -1186,7 +1214,30 @@ def on_action_submit():
1186
1214
page_index = EMPLOYEE_WITHDRAW_MONEY_PAGE ,
1187
1215
)
1188
1216
1217
+ check_balance_search_page , check_balance_page = setup_balance_operation_flow (
1218
+ stacked_widget = stacked_widget ,
1219
+ title_search = "Check Balance" ,
1220
+ placeholder = "Enter Account Number: " ,
1221
+ title_form = "Check Balance" ,
1222
+ action_button_text = "Check Balance: " ,
1223
+ success_message = "Balance checked successfully" ,
1224
+ backend_action_fn = backend .check_balance ,
1225
+ stacked_page_index = EMPLOYEE_CHECK_BALANCE_SEARCH ,
1226
+ search_index = EMPLOYEE_CHECK_BALANCE_SEARCH ,
1227
+ page_index = EMPLOYEE_CHECK_BALANCE_PAGE ,
1228
+ need_input = False
1229
+ )
1230
+ def find_and_hide_submit_button (page ):
1231
+ # Find all QPushButton widgets in the page
1232
+ buttons = page .findChildren (QtWidgets .QPushButton )
1233
+ for button in buttons :
1234
+ if button .text () == "Submit" :
1235
+ button .hide ()
1236
+ break
1237
+
1238
+ find_and_hide_submit_button (check_balance_page )
1189
1239
1240
+
1190
1241
stacked_widget .addWidget (home_page )#0
1191
1242
stacked_widget .addWidget (admin_page )#1
1192
1243
stacked_widget .addWidget (employee_page )#2
@@ -1204,6 +1255,8 @@ def on_action_submit():
1204
1255
stacked_widget .addWidget (add_balance_page )#14
1205
1256
stacked_widget .addWidget (withdraw_money_search_page )#15
1206
1257
stacked_widget .addWidget (withdraw_money_page )#16
1258
+ stacked_widget .addWidget (check_balance_search_page )#17
1259
+ stacked_widget .addWidget (check_balance_page )#18
1207
1260
1208
1261
1209
1262
0 commit comments