19
19
EMPLOYEE_CREATE_ACCOUNT_PAGE = 10
20
20
EMPLOYEE_SHOW_DETAILS_PAGE1 = 11
21
21
EMPLOYEE_SHOW_DETAILS_PAGE2 = 12
22
+ EMPLOYEE_ADD_BALANCE_SEARCH = 13
23
+ EMPLOYEE_ADD_BALANCE_PAGE = 14
24
+
25
+ FONT_SIZE = QtGui .QFont ("Segoe UI" , 12 )
22
26
# -------------------------------------------------------------------------------------------------------------
23
27
# === Reusable UI Component Functions ===
24
28
# -------------------------------------------------------------------------------------------------------------
@@ -83,7 +87,25 @@ def create_input_field(parent, label_text, min_label_size=(120, 0)):
83
87
label .setMinimumSize (QtCore .QSize (* min_label_size ))
84
88
85
89
line_edit = QtWidgets .QLineEdit (frame )
86
- line_edit .setStyleSheet ("background-color: rgb(168, 168, 168);" )
90
+ line_edit .setStyleSheet ("background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
91
+
92
+ layout .addWidget (label )
93
+ layout .addWidget (line_edit )
94
+ return frame , line_edit
95
+
96
+ def create_input_field_V (parent , label_text , min_label_size = (120 , 0 )):
97
+ """Create a horizontal layout with a label and a QLineEdit."""
98
+ frame = create_styled_frame (parent , style = "padding: 7px;" )
99
+ layout = QtWidgets .QVBoxLayout (frame )
100
+ layout .setContentsMargins (0 , 0 , 0 , 0 )
101
+ layout .setSpacing (0 )
102
+
103
+ label = create_styled_label (frame , label_text , font_size = 12 , bold = True , style = "color: #2c3e50;" )
104
+ if min_label_size :
105
+ label .setMinimumSize (QtCore .QSize (* min_label_size ))
106
+
107
+ line_edit = QtWidgets .QLineEdit (frame )
108
+ line_edit .setStyleSheet ("background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
87
109
88
110
layout .addWidget (label )
89
111
layout .addWidget (line_edit )
@@ -152,6 +174,28 @@ def on_reject():
152
174
button_box .rejected .connect (on_reject )
153
175
154
176
dialog .exec_ ()
177
+
178
+ def search_result (parent , title ,label_text ):
179
+ page , main_layout = create_page_with_header (parent , title )
180
+ content_frame = create_styled_frame (page )
181
+ content_frame .setSizePolicy (QtWidgets .QSizePolicy .Preferred , QtWidgets .QSizePolicy .Expanding )
182
+ content_layout = QtWidgets .QVBoxLayout (content_frame )
183
+ content_layout .alignment
184
+
185
+ form_frame = create_styled_frame (content_frame , min_size = (400 , 200 ), style = "background-color: #ffffff; border-radius: 15px; padding: 10px;" )
186
+ form_layout = QtWidgets .QVBoxLayout (form_frame )
187
+ form_layout .setSpacing (3 )
188
+ # Define input fields
189
+ user = create_input_field (form_frame , label_text , min_label_size = (180 , 0 ))
190
+ form_layout .addWidget (user [0 ])
191
+ user_account_number = user [1 ]
192
+ user_account_number .setFont (QtGui .QFont ("Segoe UI" , 12 ))
193
+ submit_button = create_styled_button (form_frame , "Submit" , min_size = (100 , 50 ))
194
+ form_layout .addWidget (submit_button )
195
+ content_layout .addWidget (form_frame , 0 , QtCore .Qt .AlignHCenter | QtCore .Qt .AlignVCenter )
196
+ main_layout .addWidget (content_frame )
197
+
198
+ return page ,(user_account_number ,submit_button )
155
199
# -------------------------------------------------------------------------------------------------------------
156
200
# === Page Creation Functions ==
157
201
# -------------------------------------------------------------------------------------------------------------
@@ -727,6 +771,49 @@ def create_show_details_page2(parent, title):
727
771
728
772
return page ,(account_no_field ,name_field ,age_field ,address_field ,balance_field ,mobile_number_field ,account_type_field ,exite_btn )
729
773
774
+ def update_user_balance (parent , title ):
775
+ page , main_layout = create_page_with_header (parent , title )
776
+ content_frame = create_styled_frame (page )
777
+ content_frame .setSizePolicy (QtWidgets .QSizePolicy .Preferred , QtWidgets .QSizePolicy .Expanding )
778
+ content_layout = QtWidgets .QVBoxLayout (content_frame )
779
+ content_layout .alignment
780
+
781
+ form_frame = create_styled_frame (content_frame , min_size = (400 , 200 ), style = "background-color: #ffffff; border-radius: 15px; padding: 10px;" )
782
+ form_layout = QtWidgets .QVBoxLayout (form_frame )
783
+ form_layout .setSpacing (3 )
784
+ # Define input fields
785
+ user = create_input_field (form_frame , "User Name: " , min_label_size = (180 , 0 ))
786
+ user_balance = create_input_field (form_frame , "Balance: " , min_label_size = (180 , 0 ))
787
+ user_update_balance = create_input_field_V (form_frame , "Add amount: " , min_label_size = (180 , 0 ))
788
+
789
+ # Add input fields to the form layout
790
+ form_layout .addWidget (user [0 ])
791
+ form_layout .addWidget (user_balance [0 ])
792
+ form_layout .addWidget (user_update_balance [0 ])
793
+
794
+ # Store the input fields in variables
795
+ user_account_name = user [1 ]
796
+ user_account_name .setReadOnly (True )
797
+ user_account_name .setStyleSheet ("background-color: #8a8a8a; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
798
+ user_balance_field = user_balance [1 ]
799
+ user_balance_field .setReadOnly (True )
800
+ user_balance_field .setStyleSheet ("background-color: #8a8a8a; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
801
+ user_update_balance_field = user_update_balance [1 ]
802
+ user_update_balance_field .setStyleSheet ("background-color: #f0f0f0; border: 1px solid #ccc; border-radius: 4px; padding: 8px;" )
803
+
804
+
805
+ # Set the font size for the input fields
806
+ user_account_name .setFont (QtGui .QFont ("Segoe UI" , 12 ))
807
+ user_balance_field .setFont (QtGui .QFont ("Segoe UI" , 12 ))
808
+ user_update_balance_field .setFont (QtGui .QFont ("Segoe UI" , 12 ))
809
+
810
+ # Add a submit button
811
+ submit_button = create_styled_button (form_frame , "Submit" , min_size = (100 , 50 ))
812
+ form_layout .addWidget (submit_button )
813
+ content_layout .addWidget (form_frame , 0 , QtCore .Qt .AlignHCenter | QtCore .Qt .AlignVCenter )
814
+ main_layout .addWidget (content_frame )
815
+
816
+ return page ,(user_account_name ,user_balance_field ,user_update_balance_field ,submit_button )
730
817
# -------------------------------------------------------------------------------------------------------------
731
818
# === Main Window Setup ===
732
819
# -------------------------------------------------------------------------------------------------------------
@@ -927,7 +1014,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
927
1014
# List of all page
928
1015
E_Create_Account .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_CREATE_ACCOUNT_PAGE ))
929
1016
E_Show_Details .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_SHOW_DETAILS_PAGE1 ))
930
- # E_add_Balance.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_ADD_BALANCE_PAGE ))
1017
+ E_add_Balance .clicked .connect (lambda : stacked_widget .setCurrentIndex (EMPLOYEE_ADD_BALANCE_SEARCH ))
931
1018
# E_Withdraw_Money.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_WITHDRAW_MONEY_PAGE))
932
1019
# E_Chack_Balanace.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CHECK_BALANCE_PAGE))
933
1020
# E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE))
@@ -1014,9 +1101,34 @@ def show_bank_user_data_page1_submit_btn(name:int):
1014
1101
else :
1015
1102
show_popup_message (stacked_widget , "Account not found" , EMPLOYEE_SHOW_DETAILS_PAGE1 )
1016
1103
1104
+ add_balance_search_page ,add_balance_search_other = search_result (stacked_widget , "Add Balance" ,"Enter Account Number: " )
1105
+ add_balance_search_other [1 ].clicked .connect (lambda : add_balance_page_submit_btn (int (add_balance_search_other [0 ].text ().strip ())))
1017
1106
1018
1107
1019
-
1108
+ add_balance_page ,add_balance_other = update_user_balance (stacked_widget , "Add Balance User Account" )
1109
+ add_balance_other [3 ].clicked .connect (lambda :update_user_account_balance (add_balance_other [2 ].text ().strip ()))
1110
+ # user_account_name,user_balance_field,user_update_balance_field,submit_button
1111
+
1112
+
1113
+ def add_balance_page_submit_btn (account_number :int ):
1114
+ check = backend .check_acc_no (account_number )
1115
+ if check :
1116
+ account_data = backend .get_details (account_number )
1117
+ add_balance_other [0 ].setText (str (account_data [1 ]))
1118
+ add_balance_other [1 ].setText (str (account_data [4 ]))
1119
+ stacked_widget .setCurrentIndex (14 )
1120
+ return account_data
1121
+ else :
1122
+ show_popup_message (stacked_widget , "Account not found" , EMPLOYEE_ADD_BALANCE_SEARCH ,show_cancel = True ,cancel_page = EMPLOYEE_MENU_PAGE )
1123
+
1124
+ def update_user_account_balance (add_money :int ):
1125
+ account_number = int (add_balance_search_other [0 ].text ().strip ())
1126
+ backend .update_balance (add_money ,account_number )
1127
+ add_balance_other [0 ].setText ("" )
1128
+ add_balance_other [1 ].setText ("" )
1129
+ show_popup_message (stacked_widget , "Balance updated successfully" , EMPLOYEE_MENU_PAGE )
1130
+ add_balance_search_other [0 ].setText ("" )
1131
+
1020
1132
stacked_widget .addWidget (home_page )#0
1021
1133
stacked_widget .addWidget (admin_page )#1
1022
1134
stacked_widget .addWidget (employee_page )#2
@@ -1030,14 +1142,16 @@ def show_bank_user_data_page1_submit_btn(name:int):
1030
1142
stacked_widget .addWidget (employee_create_account_page )#10
1031
1143
stacked_widget .addWidget (show_bank_user_data_page1 )#11
1032
1144
stacked_widget .addWidget (show_bank_user_data_page2 )#12
1145
+ stacked_widget .addWidget (add_balance_search_page )#13
1146
+ stacked_widget .addWidget (add_balance_page )#14
1033
1147
1034
1148
1035
1149
1036
1150
main_layout .addWidget (stacked_widget )
1037
1151
main_window .setCentralWidget (central_widget )
1038
1152
1039
1153
# Set initial page
1040
- stacked_widget .setCurrentIndex (11 )
1154
+ stacked_widget .setCurrentIndex (13 )
1041
1155
1042
1156
return stacked_widget , {
1043
1157
"admin_name" : admin_name ,
0 commit comments