diff --git a/Emoji Dictionary/QT_GUI.py b/Emoji Dictionary/QT_GUI.py new file mode 100644 index 00000000000..a4dd819ccb8 --- /dev/null +++ b/Emoji Dictionary/QT_GUI.py @@ -0,0 +1,82 @@ + +# -*- coding: utf-8 -*- + +import sys +from PyQt5.QtCore import * +from PyQt5.QtGui import * +from PyQt5.QtWidgets import * +from PyQt5 import uic +from emoji import demojize +import os + +class MainWindow(QMainWindow): + def __init__(self): + super(MainWindow, self).__init__() + + # Load the UI file + uic.loadUi(os.path.join(os.path.dirname(__file__),'QT_GUI.ui'),self) + self.pushButton_4.clicked.connect(self.close) + self.pushButton_2.clicked.connect(lambda:search_emoji()) + self.pushButton_3.clicked.connect(lambda:clear_text()) + cells = [ + + ["๐Ÿ’", "๐Ÿ•", "๐ŸŽ", "๐Ÿช", "๐Ÿ", "๐Ÿ˜", "๐Ÿฆ˜", "๐Ÿฆˆ", "๐Ÿ“", "๐Ÿ", "๐Ÿ‘€", "๐Ÿฆด", "๐Ÿ‘ฉ๐Ÿฟ", "โ€๐Ÿค", "๐Ÿง‘", "๐Ÿพ", "๐Ÿ‘ฑ๐Ÿฝ", "โ€โ™€", "๐ŸŽž", "๐ŸŽจ", "โšฝ"], + ["๐Ÿ•", "๐Ÿ—", "๐Ÿœ", "โ˜•", "๐Ÿด", "๐Ÿ‰", "๐Ÿ“", "๐ŸŒด", "๐ŸŒต", "๐Ÿ›บ", "๐Ÿšฒ", "๐Ÿ›ด", "๐Ÿš‰", "๐Ÿš€", "โœˆ", "๐Ÿ›ฐ", "๐Ÿšฆ", "๐Ÿณ", "โ€๐ŸŒˆ", "๐ŸŒŽ", "๐Ÿงญ"], + ["๐Ÿ”ฅ", "โ„", "๐ŸŒŸ", "๐ŸŒž", "๐ŸŒ›", "๐ŸŒ", "๐ŸŒง", "๐Ÿงบ", "๐Ÿงท", "๐Ÿช’", "โ›ฒ", "๐Ÿ—ผ", "๐Ÿ•Œ", "๐Ÿ‘", "โ€๐Ÿ—จ", "๐Ÿ’ฌ", "โ„ข", "๐Ÿ’ฏ", "๐Ÿ”•", "๐Ÿ’ฅ", "โค"], + ["๐Ÿ˜€", "๐Ÿฅฐ", "๐Ÿ˜ด", "๐Ÿค“", "๐Ÿคฎ", "๐Ÿคฌ", "๐Ÿ˜จ", "๐Ÿค‘", "๐Ÿ˜ซ", "๐Ÿ˜Ž"], + ] + def emoji_wight_btn(): + if self.emoji_widget.isVisible(): + self.emoji_widget.hide() + else: + self.emoji_widget.show() + + def search_emoji(): + word = self.lineEdit.text() + print(f"Field Text: {word}") + if word == "": + self.textEdit.setText("You have entered no emoji.") + else: + means = demojize(word) + self.textEdit.setText("Meaning of Emoji : " + str(word) + "\n\n" + means.replace("::", ":\n: ")) + + def add_input_emoji(emoji): + self.lineEdit.setText(self.lineEdit.text() + emoji) + + def clear_text(): + self.lineEdit.setText("") + self.textEdit.setText("") + + self.emoji_buttons = [] + self.emoji_layout = QGridLayout() + self.emoji_widget = QWidget() + self.emoji_widget.setLayout(self.emoji_layout) + self.frame_2.layout().addWidget(self.emoji_widget) + self.emoji_widget.hide() + self.pushButton.clicked.connect(lambda:emoji_wight_btn()) + + + for row_idx, row in enumerate(cells): + for col_idx, emoji in enumerate(row): + button = QPushButton(emoji) + button.setFixedSize(40, 40) + button.setFont(QFont("Arial", 20)) + button.setStyleSheet(""" + QPushButton { + background-color: #ffffff; + border: 1px solid #e0e0e0; + border-radius: 5px; + } + QPushButton:hover { + background-color: #f0f0f0; + } + """) + button.clicked.connect(lambda checked, e=emoji: add_input_emoji(e)) + self.emoji_layout.addWidget(button, row_idx, col_idx) + self.emoji_buttons.append(button) + +if __name__ == '__main__': + app = QApplication(sys.argv) + window = MainWindow() + window.show() + sys.exit(app.exec_()) diff --git a/Emoji Dictionary/QT_GUI.ui b/Emoji Dictionary/QT_GUI.ui new file mode 100644 index 00000000000..49267698e80 --- /dev/null +++ b/Emoji Dictionary/QT_GUI.ui @@ -0,0 +1,411 @@ + + + MainWindow + + + + 0 + 0 + 944 + 638 + + + + MainWindow + + + background-color: #f0f2f5; + + + + background-color: transparent; + + + + 8 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + background-color: #ffffff; + border-radius: 10px; + padding: 15px; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 30 + + + + color: #1a73e8; + padding: 10px; + + + EMOJI DICTIONARY + + + Qt::AlignCenter + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + background-color: transparent; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 20 + + + + color: #333333; + padding: 10px; + + + Enter any Emoji you want to search... + + + + + + + background-color: #ffffff; + border-radius: 8px; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 14 + 50 + false + + + + QLineEdit { + border: 1px solid #dcdcdc; + border-radius: 5px; + padding: 8px; + font-size: 14px; + background-color: #fafafa; + } + QLineEdit:focus { + border-color: #1a73e8; + background-color: #ffffff; + } + + + + + + + + + + true + + + + 14 + 62 + true + + + + QPushButton { + background-color: #1a73e8; + color: white; + border-radius: 5px; + padding: 8px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #1557b0; + } + QPushButton:pressed { + background-color: #104080; + } + + + Emoji Board + + + + + + + + + + background-color: transparent; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 14 + 62 + true + + + + QPushButton { + background-color: #34c759; + color: white; + border-radius: 5px; + padding: 8px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #2ea44f; + } + QPushButton:pressed { + background-color: #26833b; + } + + + ๐Ÿ” Search + + + + + + + + 14 + 62 + true + + + + QPushButton { + background-color: #ff3b30; + color: white; + border-radius: 5px; + padding: 8px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #cc2f27; + } + QPushButton:pressed { + background-color: #99231f; + } + + + ๐Ÿงน Clear + + + + + + + + + + + + + + 0 + 0 + + + + background-color: #ffffff; + border-radius: 10px; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 16 + 50 + false + + + + color: #333333; + padding-bottom: 10px; + + + Meaning... + + + + + + + + 14 + + + + + +QTextEdit { + border: 1px solid #dcdcdc; + border-radius: 5px; + padding: 10px; + font-size: 14px; + background-color: #fafafa; + } + QTextEdit:focus { + border-color: #1a73e8; + background-color: #ffffff; + } + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:14px; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:7.8pt;"><br /></p></body></html> + + + + + + + + 140 + 40 + + + + + 14 + 62 + true + + + + QPushButton { + background-color: #ff9500; + color: white; + border-radius: 5px; + padding: 10px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #cc7700; + } + QPushButton:pressed { + background-color: #995900; + } + + + EXIT + + + + + + + + + + + + diff --git a/Emoji Dictionary/untitled.ui b/Emoji Dictionary/untitled.ui new file mode 100644 index 00000000000..a6753b7dd19 --- /dev/null +++ b/Emoji Dictionary/untitled.ui @@ -0,0 +1,406 @@ + + + MainWindow + + + + 0 + 0 + 948 + 527 + + + + MainWindow + + + background-color: #f0f2f5; + + + + background-color: transparent; + + + + 8 + + + 10 + + + 10 + + + 10 + + + 10 + + + + + background-color: #ffffff; + border-radius: 10px; + padding: 15px; + box-shadow: 0 2px 4px rgba(0,0,0,0.1); + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 30 + + + + color: #1a73e8; + padding: 10px; + + + EMOJI DICTIONARY + + + Qt::AlignCenter + + + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + background-color: transparent; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 20 + + + + color: #333333; + padding: 10px; + + + Enter any Emoji you want to search... + + + + + + + background-color: #ffffff; +border-radius: 8px; + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + -1 + + + + QLineEdit { + border: 1px solid #dcdcdc; + border-radius: 5px; + padding: 8px; + font-size: 14px; + background-color: #fafafa; + } + QLineEdit:focus { + border-color: #1a73e8; + background-color: #ffffff; + } + + + + + + + true + + + + -1 + 62 + true + + + + QPushButton { + background-color: #1a73e8; + color: white; + border-radius: 5px; + padding: 8px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #1557b0; + } + QPushButton:pressed { + background-color: #104080; + } + + + Emoji Board + + + + + + + + + + background-color: transparent; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + -1 + 62 + true + + + + QPushButton { + background-color: #34c759; + color: white; + border-radius: 5px; + padding: 8px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #2ea44f; + } + QPushButton:pressed { + background-color: #26833b; + } + + + ๐Ÿ” Search + + + + + + + + -1 + 62 + true + + + + QPushButton { + background-color: #ff3b30; + color: white; + border-radius: 5px; + padding: 8px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #cc2f27; + } + QPushButton:pressed { + background-color: #99231f; + } + + + ๐Ÿงน Clear + + + + + + + + + + + + + + 0 + 0 + + + + background-color: #ffffff; + border-radius: 10px; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 16 + 50 + false + + + + color: #333333; +padding-bottom: 10px; + + + Meaning... + + + + + + + + -1 + + + + QTextEdit { + border: 1px solid #dcdcdc; + border-radius: 5px; + padding: 10px; + font-size: 14px; + background-color: #fafafa; + } + QTextEdit:focus { + border-color: #1a73e8; + background-color: #ffffff; + } + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:14px; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:20pt;"><br /></p></body></html> + + + + + + + + 140 + 40 + + + + + -1 + 62 + true + + + + QPushButton { + background-color: #ff9500; + color: white; + border-radius: 5px; + padding: 10px; + font-size: 14px; + font-weight: 500; + } + QPushButton:hover { + background-color: #cc7700; + } + QPushButton:pressed { + background-color: #995900; + } + + + EXIT + + + + + + + + + + + + diff --git a/bank_managment_system/QTFrontend.py b/bank_managment_system/QTFrontend.py index 08fa1143ef5..443276df1fe 100644 --- a/bank_managment_system/QTFrontend.py +++ b/bank_managment_system/QTFrontend.py @@ -3,6 +3,7 @@ import sys import backend backend.connect_database() +employee_data = None def create_styled_frame(parent, min_size=None, style=""): """Create a styled QFrame with optional minimum size and custom style.""" frame = QtWidgets.QFrame(parent) @@ -68,6 +69,7 @@ def create_input_field(parent, label_text, min_label_size=(120, 0)): layout.addWidget(label) layout.addWidget(line_edit) return frame, line_edit + def show_popup_message(parent, message: str, page: int = None, show_cancel: bool = True): """Reusable popup message box. @@ -131,6 +133,7 @@ def on_reject(): button_box.rejected.connect(on_reject) dialog.exec_() + def get_employee_name(parent, name_field_text="Enter Employee Name"): page, main_layout = create_page_with_header(parent, "Employee Data Update") @@ -152,18 +155,28 @@ def get_employee_name(parent, name_field_text="Enter Employee Name"): main_layout.addWidget(content_frame) def on_search_button_clicked(): + global employee_data entered_name = name_field.text().strip() + print(f"Entered Name: {entered_name}") if not entered_name: QtWidgets.QMessageBox.warning(parent, "Input Error", "Please enter an employee name.") return try: - cur = backend.cur - cur.execute("SELECT * FROM staff WHERE name = ?", (entered_name,)) - fetch = cur.fetchone() - if fetch: - QtWidgets.QMessageBox.information(parent, "Employee Found", - f"Employee data:\nID: {fetch[0]}\nName: {fetch[1]}\nDept: {fetch[2]}\nRole: {fetch[3]}") + employee_check = backend.check_name_in_staff(entered_name) + print(f"Employee Check: {type(employee_check)},{employee_check}") + if employee_check: + cur = backend.cur + cur.execute("SELECT * FROM staff WHERE name = ?", (entered_name,)) + employee_data = cur.fetchone() + print(f"Employee Data: {employee_data}") + parent.setCurrentIndex(6) + + # if employee_data: + # QtWidgets.QMessageBox.information(parent, "Employee Found", + # f"Employee data:\nID: {fetch[0]}\nName: {fetch[1]}\nDept: {fetch[2]}\nRole: {fetch[3]}") + + else: QtWidgets.QMessageBox.information(parent, "Not Found", "Employee not found.") except Exception as e: @@ -175,6 +188,7 @@ def on_search_button_clicked(): #backend.check_name_in_staff() + def create_login_page(parent ,title, name_field_text="Name :", password_field_text="Password :", submit_text="Submit",): """Create a login page with a title, name and password fields, and a submit button.""" page, main_layout = create_page_with_header(parent, "Admin Menu") @@ -210,6 +224,7 @@ def create_login_page(parent ,title, name_field_text="Name :", password_field_te return page, name_edit, password_edit, submit_button + def on_login_button_clicked(parent, name_field, password_field): name = name_field.text().strip() password = password_field.text().strip() @@ -277,6 +292,7 @@ def create_home_page(parent, on_admin_clicked, on_employee_clicked, on_exit_clic exit_button.clicked.connect(on_exit_clicked) return page + def create_page_with_header(parent, title_text): """Create a page with a styled header and return the page + main layout.""" page = QtWidgets.QWidget(parent) @@ -291,6 +307,7 @@ def create_page_with_header(parent, title_text): main_layout.addWidget(header_frame, 0, QtCore.Qt.AlignTop) return page, main_layout + def create_admin_menu_page(parent): page, main_layout = create_page_with_header(parent, "Admin Menu") @@ -315,7 +332,6 @@ def create_admin_menu_page(parent): main_layout.addWidget(button_frame) return page, *buttons # Unpack as add_button, update_employee, etc. - def create_add_employee_page(parent, title, submit_text="Submit",update_btn:bool=False): page, main_layout = create_page_with_header(parent, title) @@ -330,21 +346,32 @@ def create_add_employee_page(parent, title, submit_text="Submit",update_btn:bool # Define input fields fields = ["Name :", "Password :", "Salary :", "Position :"] + name_edit = None + password_edit = None + salary_edit = None + position_edit = None edits = [] - for field in fields: + for i, field in enumerate(fields): field_frame, field_edit = create_input_field(form_frame, field) form_layout.addWidget(field_frame) + if i == 0: + name_edit = field_edit + elif i == 1: + password_edit = field_edit + elif i == 2: + salary_edit = field_edit + elif i == 3: + position_edit = field_edit edits.append(field_edit) - # Submit button button_frame = create_styled_frame(form_frame, style="padding: 7px;") button_layout = QtWidgets.QVBoxLayout(button_frame) if update_btn: - update_button = create_styled_button(button_frame, "Update", min_size=(150, 0)) + update_button = create_styled_button(button_frame, "Update", min_size=(100, 50)) button_layout.addWidget(update_button, 0, QtCore.Qt.AlignHCenter) else: - submit_button = create_styled_button(button_frame, submit_text, min_size=(150, 0)) + submit_button = create_styled_button(button_frame, submit_text, min_size=(100, 50)) button_layout.addWidget(submit_button, 0, QtCore.Qt.AlignHCenter) @@ -352,9 +379,9 @@ def create_add_employee_page(parent, title, submit_text="Submit",update_btn:bool content_layout.addWidget(form_frame, 0, QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) main_layout.addWidget(content_frame) if update_btn: - return page, *edits, update_button + return page, name_edit, password_edit, salary_edit, position_edit, update_button else: - return page, *edits, submit_button # Unpack as name_edit, password_edit, etc. + return page, name_edit, password_edit, salary_edit, position_edit, submit_button # Unpack as name_edit, password_edit, etc. def setup_main_window(main_window): """Set up the main window with a stacked widget containing home, admin, and employee pages.""" @@ -474,10 +501,65 @@ def fetch_employee_data(name): update_employee_page1 = get_employee_name(stacked_widget) # apply the update_employee_data function to the submit button + update_employee_page2 ,update_employee_name, update_employee_password, update_employee_salary, update_employee_position,update_employee_update = create_add_employee_page(stacked_widget,"Update Employee Details",update_btn=True) + def populate_employee_data(): + global employee_data + if employee_data: + print("employee_data is not None") + update_employee_name.setText(str(employee_data[0])) # Name + update_employee_password.setText(str(employee_data[1])) # Password + update_employee_salary.setText(str(employee_data[2])) # Salary + update_employee_position.setText(str(employee_data[3])) # Position + else: + # Clear fields if no employee data is available + print("employee_data is None") + update_employee_name.clear() + update_employee_password.clear() + update_employee_salary.clear() + update_employee_position.clear() + QtWidgets.QMessageBox.warning(stacked_widget, "No Data", "No employee data available to display.") + def on_page_changed(index): + if index == 6: # update_employee_page2 is at index 6 + populate_employee_data() + + # Connect the currentChanged signal to the on_page_changed function + stacked_widget.currentChanged.connect(on_page_changed) + def update_employee_data(name, password, salary, position, name_to_update): + try: + if not name_to_update: + show_popup_message(stacked_widget, "Original employee name is missing.", 5) + return + if not (name or password or salary or position): + show_popup_message(stacked_widget, "Please fill at least one field to update.", 5) + return + if name: + backend.update_employee_name(name, name_to_update) + if password: + backend.update_employee_password(password, name_to_update) + if salary: + try: + salary = int(salary) + backend.update_employee_salary(salary, name_to_update) + except ValueError: + show_popup_message(stacked_widget, "Salary must be a valid number.", 5) + return + if position: + backend.update_employee_position(position, name_to_update) + show_popup_message(stacked_widget, "Employee updated successfully.", 3, False) + except Exception as e: + show_popup_message(stacked_widget, f"Error updating employee: {str(e)}", 5) + update_employee_update.clicked.connect( + lambda: update_employee_data( + update_employee_name.text().strip(), + update_employee_password.text().strip(), + update_employee_salary.text().strip(), + update_employee_position.text().strip(), + employee_data[0] if employee_data else "" + ) + ) + - - # /////////////////////////// emp_submit.clicked.connect( lambda: add_employee_form_submit( emp_name.text(), @@ -501,6 +583,7 @@ def fetch_employee_data(name): stacked_widget.addWidget(admin_menu_page)#3 stacked_widget.addWidget(add_employee_page)#4 stacked_widget.addWidget(update_employee_page1)#5 + stacked_widget.addWidget(update_employee_page2)#6 main_layout.addWidget(stacked_widget) main_window.setCentralWidget(central_widget) diff --git a/bank_managment_system/backend.py b/bank_managment_system/backend.py index 42475416fa0..7ea679863b5 100644 --- a/bank_managment_system/backend.py +++ b/bank_managment_system/backend.py @@ -1,12 +1,11 @@ import sqlite3 - +import os # Making connection with database def connect_database(): global conn global cur - conn = sqlite3.connect("bankmanaging.db") + conn = sqlite3.connect(os.path.join(os.path.dirname(__file__), "bankmanaging.db")) cur = conn.cursor() - cur.execute( """ CREATE TABLE IF NOT EXISTS bank (