class CheckData(QtWidgets.QMainWindow):
    def __init__(self):

        super(CheckData, self).__init__()
        uic.loadUi('ui/access_old.ui', self)
        self.setWindowTitle("Check For Old User Name or Password")

        self.changeData = ChangeData()

        self.lineEdit_username = self.findChild(
            QtWidgets.QLineEdit, 'old_name')  # Find the EditLine
        self.lineEdit_password = self.findChild(
            QtWidgets.QLineEdit, 'old_pass')  # Find the EditLine

        self.button_change = self.findChild(
            QtWidgets.QPushButton, 'sure_old')  # Find the Submit button
        self.button_back_login = self.findChild(QtWidgets.QPushButton,
                                                'back')  # Find the Back button

        self.button_change.clicked.connect(self.check_username_password)
        self.button_back_login.clicked.connect(self.back_login)

    def check_username_password(self):
        msg = QtWidgets.QMessageBox()
        file_data = open("admin_data/login.txt", "r")
        content = file_data.read().split('\n')

        if self.lineEdit_username.text(
        ) == content[0] and self.lineEdit_password.text() == content[1]:
            file_data.close()
            self.close()
            self.changeData.show()

        else:
            msg.setText('Incorrect UserName Or Password!!!')
            msg.exec_()

    def back_login(self):
        from login import LoginForm
        self.Login = LoginForm()
        self.close()
        self.Login.show()
class ChangeData(QtWidgets.QMainWindow):
    def __init__(self):

        super(ChangeData, self).__init__()
        uic.loadUi('ui/access_new.ui', self)
        self.setWindowTitle("Submit For Changing User Name Or Password")

        self.lineEdit_username = self.findChild(
            QtWidgets.QLineEdit, 'new_name')  # Find the EditLine
        self.lineEdit_password = self.findChild(
            QtWidgets.QLineEdit, 'new_pass')  # Find the EditLine

        self.button_login = self.findChild(
            QtWidgets.QPushButton, 'change_confirm')  # Find the Confirm button
        self.button_back_login = self.findChild(QtWidgets.QPushButton,
                                                'back')  # Find the Back button

        self.button_login.clicked.connect(self.change_username_password)
        self.button_back_login.clicked.connect(self.back_login)

    def change_username_password(self):
        msg = QtWidgets.QMessageBox()

        if self.lineEdit_username.text() != "" and self.lineEdit_password.text(
        ) != "":
            file_data = open("admin_data/login.txt", "w")
            file_data.write(self.lineEdit_username.text() + "\n")
            file_data.write(self.lineEdit_password.text())
            file_data.close()
            from login import LoginForm
            self.loginWindow = LoginForm()
            self.close()
            self.loginWindow.show()
        else:
            msg.setText('Empty UserName Or Password!!!')
            msg.exec_()

    def back_login(self):
        from login import LoginForm
        self.Login = LoginForm()
        self.close()
        self.Login.show()
Esempio n. 3
0
class Home(QtWidgets.QMainWindow):
    def __init__(self):
        super(Home, self).__init__()
        uic.loadUi('ui/home.ui', self)
        self.setWindowTitle("Home")

        self.Login = LoginForm()

        self.button_enter = self.findChild(QtWidgets.QPushButton,
                                           'enter')  # Find the Enter button
        self.button_exit = self.findChild(QtWidgets.QPushButton,
                                          'exit')  # Find the Exit button

        self.button_enter.clicked.connect(self.open_app)
        self.button_exit.clicked.connect(self.close_app)

    def open_app(self):
        self.close()
        self.Login.show()

    def close_app(self):
        self.close()