Skip to content

Commit edc215d

Browse files
committed
show employee list part done
1 parent 2c6de93 commit edc215d

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

bank_managment_system/QTFrontend.py

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,86 @@ def create_add_employee_page(parent, title, submit_text="Submit",update_btn:bool
382382
return page, name_edit, password_edit, salary_edit, position_edit, update_button
383383
else:
384384
return page, name_edit, password_edit, salary_edit, position_edit, submit_button # Unpack as name_edit, password_edit, etc.
385+
386+
def show_employee_list_page(parent, title):
387+
page, main_layout = create_page_with_header(parent, title)
388+
389+
content_frame = create_styled_frame(page, style="background-color: #f9f9f9; border-radius: 10px; padding: 15px;")
390+
content_frame.setSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
391+
content_layout = QtWidgets.QVBoxLayout(content_frame)
392+
393+
# Table frame
394+
table_frame = create_styled_frame(content_frame, style="background-color: #ffffff; border-radius: 8px; padding: 10px;")
395+
table_layout = QtWidgets.QVBoxLayout(table_frame)
396+
table_layout.setSpacing(0)
397+
398+
# Header row
399+
header_frame = create_styled_frame(table_frame, style="background-color: #f5f5f5; ; border-radius: 8px 8px 0 0; padding: 10px;")
400+
header_layout = QtWidgets.QHBoxLayout(header_frame)
401+
header_layout.setContentsMargins(10, 5, 10, 5)
402+
headers = ["Name", "Position", "Salary"]
403+
for i, header in enumerate(headers):
404+
header_label = QtWidgets.QLabel(header, header_frame)
405+
header_label.setStyleSheet("font-weight: bold; font-size: 14px; color: #333333; padding: 0px; margin: 0px;")
406+
if i == 2: # Right-align salary header
407+
header_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
408+
else:
409+
header_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
410+
header_layout.addWidget(header_label, 1 if i < 2 else 0) # Stretch name and position, not salary
411+
table_layout.addWidget(header_frame)
412+
413+
# Employee rows
414+
employees = backend.show_employees_for_update()
415+
for row, employee in enumerate(employees):
416+
row_frame = create_styled_frame(table_frame, style=f"background-color: {'#fafafa' if row % 2 else '#ffffff'}; padding: 8px;")
417+
row_layout = QtWidgets.QHBoxLayout(row_frame)
418+
row_layout.setContentsMargins(10, 5, 10, 5)
419+
420+
# Name
421+
name_label = QtWidgets.QLabel(employee[0], row_frame)
422+
name_label.setStyleSheet("font-size: 14px; color: #333333; padding: 0px; margin: 0px;")
423+
name_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
424+
row_layout.addWidget(name_label, 1)
425+
426+
# Position
427+
position_label = QtWidgets.QLabel(employee[3], row_frame)
428+
position_label.setStyleSheet("font-size: 14px; color: #333333; padding: 0px; margin: 0px;")
429+
position_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
430+
row_layout.addWidget(position_label, 1)
431+
432+
# Salary (formatted as currency)
433+
salary_label = QtWidgets.QLabel(f"${float(employee[2]):,.2f}", row_frame)
434+
salary_label.setStyleSheet("font-size: 14px; color: #333333; padding: 0px; margin: 0px;")
435+
salary_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
436+
row_layout.addWidget(salary_label, 0)
437+
438+
table_layout.addWidget(row_frame)
439+
440+
# Add stretch to prevent rows from expanding vertically
441+
table_layout.addStretch()
442+
443+
# Back button
444+
back_button = QtWidgets.QPushButton("Back", content_frame)
445+
back_button.setStyleSheet("""
446+
QPushButton {
447+
background-color: #6c757d;
448+
color: white;
449+
border: none;
450+
border-radius: 4px;
451+
padding: 8px 16px;
452+
font-size: 14px;
453+
}
454+
QPushButton:hover {
455+
background-color: #5a6268;
456+
}
457+
""")
458+
back_button.clicked.connect(lambda: parent.setCurrentIndex(3))
459+
460+
content_layout.addWidget(table_frame)
461+
main_layout.addWidget(back_button, alignment=QtCore.Qt.AlignLeft)
462+
main_layout.addWidget(content_frame)
463+
464+
return page
385465

386466
def setup_main_window(main_window):
387467
"""Set up the main window with a stacked widget containing home, admin, and employee pages."""

0 commit comments

Comments
 (0)