Skip to content

Commit e0257c5

Browse files
committed
create bank account page done
1 parent 0b07b93 commit e0257c5

File tree

1 file changed

+152
-4
lines changed

1 file changed

+152
-4
lines changed

bank_managment_system/QTFrontend.py

Lines changed: 152 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ def show_total_money(parent, title):
525525
content_layout.addWidget(back_button, alignment=QtCore.Qt.AlignCenter)
526526
main_layout.addWidget(content_frame)
527527
return page
528-
528+
529+
#-----------employees menu pages-----------
529530
def create_employee_menu_page(parent, title):
530531
page, main_layout = create_page_with_header(parent, title)
531532

@@ -550,7 +551,101 @@ def create_employee_menu_page(parent, title):
550551
main_layout.addWidget(button_frame)
551552

552553
return page, *buttons # Unpack as add_button, update_employee, etc.
554+
555+
def create_account_page(parent, title):
556+
page, main_layout = create_page_with_header(parent, title)
557+
558+
content_frame = create_styled_frame(page)
559+
content_frame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
560+
content_layout = QtWidgets.QVBoxLayout(content_frame)
561+
562+
form_frame = create_styled_frame(content_frame, min_size=(400, 200), style="background-color: #ffffff; border-radius: 15px; padding: 10px;")
563+
form_layout = QtWidgets.QVBoxLayout(form_frame)
564+
form_layout.setSpacing(3)
565+
566+
# Define input fields
567+
fields = ["Name :", "Age :", "Address","Balance :", "Mobile number :"]
568+
edits = []
569+
570+
for i, field in enumerate(fields):
571+
field_frame, field_edit = create_input_field(form_frame, field,min_label_size=(160, 0))
572+
form_layout.addWidget(field_frame)
573+
if i == 0:
574+
name_edit = field_edit
575+
elif i == 1:
576+
Age_edit = field_edit
577+
elif i == 2:
578+
Address_edit = field_edit
579+
elif i == 3:
580+
Balance_edit = field_edit
581+
elif i == 4:
582+
Mobile_number_edit = field_edit
583+
edits.append(field_edit)
584+
# Dropdown for account type
585+
account_type_label = QtWidgets.QLabel("Account Type :", form_frame)
586+
account_type_label.setStyleSheet("font-size: 14px; font-weight: bold; color: #333333;")
587+
form_layout.addWidget(account_type_label)
588+
account_type_dropdown = QtWidgets.QComboBox(form_frame)
589+
account_type_dropdown.addItems(["Savings", "Current", "Fixed Deposit"])
590+
account_type_dropdown.setStyleSheet("""
591+
QComboBox {
592+
padding: 5px;
593+
border: 1px solid #ccc;
594+
border-radius: 4px;
595+
background-color: white;
596+
min-width: 200px;
597+
font-size: 14px;
598+
}
599+
QComboBox:hover {
600+
border: 1px solid #999;
601+
}
602+
QComboBox::drop-down {
603+
border: none;
604+
width: 25px;
605+
}
606+
QComboBox::down-arrow {
607+
width: 12px;
608+
height: 12px;
609+
}
610+
QComboBox QAbstractItemView {
611+
border: 1px solid #ccc;
612+
background-color: white;
613+
selection-background-color: #0078d4;
614+
selection-color: white;
615+
}
616+
""")
617+
form_layout.addWidget(account_type_dropdown)
618+
619+
# Submit button
620+
button_frame = create_styled_frame(form_frame, style="padding: 7px;")
621+
button_layout = QtWidgets.QVBoxLayout(button_frame)
622+
623+
624+
submit_button = create_styled_button(button_frame, "Submit", min_size=(100, 50))
625+
button_layout.addWidget(submit_button, 0, QtCore.Qt.AlignHCenter)
553626

627+
628+
form_layout.addWidget(button_frame)
629+
content_layout.addWidget(form_frame, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
630+
main_layout.addWidget(content_frame)
631+
back_btn = QtWidgets.QPushButton("Back", content_frame)
632+
back_btn.setStyleSheet("""
633+
QPushButton {
634+
background-color: #6c757d;
635+
color: white;
636+
border: none;
637+
border-radius: 4px;
638+
padding: 8px 16px;
639+
font-size: 14px;
640+
}
641+
QPushButton:hover {
642+
background-color: #5a6268;
643+
}
644+
""")
645+
back_btn.clicked.connect(lambda: parent.setCurrentIndex(ADMIN_MENU_PAGE))
646+
main_layout.addWidget(back_btn, 0,alignment=QtCore.Qt.AlignLeft)
647+
648+
return page,( name_edit, Age_edit,Address_edit,Balance_edit,Mobile_number_edit, account_type_dropdown ,submit_button)
554649
# -------------------------------------------------------------------------------------------------------------
555650
# === Main Window Setup ===
556651
# -------------------------------------------------------------------------------------------------------------
@@ -746,10 +841,10 @@ def update_employee_data(name, password, salary, position, name_to_update):
746841
stacked_widget,
747842
title="Employee Login"
748843
)
749-
844+
employee_submit.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_MENU_PAGE))
750845
employee_menu_page, E_Create_Account, E_Show_Details, E_add_Balance, E_Withdraw_Money, E_Chack_Balanace, E_Update_Account, E_list_of_all_Members, E_Delete_Account, E_Back= create_employee_menu_page(stacked_widget,"Employee Menu")
751846
# List of all page
752-
# E_Create_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CREATE_ACCOUNT_PAGE))
847+
E_Create_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_CREATE_ACCOUNT_PAGE))
753848
# E_Show_Details.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_SHOW_DETAILS_PAGE))
754849
# E_add_Balance.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_ADD_BALANCE_PAGE))
755850
# E_Withdraw_Money.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_WITHDRAW_MONEY_PAGE))
@@ -759,7 +854,59 @@ def update_employee_data(name, password, salary, position, name_to_update):
759854
# E_Delete_Account.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_DELETE_ACCOUNT_PAGE))
760855
# E_Back.clicked.connect(lambda: stacked_widget.setCurrentIndex(EMPLOYEE_MENU_PAGE))
761856

762-
# Add pages to stacked widget
857+
employee_create_account_page,all_employee_menu_btn = create_account_page(stacked_widget, "Create Account")
858+
submit_button = all_employee_menu_btn[6].clicked.connect(lambda: add_account_form_submit(
859+
all_employee_menu_btn[0].text().strip(),
860+
all_employee_menu_btn[1].text().strip(),
861+
all_employee_menu_btn[2].text().strip(),
862+
all_employee_menu_btn[3].text().strip(),
863+
all_employee_menu_btn[5].currentText(),
864+
all_employee_menu_btn[4].text().strip()
865+
))
866+
867+
def add_account_form_submit(name, age, address, balance, account_type, mobile):
868+
if (
869+
len(name) != 0
870+
and len(age) != 0
871+
and len(address) != 0
872+
and len(balance) != 0
873+
and len(account_type) != 0
874+
and len(mobile) != 0
875+
):
876+
try:
877+
balance = int(balance)
878+
except ValueError:
879+
show_popup_message(stacked_widget, "Balance must be a valid number", EMPLOYEE_CREATE_ACCOUNT_PAGE)
880+
return
881+
if balance < 0:
882+
show_popup_message(stacked_widget, "Balance cannot be negative",EMPLOYEE_CREATE_ACCOUNT_PAGE)
883+
return
884+
if account_type not in ["Savings", "Current","Fixed Deposit"]:
885+
show_popup_message(stacked_widget, "Invalid account type", EMPLOYEE_CREATE_ACCOUNT_PAGE)
886+
return
887+
if len(mobile) != 10:
888+
show_popup_message(stacked_widget, "Mobile number must be 10 digits", EMPLOYEE_CREATE_ACCOUNT_PAGE)
889+
return
890+
if not mobile.isdigit():
891+
show_popup_message(stacked_widget, "Mobile number must contain only digits", EMPLOYEE_CREATE_ACCOUNT_PAGE)
892+
return
893+
if not name.isalpha():
894+
show_popup_message(stacked_widget, "Name must contain only alphabets", EMPLOYEE_CREATE_ACCOUNT_PAGE)
895+
return
896+
if not age.isdigit():
897+
show_popup_message(stacked_widget, "Age must contain only digits", EMPLOYEE_CREATE_ACCOUNT_PAGE)
898+
return
899+
if int(age) < 18:
900+
show_popup_message(stacked_widget, "Age must be greater than 18", EMPLOYEE_CREATE_ACCOUNT_PAGE)
901+
return
902+
if len(address) < 10:
903+
show_popup_message(stacked_widget, "Address must be at least 10 characters long", EMPLOYEE_CREATE_ACCOUNT_PAGE)
904+
return
905+
backend.create_customer(name, age, address, balance, account_type, mobile)
906+
show_popup_message(stacked_widget, "Account created successfully", EMPLOYEE_MENU_PAGE, False)
907+
else:
908+
show_popup_message(stacked_widget, "Please fill in all fields", EMPLOYEE_CREATE_ACCOUNT_PAGE)
909+
# Add pages to stacked widget
763910
stacked_widget.addWidget(home_page)#0
764911
stacked_widget.addWidget(admin_page)#1
765912
stacked_widget.addWidget(employee_page)#2
@@ -770,6 +917,7 @@ def update_employee_data(name, password, salary, position, name_to_update):
770917
stacked_widget.addWidget(employee_list_page)#7
771918
stacked_widget.addWidget(admin_total_money)#8
772919
stacked_widget.addWidget(employee_menu_page)#9
920+
stacked_widget.addWidget(employee_create_account_page)#10
773921

774922

775923

0 commit comments

Comments
 (0)