Skip to content

Commit 83e00b4

Browse files
committed
check balance page added
1 parent 57452c5 commit 83e00b4

File tree

1 file changed

+65
-12
lines changed

1 file changed

+65
-12
lines changed

bank_managment_system/QTFrontend.py

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
EMPLOYEE_ADD_BALANCE_PAGE = 14
2424
EMPLOYEE_WITHDRAW_MONEY_SEARCH = 15
2525
EMPLOYEE_WITHDRAW_MONEY_PAGE = 16
26+
EMPLOYEE_CHECK_BALANCE_SEARCH = 17
27+
EMPLOYEE_CHECK_BALANCE_PAGE = 18
2628

2729
FONT_SIZE = QtGui.QFont("Segoe UI", 12)
2830
# -------------------------------------------------------------------------------------------------------------
@@ -775,7 +777,7 @@ def create_show_details_page2(parent, title):
775777

776778
return page,(account_no_field,name_field,age_field,address_field,balance_field,mobile_number_field,account_type_field,exite_btn)
777779

778-
def update_user(parent, title,input_fields_label):
780+
def update_user(parent, title,input_fields_label,input_fielf:bool=True):
779781
page, main_layout = create_page_with_header(parent, title)
780782
content_frame = create_styled_frame(page)
781783
content_frame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
@@ -788,12 +790,14 @@ def update_user(parent, title,input_fields_label):
788790
# Define input fields
789791
user = create_input_field(form_frame, "User Name: ", min_label_size=(180, 0))
790792
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+
792794

793795
# Add input fields to the form layout
794796
form_layout.addWidget(user[0])
795797
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])
797801

798802
# Store the input fields in variables
799803
user_account_name= user[1]
@@ -802,22 +806,42 @@ def update_user(parent, title,input_fields_label):
802806
user_balance_field = user_balance[1]
803807
user_balance_field.setReadOnly(True)
804808
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;")
807812

808813

809814
# Set the font size for the input fields
810815
user_account_name.setFont(FONT_SIZE)
811816
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)
813819

814820
# Add a submit button
815821
submit_button = create_styled_button(form_frame, "Submit", min_size=(100, 50))
816822
form_layout.addWidget(submit_button)
817823
content_layout.addWidget(form_frame, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
818824
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)
821845

822846
# -------------------------------------------------------------------------------------------------------------
823847
# === Main Window Setup ===
@@ -1021,7 +1045,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
10211045
E_Show_Details.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_SHOW_DETAILS_PAGE1))
10221046
E_add_Balance.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_ADD_BALANCE_SEARCH))
10231047
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))
10251049
# E_Update_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_UPDATE_ACCOUNT_PAGE))
10261050
# E_list_of_all_Members.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_LIST_OF_ALL_MEMBERS_PAGE))
10271051
# E_Delete_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_DELETE_ACCOUNT_PAGE))
@@ -1116,16 +1140,20 @@ def setup_balance_operation_flow(
11161140
backend_action_fn,
11171141
stacked_page_index,
11181142
search_index,
1119-
page_index
1143+
page_index,
1144+
need_input=True
11201145
):
11211146
# Create search UI
11221147
search_page, search_widgets = search_result(stacked_widget, title_search, placeholder)
11231148
search_input = search_widgets[0]
11241149
search_button = search_widgets[1]
11251150

11261151
# 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
11291157

11301158
def on_search_submit():
11311159
try:
@@ -1186,7 +1214,30 @@ def on_action_submit():
11861214
page_index=EMPLOYEE_WITHDRAW_MONEY_PAGE,
11871215
)
11881216

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)
11891239

1240+
11901241
stacked_widget.addWidget(home_page)#0
11911242
stacked_widget.addWidget(admin_page)#1
11921243
stacked_widget.addWidget(employee_page)#2
@@ -1204,6 +1255,8 @@ def on_action_submit():
12041255
stacked_widget.addWidget(add_balance_page)#14
12051256
stacked_widget.addWidget(withdraw_money_search_page)#15
12061257
stacked_widget.addWidget(withdraw_money_page)#16
1258+
stacked_widget.addWidget(check_balance_search_page)#17
1259+
stacked_widget.addWidget(check_balance_page)#18
12071260

12081261

12091262

0 commit comments

Comments
 (0)