class EmployeeView(QDialog):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("EMPLOYEE FORM.")
        self.setModal(True)
        self.resize(550, 350)

        #  >>>FONT CONFIGURE<<<
        self.font = QtGui.QFont()
        self.font.setFamily("Product Sans")
        self.font.setPointSize(12)
        self.font.setWeight(55)

        # >>> BASE SECTION <<<
        self.layoutUtama = QGridLayout()

        # >>> FIRST LAYOUT <<<
        framelayout1 = QFrameRC("white")
        framelayout1.setContentsMargins(25, 25, 25, 25)
        layout1 = QGridLayout(framelayout1)

        lbljudul = QLabelRC("Data Employee", "rgb(125, 15, 15)")

        lblauthority = QLabelRC("\nJabatan\n", "black")
        lblauthority.setFont(self.font)
        self.cmbauthority = QComboBoxRC()
        self.cmbauthority.addItems(
            ['Employee', 'Receptonist', 'Marketing Crew', 'Cashier'])
        self.pilAuthority = [
            Emptype.Employee, Emptype.Receptionist, Emptype.Marketing_crew,
            Emptype.Cashier
        ]

        lbljeniskelamin = QLabelRC("\nJenis Kelamin\n", "black")
        lbljeniskelamin.setFont(self.font)
        self.cmbjeniskelamin = QComboBoxRC()
        self.cmbjeniskelamin.addItems(['Laki-laki', 'Perempuan'])
        self.pilJenisKelamin = [JenKel.Lakilaki, JenKel.Perempuan]

        lblnama = QLabelRC("\nNama\n", "black")
        lblnama.setFont(self.font)
        self.txtnama = EditLineRC("Input Nama")

        lblTL = QLabelRC("\n\nTanggal Lahir\n", "black")
        lblTL.setFont(self.font)
        self.txtTL = EditLineRC("")

        lblalamat = QLabelRC("\n\nAlamat\n", "black")
        lblalamat.setFont(self.font)
        self.txtalamat = EditLineRC("Input Alamat")

        # >>> ADD DATA <<<
        self.btnTambah = QPushButtonRC2("Tambah Data", "Assets/img/button.png")
        self.btnTambah.setStyleSheet("background-color : rgb(125, 15, 15);\n"
                                     "border : none;\n"
                                     "border-radius : 25px;\n"
                                     "height : 50%;\n"
                                     "color : white;\n")
        self.btnTambah.setIconSize(QtCore.QSize(60, 35))

        self.btnMainMenu = QPushButtonRC2("Main Menu", "Assets/img/back.png")
        self.btnMainMenu.setStyleSheet("background-color : rgb(125, 15, 15);\n"
                                       "border : none;\n"
                                       "border-radius : 25px;\n"
                                       "height : 50%;\n"
                                       "color : white;\n")
        self.btnMainMenu.setIconSize(QtCore.QSize(60, 35))

        # >>> EVENT SECTION <<<
        self.btnTambah.clicked.connect(lambda: self.insertData())
        self.btnMainMenu.clicked.connect(lambda: self.switchMainMenu())

        # >>> LAYOUT SECTION <<<
        self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignVCenter)
        self.layoutUtama.addWidget(self.btnTambah, 5, 0, 1, 9,
                                   Qt.AlignBottom | Qt.AlignRight)
        self.layoutUtama.addWidget(self.btnMainMenu, 5, 0, 1, 9,
                                   Qt.AlignBottom | Qt.AlignLeft)

        layout1.addWidget(lbljudul, 0, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(lblnama, 1, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.txtnama, 2, 0, 2, 3)
        layout1.addWidget(lblTL, 4, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.txtTL, 5, 0, 2, 3)
        layout1.addWidget(lblalamat, 7, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.txtalamat, 8, 0, 2, 3)
        layout1.addWidget(lblauthority, 1, 5, 1, 3)
        layout1.addWidget(self.cmbauthority, 2, 5, 2, 3)
        layout1.addWidget(lbljeniskelamin, 4, 5, 1, 3)
        layout1.addWidget(self.cmbjeniskelamin, 5, 5, 2, 3)

        self.setLayout(self.layoutUtama)
        self.show()

    @pyqtSlot()
    def insertData(self):
        self.id_emp = self.txtnama.text()
        self.nama_emp = self.txtnama.text()
        self.TL_emp = self.txtTL.text()
        self.jabatan_emp = self.pilAuthority[self.cmbauthority.currentIndex()]
        self.JK_emp = self.pilJenisKelamin[self.cmbjeniskelamin.currentIndex()]
        self.alamat_emp = self.txtalamat.text()
        employee = EmployeeOrm(self.id_emp, self.nama_emp, self.TL_emp,
                               self.jabatan_emp, self.JK_emp, self.alamat_emp)
        try:
            EmployeeOrm.insertEmployee(employee)
        except Exception as e:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Warning)
            msg.setText("Something Wrong", e)
            msg.setWindowTitle("GAGAL")
            msg.exec_()
        else:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Information)
            msg.setText("Data Berhasil Di Input!")
            msg.setWindowTitle("BERHASIL")
            msg.exec_()
            self.clear()

    def switchMainMenu(self):
        self.close()

    def clear(self):
        self.txtnama.setText("")
        self.txtTL.setText("")
        self.txtalamat.setText("")
        self.cmbauthority.setCurrentIndex(0)
        self.cmbjeniskelamin.setCurrentIndex(0)
        self.txtnama.setFocus()
class UserView(QDialog):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Sign in.")
        self.setModal(True)
        self.resize(750, 400)

        # >>> FONT CONFIGURE <<<
        self.font = QtGui.QFont()
        self.font.setFamily("Product Sans")
        self.font.setPointSize(12)
        self.font.setWeight(55)

        # >>> BASE SECTION <<<
        self.layoutUtama = QGridLayout()

        # >>> FIRST LAYOUT <<<
        framelayout1 = QFrameRC("azure")
        framelayout1.setContentsMargins(25, 25, 25, 25)
        layout1 = QGridLayout(framelayout1)

        lbljudul = QLabelRC("Daftar Akun User", "rgb(125, 15, 15)")

        lblauthority = QLabelRC("\nOtoritas\n", "black")
        lblauthority.setFont(self.font)
        self.cmbauthority = QComboBoxRC()
        self.cmbauthority.addItems([
            'Administrator', 'Employee', 'Receptionist', 'Marketing_crew',
            'Cashier', 'Visitor'
        ])
        self.pilAuthority = [
            Authority.Administrator, Authority.Employee,
            Authority.Receptionist, Authority.Marketing_crew,
            Authority.Cashier, Authority.Visitor
        ]

        lblusername = QLabelRC("\nUsername\n", "black")
        lblusername.setFont(self.font)
        self.txtusername = EditLineRC("Input Username")

        lblpassword = QLabelRC("\n\nPassword\n", "black")
        lblpassword.setFont(self.font)
        self.txtpassword = EditLineRC("Input Password")

        # >>> ADD DATA <<<
        self.btnTambah = QPushButtonRC2("Tambah Akun", "Assets/img/button.png")
        self.btnTambah.setStyleSheet("background-color : rgb(125, 15, 15);\n"
                                     "border : none;\n"
                                     "border-radius : 30px;\n"
                                     "height : 60%;\n"
                                     "color : grey;\n")
        self.btnTambah.setIconSize(QtCore.QSize(60, 35))

        # >>> LOGIN BUTTON <<<
        self.btnLogin = QPushButtonRC2("Login Now", "Assets/img/profile.png")
        self.btnLogin.setStyleSheet("background-color : rgb(125, 15, 15);\n"
                                    "border : none;\n"
                                    "border-radius : 30px;\n"
                                    "height : 60%;\n"
                                    "color : grey;\n")
        self.btnLogin.setIconSize(QtCore.QSize(60, 35))

        # >>> EVENT SECTION <<<
        self.btnTambah.clicked.connect(lambda: self.insertData())
        self.btnLogin.clicked.connect(lambda: self.LoginView())

        # >>> LAYOUT SECTION <<<
        self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignVCenter)
        self.layoutUtama.addWidget(self.btnTambah, 5, 0, 1, 9,
                                   Qt.AlignBottom | Qt.AlignRight)
        self.layoutUtama.addWidget(self.btnLogin, 5, 0, 1, 9,
                                   Qt.AlignBottom | Qt.AlignLeft)

        layout1.addWidget(lbljudul, 0, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(lblusername, 1, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.txtusername, 2, 0, 2, 3)
        layout1.addWidget(lblauthority, 4, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.cmbauthority, 5, 0, 2, 3)
        layout1.addWidget(lblpassword, 1, 5, 1, 3)
        layout1.addWidget(self.txtpassword, 2, 5, 2, 3)

        self.setLayout(self.layoutUtama)
        self.show()

    @pyqtSlot()
    def insertData(self):
        self.username = self.txtusername.text()
        self.password = self.txtpassword.text()
        self.authority = self.pilAuthority[self.cmbauthority.currentIndex()]
        user = User(self.username, self.password, self.authority)
        try:
            UserOrm.insertUser(user)
        except Exception as e:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Warning)
            msg.setText("Ada kesalahan!", e)
            msg.setWindowTitle("GAGAL")
            msg.exec_()
        else:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Information)
            msg.setText("Akun berhasil dibuat!")
            msg.setWindowTitle("BERHASIL")
            msg.exec_()
            self.clear()

    def LoginView(self):
        from GUI.AuthenticationGUI import LoginView
        self.LoginView = LoginView()
        self.LoginView.show()
        self.hide()

    def clear(self):
        self.txtusername.setText("")
        self.txtpassword.setText("")
        self.cmbauthority.setCurrentIndex(0)
        self.txtusername.setFocus()
Esempio n. 3
0
class LoginView(QWidget):
    def __init__(self):
        super().__init__()
        self.resize(1120, 810)
        self.setWindowTitle("LOGIN HOTEL")

        # >>>> LAYOUT 1 SECTION <<<<
        lbllogo = QLabelRC("yo", "yo")
        lbllogo.setPixmap(QtGui.QPixmap("Assets/img/sleep.jpg"))
        lbllogo.setAlignment(QtCore.Qt.AlignCenter)

        lblPresentBy = QLabelRC("Sleep tight", "black")
        lblPresentBy.setAlignment(QtCore.Qt.AlignCenter)
        lblCredit = QLabelRC(
            "'Chilling out on the bed in your hotel room watching television, while wearing your own pajamas, is sometimes the best part of a vacation.'",
            "grey")
        lblCredit.setAlignment(QtCore.Qt.AlignCenter)

        # >>>> LAYOUT 2 SECTION <<<<
        lbljudul = QLabelRC("HOTEL", "black")
        font = QtGui.QFont()
        font.setFamily("Candara")
        font.setPointSize(24)
        font.setBold(True)
        font.setWeight(70)
        lbljudul.setFont(font)
        lbljudul.setAlignment(QtCore.Qt.AlignCenter)

        lblusername = QLabelRC("Username", "grey")
        lblpassword = QLabelRC("Password", "grey")
        # EditLine
        self.txtUsername = EditLineRC("masukkan username anda disini")
        self.txtpassword = EditLineRC("masukkan password anda disini")
        self.txtpassword.setEchoMode(QLineEdit.Password)
        # QPushButton
        self.btnLogin = QPushButtonRC("Login")
        self.btnLogin.clicked.connect(lambda: self.buttonClick())

        self.btnUser = QPushButtonRC("Tambah User")
        self.btnUser.clicked.connect(lambda: self.buttonClick2())

        # >>>> LAYOUT SECTION <<<<
        layout1 = QVBoxLayout()
        layout1.addWidget(lbllogo)
        layout1.addWidget(lblPresentBy)
        layout1.addWidget(lblCredit)

        layout2 = QVBoxLayout()
        layout2.setContentsMargins(45, 45, 45, 45)
        layout2.setSpacing(0)
        layout2.addWidget(lbljudul)
        layout2.addWidget(lblusername)
        layout2.addWidget(self.txtUsername)
        layout2.addWidget(lblpassword)
        layout2.addWidget(self.txtpassword)
        layout2.addWidget(self.btnLogin)
        layout2.addWidget(self.btnUser)

        layoutUtama = QHBoxLayout()
        layoutUtama.addLayout(layout1)
        layoutUtama.addLayout(layout2)

        self.setLayout(layoutUtama)
        self.show()

    @pyqtSlot()
    def buttonClick(self):
        username = self.txtUsername.text()
        password = self.txtpassword.text()
        checkLogin = UserOrm.verifyUser(username, password)
        if (checkLogin == True):
            self.switchMainMenu()
        else:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Warning)
            msg.setText("Username/Password tidak cocok!")
            msg.setWindowTitle("GAGAL")
            msg.exec_()

    def buttonClick2(self):
        from GUI.UserGUI import UserView
        self.userView = UserView()
        self.userView.show()
        self.hide()

    @pyqtSlot()
    def switchMainMenu(self):
        username = self.txtUsername.text()
        authority = UserOrm.findOtoritas(username)
        self.mainMenu = MainMenu(username.upper(), authority)
        self.mainMenu.show()
        self.hide()

    def clear(self):
        self.txtUsername.setText("")
        self.txtpassword.setText("")
        self.txtUsername.setFocus()
Esempio n. 4
0
class AdminView(QDialog):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("ADMIN FORM.")
        self.setModal(True)
        self.resize(550, 350)

        # >>>> FONT CONFIGURE <<<<
        self.font = QtGui.QFont()
        self.font.setFamily("Product Sans")
        self.font.setPointSize(12)
        self.font.setWeight(55)

        # >>>> BASE SECTION <<<<
        self.layoutUtama = QGridLayout()

        # >>>> FIRST LAYOUT <<<<
        framelayout1 = QFrameRC("white")
        framelayout1.setContentsMargins(25, 25, 25, 25)
        layout1 = QGridLayout(framelayout1)

        lbljudul = QLabelRC("Data Admin", "rgb(125, 15, 15)")

        lblnama = QLabelRC("\nNama\n", "black")
        lblnama.setFont(self.font)
        self.txtnama = EditLineRC("Input Nama")

        lblkode = QLabelRC("\n\nKode\n", "black")
        lblkode.setFont(self.font)
        self.txtkode = EditLineRC("Input Kode")

        # >>>> ADD DATA <<<<
        self.btnTambah = QPushButtonRC2("Tambah Data", "Assets/img/button.png")
        self.btnTambah.setStyleSheet("background-color : rgb(125, 15, 15);\n"
                                     "border : none;\n"
                                     "border-radius : 25px;\n"
                                     "height : 50%;\n"
                                     "color : white;\n")
        self.btnTambah.setIconSize(QtCore.QSize(60, 35))

        self.btnMainMenu = QPushButtonRC2("Main Menu", "Assets/img/back.png")
        self.btnMainMenu.setStyleSheet("background-color : rgb(125, 15, 15);\n"
                                     "border : none;\n"
                                     "border-radius : 25px;\n"
                                     "height : 50%;\n"
                                     "color : white;\n")
        self.btnMainMenu.setIconSize(QtCore.QSize(60, 35))

        # >>>> EVENT SECTION <<<<
        self.btnTambah.clicked.connect(lambda: self.insertData())
        self.btnMainMenu.clicked.connect(lambda: self.switchMainMenu())

        # >>>> LAYOUT SECTION <<<<
        self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignVCenter)
        self.layoutUtama.addWidget(self.btnTambah, 5, 0, 1, 9, Qt.AlignBottom | Qt.AlignRight)
        self.layoutUtama.addWidget(self.btnMainMenu, 5, 0, 1, 9, Qt.AlignBottom | Qt.AlignLeft)

        layout1.addWidget(lbljudul, 0, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(lblnama, 1, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.txtnama, 2, 0, 2, 3)
        layout1.addWidget(lblkode, 4, 0, 1, 3, Qt.AlignLeft)
        layout1.addWidget(self.txtkode, 5, 0, 2, 3)

        self.setLayout(self.layoutUtama)
        self.show()

    @pyqtSlot()
    def insertData(self):
        self.id_admin = self.txtkode.text()+self.txtnama.text()
        self.nama_admin = self.txtnama.text()
        self.kode_admin = self.txtkode.text()
        admin = AdministratorOrm(self.id_admin, self.nama_admin, self.kode_admin)
        try:
            AdministratorOrm.insertAdmin(admin)
        except Exception as e:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Warning)
            msg.setText("Something Wrong", e)
            msg.setWindowTitle("GAGAL")
            msg.exec_()
        else:
            msg = QMessageBox()
            msg.resize(250, 250)
            msg.setIcon(QMessageBox.Information)
            msg.setText("Data Berhasil Di Input!")
            msg.setWindowTitle("BERHASIL")
            msg.exec_()
            self.clear()

    def switchMainMenu(self):
        self.close()


    def clear(self):
        self.txtnama.setText("")
        self.txtkode.setText("")
        self.txtnama.setFocus()