예제 #1
0
class StudentLogin(object):
    def openVote(self):
        self.window = QtWidgets.QMainWindow()
        self.ui = Vote()
        self.ui.setupUi(self.window)
        self.window.show()
        MainWindow.hide()

    def authenticate(self):

        user = self.username.text()
        passw = self.password.text()

        con = sqlite3.connect("E-VOTING.db")
        cur = con.cursor()
        result = cur.execute(
            "SELECT * FROM students WHERE MAT = ? AND CONTACT = ?",
            (user, passw))
        try:
            if (len(result.fetchall()) > 0):
                print("WELCOME STUDENT!")
                self.openVote()
            else:
                print("UNKNOWN PASSWORD OR USER!")
        except:
            print(
                "..........................................Error establishing database connection................................."
            )
            print(
                "...........................................Reconnecting.................................................."
            )

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(557, 389)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.login = QtWidgets.QPushButton(self.centralwidget)
        self.login.setGeometry(QtCore.QRect(200, 304, 141, 41))
        self.login.setStyleSheet("font: bold;\n"
                                 "color: blue;\n"
                                 "font-size: 20px;")
        self.login.setObjectName("login")

        ##############################################
        self.login.clicked.connect(self.authenticate)
        ##############################################

        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(10, 10, 531, 101))
        self.label.setObjectName("label")
        self.username = QtWidgets.QLineEdit(self.centralwidget)
        self.username.setGeometry(QtCore.QRect(230, 130, 200, 41))
        self.username.setObjectName("username")
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setGeometry(QtCore.QRect(56, 130, 171, 41))
        self.label_2.setObjectName("label_2")
        self.password = QtWidgets.QLineEdit(self.centralwidget)
        self.password.setGeometry(QtCore.QRect(230, 210, 200, 41))
        self.password.setObjectName("password")

        #############################################################
        self.password.setEchoMode(QtWidgets.QLineEdit.Password)
        #############################################################

        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setGeometry(QtCore.QRect(60, 210, 171, 41))
        self.label_3.setObjectName("label_3")
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(
            _translate("MainWindow", "UTGSU E-VOTING SYSTEM"))
        self.login.setText(_translate("MainWindow", "LOGIN"))
        self.label.setText(
            _translate(
                "MainWindow",
                "<html><head/><body><p align=\"center\"><span style=\" font-size:26pt; font-weight:600; color:#204a87;\">WELCOME TO UTGSU E-VOTING</span></p><p align=\"center\"><span style=\" font-size:26pt; font-weight:600; color:#204a87;\">SYSTEM</span></p><p align=\"center\"><br/></p></body></html>"
            ))
        self.label_2.setText(
            _translate(
                "MainWindow",
                "<html><head/><body><p><span style=\" font-size:20pt; font-weight:600; color:#204a87;\">USERNAME</span></p></body></html>"
            ))
        self.label_3.setText(
            _translate(
                "MainWindow",
                "<html><head/><body><p><span style=\" font-size:20pt; font-weight:600; color:#204a87;\">PASSWORD</span></p></body></html>"
            ))
예제 #2
0
class Ui_Form(object):
    def entervote(self):
        self.window = QtWidgets.QMainWindow()
        self.ui = Vote()
        self.ui.setupUi(self.window)
        self.window.show()
        MainWindow.hide()

    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(452, 427)
        Form.setStyleSheet("\n"
                           "#checkelections\n"
                           "{\n"
                           "    background-color: grey;\n"
                           "    color: white;\n"
                           "    font: bold;\n"
                           "    font-size: 15px;\n"
                           "}\n"
                           "\n"
                           "#vote\n"
                           "{\n"
                           "    background-color: grey;\n"
                           "    color: white;\n"
                           "    font: bold;\n"
                           "    font-size: 15px;\n"
                           "}\n"
                           "\n"
                           "#checkresult\n"
                           "{\n"
                           "    background-color: grey;\n"
                           "    color: white;\n"
                           "    font: bold;\n"
                           "    font-size: 15px;\n"
                           "}\n"
                           "\n"
                           "#logout\n"
                           "{\n"
                           "    background-color: white;\n"
                           "    color: red;\n"
                           "    font: bold;\n"
                           "}")
        self.label = QtWidgets.QLabel(Form)
        self.label.setGeometry(QtCore.QRect(30, 10, 381, 41))
        self.label.setObjectName("label")
        self.checkelections = QtWidgets.QPushButton(Form)
        self.checkelections.setGeometry(QtCore.QRect(80, 60, 281, 91))
        self.checkelections.setObjectName("checkelections")
        self.vote = QtWidgets.QPushButton(Form)
        self.vote.setGeometry(QtCore.QRect(80, 170, 281, 91))
        self.vote.setObjectName("vote")
        ###
        self.vote.clicked.connect(self.entervote)
        ###
        self.checkresult = QtWidgets.QPushButton(Form)
        self.checkresult.setGeometry(QtCore.QRect(80, 280, 281, 91))
        self.checkresult.setObjectName("checkresult")
        self.logout = QtWidgets.QPushButton(Form)
        self.logout.setGeometry(QtCore.QRect(334, 392, 101, 31))
        self.logout.setObjectName("logout")

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.label.setText(
            _translate(
                "Form",
                "<html><head/><body><p align=\"center\"><span style=\" font-size:18pt; font-weight:600; color:#00007f;\">WELCOME BACK!</span></p></body></html>"
            ))
        self.checkelections.setText(_translate("Form", "CHECK ELECTIONS"))
        self.vote.setText(_translate("Form", "VOTE"))
        self.checkresult.setText(_translate("Form", "CHECK RESULTS"))
        self.logout.setText(_translate("Form", "LOGOUT"))