Ejemplo n.º 1
0
class LoginController:
    def __init__(self, model):
        self.__model = model
        self.__view = LoginView(self, self.__model)
        self.__view.show()

    def set_mail(self):
        mail = self.__view.ui.lineEdit.text()
        self.__model.mail = mail

    def set_password(self):
        password = self.__view.ui.lineEdit_2.text()
        self.__model.password = password

    def login(self):
        users = DataContext().User.load()
        mail = users.where(
            lambda x: x.email == self.__model.mail).first_of_default()
        if mail is not False:
            password = users.where(lambda x: x.password == self.__model.
                                   password).first_of_default()
            if password is not False:
                model = MainWindowModel()
                controller = MainWindowController(model)
                self.__view.close()
            else:
                self.__model.error = "Неправельный пароль"
        else:
            self.__model.error = "неправельная почта"
Ejemplo n.º 2
0
 def __init__(self):
     self.gladefile = "serwerspotkan.glade"
     self.wTree = gtk.glade.XML(self.gladefile)
     self.window = self.wTree.get_widget("window1")
     Session = sessionmaker(bind=engine)
     session = Session()
     self.loginView = LoginView(self.wTree)
     self.registerView = RegisterView(self.wTree, self.loginView)
     self.mainView = mainView(self.wTree)
     RegisterController(self.wTree, self.registerView, session)
     LoginController(self.wTree, self.loginView, self.mainView, self.registerView, session)
Ejemplo n.º 3
0
    def clickDashboard(self, buttonName):
        # Check the button name and open the particular window

        if buttonName == 'btn_AddManufacture':
            # Close the office staff dashboard
            # Open the manufacture view
            self.window.destroy()
            ManuFactureview()

        elif buttonName == 'btn_AddCar':
            self.window.destroy()
            CarView()

        elif buttonName == 'btn_DeleteCar':
            self.window.destroy()
            DeleteCarView()

        elif buttonName == 'btn_ViewSoldCar':
           self.window.destroy()
           ViewSoldCar()

        elif buttonName == 'btn_AddModel':
            self.window.destroy()
            CarmodelView()

        elif buttonName == 'btn_AddUpgrade':
            self.window.destroy()
            Officestaff_Upgrade_View()

        elif buttonName == 'btn_SearchCar':
            self.window.destroy()
            SearchCarView()

        elif buttonName == 'btn_Logout':
           self.window.destroy()
           from View.LoginView import LoginView
           LoginView()
Ejemplo n.º 4
0
 def logOutSlot(self):
     from View.LoginView import LoginView
     self.login = LoginView()
     self.login.show()
     self.close()
Ejemplo n.º 5
0
class MainMenuView(QWidget):
    def __init__(self, username, hakakses):
        super().__init__()

        self.showMaximized()
        self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
        self.setWindowTitle("MAIN MENU")

        # ========== SIDEBAR SECTION =============
        frameSideBar = QFrameReuse("white")
        frameSideBar.setContentsMargins(10, 10, 10, 10)

        sideBarLayout = QGridLayout(frameSideBar)
        sideBarLayout.setSpacing(5)
        btnMainMenu = QPushButtonReuse("Main Menu", "assets/img/medication.png")
        self.btnPasien = QPushButtonReuse("Form.Pasien", "assets/img/pasien.png")
        self.btnDokter = QPushButtonReuse("Form.Dokter", "assets/img/dokter.png")
        self.btnApoteker = QPushButtonReuse("Form.Apoteker", "assets/img/apoteker.png")
        self.btnObat = QPushButtonReuse("Form.Obat", "assets/img/obat.png")
        self.btnUser = QPushButtonReuse("Form.User", "assets/img/user.png")
        self.btnLogOut = QPushButtonReuse("Log Out", "assets/img/log_out.png")

        # =========== EVENT SECTION =============
        self.btnLogOut.clicked.connect(lambda: self.logOutSlot())
        self.btnPasien.clicked.connect(lambda: self.pasienSlot())
        self.btnDokter.clicked.connect(lambda: self.dokterSlot())
        self.btnApoteker.clicked.connect(lambda: self.apotekerSlot())
        self.btnObat.clicked.connect(lambda: self.obatSlot())
        self.btnUser.clicked.connect(lambda: self.userSlot())

        # ========== DASHBOARD SECTION TITLE ===========
        frameTitle = QFrameReuse("white")

        headerLayout = QGridLayout(frameTitle)
        self.hakAkses = QLabelReuse(str(hakakses), "black")

        self.hakAkses.setAlignment(QtCore.Qt.AlignLeft)

        layoutRightTitle = QHBoxLayout()
        self.btnnotification = QPushButtonReuse(str(PemeriksaanOrm.countNotif()), "assets/img/notification.png")
        self.btnnotification.setStyleSheet("background-color : transparent;\n"
                                           "color : red")
        profile = QPushButtonReuse("", "assets/img/profile.png")

        # =========== TITLE SECTION EVENT ============
        self.btnnotification.clicked.connect(lambda: self.pemeriksaanNotif())

        # ========== DASHBOARD SECTION BODY ===========
        frameDashboard = QFrameReuse("rgb(58, 150, 248)")
        frameLayout = QHBoxLayout(frameDashboard)
        frameLayout.setContentsMargins(40, 40, 40, 40)

        frameLayoutLeft = QVBoxLayout()
        frameLayoutRight = QVBoxLayout()

        font = QtGui.QFont()
        font.setFamily("Arial Rounded")
        font.setPointSize(11)
        font.setWeight(50)
        welcome = QLabelReuse("Welcome", "white")
        welcome.setFont(font)

        font = QtGui.QFont()
        font.setFamily("Product Sans")
        font.setPointSize(12)
        font.setWeight(75)
        self.username = QLabelReuse(username, "white")
        self.username.setFont(font)

        font = QtGui.QFont()
        font.setFamily("Arial Rounded")
        font.setPointSize(11)
        font.setItalic(True)
        font.setWeight(50)
        quote = QLabelReuse("\n\n\n\n\nTo keep the body in good health is a duty.. otherwise \n\n"
                            "we shall not be able to keep our mind strong and clear.\n", "white")
        quote.setFont(font)

        lbllogo = QLabelReuse("", "")
        lbllogo.setPixmap(QtGui.QPixmap("assets/img/medical256.png"))
        lbllogo.setAlignment(QtCore.Qt.AlignRight)

        self.framePemeriksaan = QFrameReuse("white")
        layoutPemeriksaan = QVBoxLayout(self.framePemeriksaan)
        layoutPemeriksaan.setContentsMargins(45, 45, 45, 45)

        lblPemeriksaan = QLabelReuse("", "")
        lblPemeriksaan.setPixmap(QtGui.QPixmap("assets/img/medical-tool.png"))
        lblPemeriksaan.setAlignment(QtCore.Qt.AlignCenter)
        lblPemeriksaanjudul = QLabelReuse("\nForm. Pemeriksaan\n", "black")
        lblPemeriksaanjudul.setAlignment(QtCore.Qt.AlignCenter)
        self.btnPemeriksaan = QPushButtonReuse("Get Started", "")

        self.frameTransaksi = QFrameReuse("white")
        layoutTransaksi = QVBoxLayout(self.frameTransaksi)
        layoutTransaksi.setContentsMargins(45, 45, 45, 45)

        lblTransaksi = QLabelReuse("", "")
        lblTransaksi.setPixmap(QtGui.QPixmap("assets/img/transaksi.png"))
        lblTransaksi.setAlignment(QtCore.Qt.AlignCenter)
        lblTransaksijudul = QLabelReuse("\nForm. Transaksi\n", "black")
        lblTransaksijudul.setAlignment(QtCore.Qt.AlignCenter)
        self.btnTransaksi = QPushButtonReuse("Get Started", "")

        # ========== DASHBOARD BODY EVENT =========
        self.btnPemeriksaan.clicked.connect(lambda: self.pemeriksaanSlot())

        # ========== LAYOUT SECTION ==============
        sideBarLayout.addWidget(btnMainMenu, 0, 0)
        sideBarLayout.addWidget(self.btnPasien, 1, 0)
        sideBarLayout.addWidget(self.btnDokter, 2, 0)
        sideBarLayout.addWidget(self.btnApoteker, 3, 0)
        sideBarLayout.addWidget(self.btnObat, 4, 0)
        sideBarLayout.addWidget(self.btnUser, 5, 0)
        sideBarLayout.addWidget(self.btnLogOut, 6, 0, QtCore.Qt.AlignBottom)

        layoutRightTitle.addWidget(self.btnnotification)
        layoutRightTitle.addWidget(profile)

        headerLayout.addWidget(self.hakAkses, 0, 0, QtCore.Qt.AlignLeft)
        headerLayout.addLayout(layoutRightTitle, 0, 2, QtCore.Qt.AlignRight)

        frameLayout.addLayout(frameLayoutLeft)
        frameLayout.addLayout(frameLayoutRight)

        frameLayoutLeft.addWidget(welcome)
        frameLayoutLeft.addWidget(self.username)
        frameLayoutLeft.addWidget(quote)

        frameLayoutRight.addWidget(lbllogo)

        layoutPemeriksaan.addWidget(lblPemeriksaan)
        layoutPemeriksaan.addWidget(lblPemeriksaanjudul)
        layoutPemeriksaan.addWidget(self.btnPemeriksaan)

        layoutTransaksi.addWidget(lblTransaksi)
        layoutTransaksi.addWidget(lblTransaksijudul)
        layoutTransaksi.addWidget(self.btnTransaksi)

        layoutUtama = QGridLayout()
        layoutUtama.addWidget(frameSideBar, 0, 0, 6, 1, QtCore.Qt.AlignLeft)
        layoutUtama.addWidget(frameTitle, 0, 1, 1, 9, QtCore.Qt.AlignTop)
        layoutUtama.addWidget(frameDashboard, 1, 1, 3, 9, QtCore.Qt.AlignTop)
        layoutUtama.addWidget(self.framePemeriksaan, 4, 1, 2, 2, QtCore.Qt.AlignHCenter)
        layoutUtama.addWidget(self.frameTransaksi, 4, 3, 2, 2, QtCore.Qt.AlignHCenter)
        layoutUtama.setSpacing(10)
        self.hakAksesVisible()
        self.setLayout(layoutUtama)

    @pyqtSlot()
    def logOutSlot(self):
        from View.LoginView import LoginView
        self.login = LoginView()
        self.login.show()
        self.close()

    @pyqtSlot()
    def pasienSlot(self):
        from View.PasienView import PasienView
        self.pasienview = PasienView()
        self.pasienview.show()
        self.pasienview.exec_()

    @pyqtSlot()
    def dokterSlot(self):
        from View.DokterView import DokterView
        self.dokterView = DokterView()
        self.dokterView.show()
        self.dokterView.exec_()

    @pyqtSlot()
    def apotekerSlot(self):
        from View.ApotekerView import ApotekerView
        self.apotekerView = ApotekerView()
        self.apotekerView.show()
        self.apotekerView.exec_()

    @pyqtSlot()
    def obatSlot(self):
        from View.ObatView import ObatView
        self.obatView = ObatView()
        self.obatView.show()
        self.obatView.exec_()

    @pyqtSlot()
    def userSlot(self):
        from View.UserView import UserView
        self.userView = UserView()
        self.userView.show()
        self.userView.exec_()

    @pyqtSlot()
    def pemeriksaanSlot(self):
        from View.PemeriksaanView import PemeriksaanView
        self.periksaView = PemeriksaanView()
        self.periksaView.show()
        self.periksaView.exec_()

    @pyqtSlot()
    def pemeriksaanNotif(self):
        from View.notificationView import notificationView
        self.notifView = notificationView()
        self.notifView.show()
        self.notifView.exec_()

    def hakAksesVisible(self):
        hakAkses = self.hakAkses.text()
        if (hakAkses == str(HakAkses.DOKTER)):
            self.btnUser.setVisible(False)
            self.btnObat.setVisible(False)
            self.btnApoteker.setVisible(False)
            self.btnDokter.setVisible(False)
            self.btnPasien.setVisible(False)
            self.framePemeriksaan.setVisible(False)
            self.frameTransaksi.setVisible(False)
        elif (hakAkses == str(HakAkses.APOTEKER)):
            self.btnUser.setVisible(False)
            self.btnnotification.setVisible(False)
            self.btnApoteker.setVisible(False)
            self.btnDokter.setVisible(False)
            self.btnPasien.setVisible(False)
            self.framePemeriksaan.setVisible(False)
            self.frameTransaksi.setVisible(False)
        else:
            self.btnnotification.setVisible(False)
Ejemplo n.º 6
0
 def __init__(self):
     self.loginView = LoginView()
     self.usuarioDTO = UsuarioDTO("", "")
Ejemplo n.º 7
0
class LoginController:
    def __init__(self):
        self.loginView = LoginView()
        self.usuarioDTO = UsuarioDTO("", "")

    def index(self):
        sair = False
        while sair == False:
            opcao = "a"
            hasCaracteresEspeciais = True
            hasCaracteresAlpha = True
            while (opcao.isalpha() or opcao == "" or hasCaracteresEspeciais
                   or hasCaracteresAlpha or
                   (opcao.isnumeric() and (int(opcao) < 1 or int(opcao) > 3))):
                opcao = self.loginView.index()
                hasCaracteresEspeciais = TextoUtil(
                ).verificarTextoComCaracteresEspeciais(opcao)
                hasCaracteresAlpha = TextoUtil().verificarTextoComAlpha(opcao)
                if (opcao == ""):
                    self.loginView.colocarMensagem(7)
                else:
                    if (hasCaracteresAlpha):
                        self.loginView.colocarMensagem(3)
                    else:
                        if (hasCaracteresEspeciais):
                            self.loginView.colocarMensagem(5)
                        else:
                            if (opcao.isnumeric()
                                    and (int(opcao) < 1 or int(opcao) > 3)):
                                self.loginView.colocarMensagem(4)
                            if (opcao.isalpha()):
                                self.loginView.colocarMensagem(3)
                            else:
                                if (int(opcao) == 1):
                                    self.acessarContaGmail()
                                elif (int(opcao) == 3):
                                    sair = True
            if (sair == False):
                principal = PrincipalController(self.usuarioDTO)

    def acessarContaGmail(self):
        sair = False
        teveErro = False
        while (sair == False):
            erroDeFormato = True
            email = ""
            senha = ""
            if (teveErro):
                self.loginView.mensagemErroAoLogar()
            while (erroDeFormato or email == ""):
                email = self.loginView.formularioEmail("", teveErro)
                teveErro = True
                if (email == "999"):
                    break
                if (email == ""):
                    self.loginView.colocarMensagem(7)
                else:
                    tuplaDeErro = Validador().validarEmail(email)
                    erroDeFormato = tuplaDeErro[0]
                    self.loginView.mensagem += tuplaDeErro[1]
            if (email == "999"):
                break
            while (senha == ""):
                self.loginView.formularioEmail(email)
                senha = self.loginView.formularioSenha()
                if (senha == ""):
                    self.loginView.colocarMensagem(2)
            self.usuarioDTO.email = email
            self.usuarioDTO.senha = senha
            enviarEmail = EnviarEmail()
            enviarEmail.setDadosRemetente(
                UsuarioDTO(self.usuarioDTO.email, self.usuarioDTO.senha))
            enviarEmail.setDadosDestinario("*****@*****.**",
                                           "Teste de Login")
            enviarEmail.setMensagem("Teste de Login")
            if (enviarEmail.enviarEmail() == 0):
                self.loginView.mensagemSucesso()
                self.usuarioDTO.logado = True
                sair = True
            elif (enviarEmail.enviarEmail() == 1):
                self.loginView.colocarMensagem(8)
                teveErro = True
            elif (enviarEmail.enviarEmail() == 2):
                self.loginView.colocarMensagem(9)
                teveErro = True
            else:
                self.loginView.colocarMensagem(999)
                teveErro = True
Ejemplo n.º 8
0
 def __init__(self, model):
     self.__model = model
     self.__view = LoginView(self, self.__model)
     self.__view.show()
Ejemplo n.º 9
0
from View.LoginView import LoginView

if __name__ == "__main__":
    login = LoginView()
    login.window_login()
Ejemplo n.º 10
0
 def logout(self):
     self.root.destroy()
     from View.LoginView import LoginView
     LoginView()
Ejemplo n.º 11
0
 def openlogout(self):
     from View.LoginView import LoginView
     self.loginview = LoginView()
     self.loginview.show()
     self.close()
Ejemplo n.º 12
0
class MainMenuView(QWidget):
    def __init__(self, username, hakakses):
        super().__init__()

        self.showMaximized()
        self.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False)
        self.setWindowTitle("MENU")

        frameheadBar = QFrameComponent("white")

        headBarLayout = QGridLayout(frameheadBar)
        headBarLayout.setSpacing(5)

        self.btnPetugas = QPushButtonComponent("Data Petugas")
        self.btnAnggota = QPushButtonComponent("Data Anggota")
        self.btnTransaksi = QPushButtonComponent("Transaksi")
        self.btnBuku = QPushButtonComponent("Data Buku")
        self.btnUser = QPushButtonComponent("Data User")
        self.btnLogOut = QPushButtonComponent("Log Out")
        self.hak_akses = QLabel(str(hakakses))
        self.username = QLabel(str(username))
        framebodybar = QFrameComponent("maroon")
        bodyBarLayout = QHBoxLayout(framebodybar)

        headBarLayout.addWidget(self.btnPetugas, 0, 1)
        headBarLayout.addWidget(self.btnAnggota, 0, 2)
        headBarLayout.addWidget(self.btnBuku, 0, 3)
        headBarLayout.addWidget(self.btnTransaksi, 0, 4)
        headBarLayout.addWidget(self.btnUser, 0, 5)
        headBarLayout.addWidget(self.btnLogOut, 0, 6, QtCore.Qt.AlignBottom)
        bodyBarLayout.addWidget(self.username)
        bodyBarLayout.addWidget(self.hak_akses)

        layoutUtama = QGridLayout()
        layoutUtama.addWidget(frameheadBar, 0, 1, 1, 10, QtCore.Qt.AlignTop)
        layoutUtama.addWidget(framebodybar, 2, 1, 1, 10)

        self.btnPetugas.clicked.connect(lambda: self.openpetugas())
        self.btnAnggota.clicked.connect(lambda: self.openanggota())
        self.btnBuku.clicked.connect(lambda: self.openbuku())
        self.btnUser.clicked.connect(lambda: self.openuser())
        self.btnTransaksi.clicked.connect(lambda: self.openpeminjaman())
        self.btnLogOut.clicked.connect(lambda: self.openlogout())
        self.cekhak_akses()
        self.setLayout(layoutUtama)
        self.show()

    def openpetugas(self):
        from View.PetugasView import PetugasView
        self.petugasview = PetugasView()
        self.petugasview.show()

    def openanggota(self):
        from View.AnggotaView import AnggotaView
        self.anggotaview = AnggotaView()
        self.anggotaview.show()

    def openbuku(self):
        from View.BukuView import BukuView
        self.bukuview = BukuView()
        self.bukuview.show()

    def openuser(self):
        from View.UserView import UserView
        self.userview = UserView()
        self.userview.show()

    def openpeminjaman(self):
        from View.PeminjamanView import PeminjamanView
        self.pinjamview = PeminjamanView()
        self.pinjamview.show()

    #
    # def openpengembalian(self):
    #     from View.PengembalianView import PengembalianView
    #     self.kembaliview = PengembalianView()
    #     self.kembaliview.show()
    #     self.kembaliview.exec_()
    #

    #
    def openlogout(self):
        from View.LoginView import LoginView
        self.loginview = LoginView()
        self.loginview.show()
        self.close()

    def cekhak_akses(self):
        hak_akses = self.hak_akses.text()
        if (hak_akses == str(HakAkses.Petugas)):
            self.btnPetugas.setVisible(False)
            self.btnUser.setVisible(False)
        elif (hak_akses == str(HakAkses.Admin)):
            self.btnPetugas.setVisible(True)
            self.btnUser.setVisible(True)