class ApotekerView(FormView): def __init__(self): super().__init__() self.setWindowTitle("APOTEKER FORM") # ========= THIRD LAYOUT ========= framelayout3 = QFrameReuse("white") framelayout3.setContentsMargins(25, 25, 25, 25) layout3 = QGridLayout(framelayout3) lbljudul3 = QLabelReuse("Data Apoteker", "rgb(0, 85, 255)") lblnoNip = QLabelReuse("\nNo NIP", "grey") lblnoNip.setFont(self.font) self.txtnoNip = EditLineReuse("") # ========== EVENT SECTION ========= self.btnTambah.clicked.connect(lambda: self.insertData()) # =========== LAYOUT SECTION ======== layout3.addWidget(lbljudul3, 0, 0, 1, 3, Qt.AlignLeft) layout3.addWidget(lblnoNip, 1, 0, 1, 3, Qt.AlignLeft) layout3.addWidget(self.txtnoNip, 2, 0, 2, 3) self.layoutUtama.addWidget(framelayout3, 3, 0, 1, 9) @pyqtSlot() def insertData(self): super(ApotekerView, self).insertData() self.noNip = self.txtnoNip.text() apoteker = Apoteker(self.nama, self.alamat, self.jenisKelamin, self.noTelp, self.tanggalLahir, self.noNip) try: ApotekerOrm.insertApoteker(apoteker) 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 clear(self): super(ApotekerView, self).clear() self.txtnoNip.setText("") self.txtnama.setFocus()
class UserView(QDialog): def __init__(self): super().__init__() self.setWindowTitle("USER FORM.") self.resize(1400, 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 = QFrameReuse("white") framelayout1.setContentsMargins(25, 25, 25, 25) layout1 = QGridLayout(framelayout1) lbljudul = QLabelReuse("Data User", "rgb(0, 85, 255)") lblusername = QLabelReuse("\nUsername\n", "grey") lblusername.setFont(self.font) self.txtusername = EditLineReuse("") lblpassword = QLabelReuse("\n\nPassword\n", "grey") lblpassword.setFont(self.font) self.txtpassword = EditLineReuse("") lblhakAkses = QLabelReuse("\nHak Akses\n", "grey") lblhakAkses.setFont(self.font) self.cmbhakAkses = QComboBoxReuse() self.cmbhakAkses.addItems(['DOKTER', 'APOTEKER']) self.pilHakAkses = [HakAkses.DOKTER, HakAkses.APOTEKER] # ======== CRUD BUTTON =========== frameCrudSection = QFrameReuse("white") frameCrudSection.setContentsMargins(5, 5, 5, 5) layoutCrudSection = QHBoxLayout(frameCrudSection) self.btnTambah = QPushButtonReuse("", "assets/img/button.png") self.btnTambah.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnTambah.setIconSize(QtCore.QSize(75, 54)) self.btnView = QPushButtonReuse("", "assets/img/view62.png") self.btnView.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnView.setIconSize(QtCore.QSize(75, 54)) # ========== EVENT SECTION ========= self.btnTambah.clicked.connect(lambda: self.insertData()) self.btnView.clicked.connect(lambda: self.viewDataEvent()) # ======== LAYOUT SECTION ====== self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignVCenter) self.layoutUtama.addWidget(frameCrudSection, 5, 0, 1, 9, Qt.AlignBottom | Qt.AlignRight) 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(lblpassword, 4, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(self.txtpassword, 5, 0, 2, 3) layout1.addWidget(lblhakAkses, 1, 5, 1, 3) layout1.addWidget(self.cmbhakAkses, 2, 5, 2, 3) layoutCrudSection.addWidget(self.btnView) layoutCrudSection.addWidget(self.btnTambah) self.setLayout(self.layoutUtama) self.show() @pyqtSlot() def insertData(self): self.username = self.txtusername.text() self.password = self.txtpassword.text() self.hakAkses = self.pilHakAkses[self.cmbhakAkses.currentIndex()] user = User(self.username, self.password, self.hakAkses) try: UserOrm.insertUser(user) 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() @pyqtSlot() def viewDataEvent(self): from View.UserViewContent import UserContentView self.viewData = UserContentView() self.viewData.show() self.viewData.exec_() def clear(self): self.txtusername.setText("") self.txtpassword.setText("") self.cmbhakAkses.setCurrentIndex(0) self.txtusername.setFocus()
class PemeriksaanView(QDialog): def __init__(self): super(PemeriksaanView, self).__init__() self.setWindowTitle("PEMERIKSAAN FORM") self.resize(1400, 700) self.setModal(True) # ======== 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 = QFrameReuse("white") framelayout1.setContentsMargins(25, 25, 25, 25) layout1 = QGridLayout(framelayout1) lbljudul = QLabelReuse("Data Pemeriksaan", "rgb(0, 85, 255)") lblpasien = QLabelReuse("\nPilih Pasien\n", "grey") lblpasien.setFont(self.font) itempasien = PasienOrm.showPasienIdNama() self.cmbpasien = QComboBoxReuse() for idpasien,namapasien in itempasien: self.cmbpasien.addItem(idpasien+" "+ namapasien, idpasien) lblalamat = QLabelReuse("\n\nStatus Pemeriksaan\n", "grey") lblalamat.setFont(self.font) self.txtalamat = EditLineReuse("") self.txtalamat.setText("BELUM DIPERIKSA") self.txtalamat.setEnabled(False) lbldokter = QLabelReuse("\nPilih Dokter\n", "grey") lbldokter.setFont(self.font) itemdokter = DokterOrm.showDokterIdNama() self.cmbdokter = QComboBoxReuse() for id, nama in itemdokter: self.cmbdokter.addItem(id +" "+ nama, id) lbltanggalLahir = QLabelReuse("\n\nTanggal Pemeriksaan\n", "grey") lbltanggalLahir.setFont(self.font) self.dateTglLahir = QDateEdit() self.dateTglLahir.setStyleSheet("border : 0;\n" "outline : 0;\n" "border-bottom : 2px solid rgb(0, 85, 255);") self.dateTglLahir.setDisplayFormat("dd - MMM - yyyy") self.dateTglLahir.setDate(date.today()) self.dateTglLahir.setEnabled(False) font2 = QtGui.QFont() font2.setFamily("Product Sans") font2.setPointSize(14) font2.setBold(True) font2.setWeight(75) self.dateTglLahir.setFont(font2) # ======== CRUD BUTTON =========== frameCrudSection = QFrameReuse("white") frameCrudSection.setContentsMargins(5, 5, 5, 5) layoutCrudSection = QHBoxLayout(frameCrudSection) self.btnTambah = QPushButtonReuse("", "assets/img/button.png") self.btnTambah.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnTambah.setIconSize(QtCore.QSize(75, 54)) self.btnView = QPushButtonReuse("", "assets/img/view62.png") self.btnView.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnView.setIconSize(QtCore.QSize(75, 54)) # ========== EVENT SECTION ========= self.btnTambah.clicked.connect(lambda: self.insertData()) # ======== LAYOUT SECTION ====== self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignTop) self.layoutUtama.addWidget(frameCrudSection, 5, 0, 1, 9, Qt.AlignBottom | Qt.AlignRight) self.layoutUtama.setContentsMargins(35, 35, 35, 35) layout1.addWidget(lbljudul, 0, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(lblpasien, 1, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(self.cmbpasien, 2, 0, 2, 3) layout1.addWidget(lblalamat, 4, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(self.txtalamat, 5, 0, 2, 3) layout1.addWidget(lbldokter, 1, 5, 1, 3) layout1.addWidget(self.cmbdokter, 2, 5, 2, 3) layout1.addWidget(lbltanggalLahir, 4, 5, 1, 3, Qt.AlignLeft) layout1.addWidget(self.dateTglLahir, 5, 5, 2, 3) layoutCrudSection.addWidget(self.btnView) layoutCrudSection.addWidget(self.btnTambah) self.setLayout(self.layoutUtama) self.show() @pyqtSlot() def insertData(self): self.pasien = self.cmbpasien.itemData(self.cmbpasien.currentIndex()) self.dokter = self.cmbdokter.itemData(self.cmbdokter.currentIndex()) self.status = self.txtalamat.text() pemeriksaan = Pemeriksaan(self.pasien, self.dokter, self.status) try: PemeriksaanOrm.insertPemeriksaan(pemeriksaan) 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_()
class LoginView(QWidget): def __init__(self): super().__init__() self.resize(1136, 833) self.setWindowTitle("LOGIN PUSKESMAS") # =========== LAYOUT 1 SECTION =========== lbllogo = QLabelReuse("", "") lbllogo.setPixmap(QtGui.QPixmap("assets/img/lung.svg")) lbllogo.setAlignment(QtCore.Qt.AlignCenter) lblPresentBy = QLabelReuse("PRESENT BY", "black") lblPresentBy.setAlignment(QtCore.Qt.AlignCenter) lblCredit = QLabelReuse( "-> Mohammad Fahmi -> Pramana Ade Putra\n" "-> M.Rizqi Nugraha -> Sakti Pujo Edi", "grey") lblCredit.setAlignment(QtCore.Qt.AlignCenter) # =========== LAYOUT 2 SECTION =========== lbljudul = QLabelReuse("PUSKESMAS", "black") font = QtGui.QFont() font.setFamily("Harlow Solid Italic") font.setPointSize(24) font.setBold(True) font.setWeight(50) lbljudul.setFont(font) lbljudul.setAlignment(QtCore.Qt.AlignCenter) lblusername = QLabelReuse("Username", "grey") lblpassword = QLabelReuse("Password", "grey") self.txtUsername = EditLineReuse("") self.txtpassword = EditLineReuse("") self.txtpassword.setEchoMode(QLineEdit.Password) self.btnLogin = QPushButtonReuse("Login", "") self.btnLogin.clicked.connect(lambda: self.buttonClick()) # =========== 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) 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 Atau Password Salah!") msg.setWindowTitle("LOGIN SALAH") msg.exec_() @pyqtSlot() def switchMainMenu(self): username = self.txtUsername.text() hakAkses = UserOrm.findHakAkses(username) self.mainMenu = MainMenuView(username.upper(), hakAkses) self.mainMenu.show() self.hide() def clear(self): self.txtUsername.setText("") self.txtpassword.setText("") self.txtUsername.setFocus()
class ObatView(QDialog): def __init__(self): super().__init__() self.resize(1400, 700) self.setWindowTitle("FORM OBAT") self.setModal(True) # ======== 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 = QFrameReuse("white") framelayout1.setContentsMargins(25, 25, 25, 25) layout1 = QGridLayout(framelayout1) lbljudul = QLabelReuse("Data Obat", "rgb(0, 85, 255)") lblnamaObat = QLabelReuse("\nNama Obat\n", "grey") lblnamaObat.setFont(self.font) self.txtnamaObat = EditLineReuse("") lbljenisObat = QLabelReuse("\nJenis Obat\n", "grey") lbljenisObat.setFont(self.font) self.cmbJenisObat = QComboBoxReuse() self.cmbJenisObat.addItems(['SERBUK', 'TABLET', 'PIL', 'KAPSUL', 'SYRUP', 'SALEP', 'INJEKSI']) self.pilJenObat = [JenisObat.SERBUK, JenisObat.TABLET, JenisObat.PIL, JenisObat.KAPSUL, JenisObat.SYRUP, JenisObat.SALEP, JenisObat.INJEKSI] # ======== SECOND LAYOUT ======= framelayout2 = QFrameReuse("white") framelayout2.setContentsMargins(25, 25, 25, 25) layout2 = QGridLayout(framelayout2) lbljudul2 = QLabelReuse("Inventaris Obat", "rgb(0, 85, 255)") lblstockObat = QLabelReuse("\nStock Obat", "grey") lblstockObat.setFont(self.font) self.txtstockObat = EditLineReuse("") lblhargaObat = QLabelReuse("\nHarga Obat", "grey") lblhargaObat.setFont(self.font) self.txthargaObat = EditLineReuse("") lbllokasiObat = QLabelReuse("\nLokasi Penyimpanan", "grey") lbllokasiObat.setFont(self.font) self.txtlokasiObat = EditLineReuse("") # ======== ADD DATA =========== self.btnTambah = QPushButtonReuse("", "assets/img/button.png") self.btnTambah.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnTambah.setIconSize(QtCore.QSize(75, 54)) # ========== EVENT SECTION ========= self.btnTambah.clicked.connect(lambda: self.insertData()) # ======== LAYOUT SECTION ====== self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignTop) self.layoutUtama.addWidget(framelayout2, 2, 0, 1, 9) self.layoutUtama.addWidget(self.btnTambah, 5, 0, 1, 9, Qt.AlignBottom | Qt.AlignRight) layout1.addWidget(lbljudul, 0, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(lbljenisObat, 1, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(self.cmbJenisObat, 2, 0, 2, 3) layout1.addWidget(lblnamaObat, 1, 5, 1, 3) layout1.addWidget(self.txtnamaObat, 2, 5, 2, 3) layout2.addWidget(lbljudul2, 0, 0, 1, 3, Qt.AlignLeft) layout2.addWidget(lblstockObat, 1, 0, 1, 3, Qt.AlignLeft) layout2.addWidget(self.txtstockObat, 2, 0, 2, 3) layout2.addWidget(lblhargaObat, 4, 0, 1, 3, Qt.AlignLeft) layout2.addWidget(self.txthargaObat, 5, 0, 2, 3) layout2.addWidget(lbllokasiObat, 1, 5, 1, 3) layout2.addWidget(self.txtlokasiObat, 2, 5, 1, 3) self.setLayout(self.layoutUtama) self.show() @pyqtSlot() def insertData(self): self.jenisObat = self.pilJenObat[self.cmbJenisObat.currentIndex()] self.namaObat = self.txtnamaObat.text() self.stockObat = self.txtstockObat.text() self.hargaObat = self.txthargaObat.text() self.lokasi = self.txtlokasiObat.text() obat = Obat(self.jenisObat, self.namaObat) try: ObatOrm.insertObat(obat) 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: try: idObat = ObatOrm.findLatest() inv = InventarisObat(idObat, self.stockObat, self.hargaObat, self.lokasi) InventarisObatOrm.insertInvenObat(inv) except Exception as e: msg = QMessageBox() msg.resize(250, 250) msg.setIcon(QMessageBox.Warning) msg.setText("Something Wrong", e) msg.setWindowTitle("GAGAL") msg.exec_() msg = QMessageBox() msg.resize(250, 250) msg.setIcon(QMessageBox.Information) msg.setText("Data Berhasil Di Input!") msg.setWindowTitle("BERHASIL") msg.exec_() self.clear() def clear(self): self.txtnamaObat.setText("") self.txtstockObat.setText("") self.cmbJenisObat.setCurrentIndex(0) self.txtlokasiObat.setText("") self.txthargaObat.setText("") self.txtnamaObat.setFocus()
class FormView(QDialog): def __init__(self): super().__init__() self.resize(1400, 700) self.setModal(True) # ======== 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 = QFrameReuse("white") framelayout1.setContentsMargins(25, 25, 25, 25) layout1 = QGridLayout(framelayout1) lbljudul = QLabelReuse("Data Diri", "rgb(0, 85, 255)") lblnama = QLabelReuse("\nNama Lengkap\n", "grey") lblnama.setFont(self.font) self.txtnama = EditLineReuse("") lblalamat = QLabelReuse("\n\nAlamat\n", "grey") lblalamat.setFont(self.font) self.txtalamat = EditLineReuse("") lbljenisKelamin = QLabelReuse("\nJenis Kelamin\n", "grey") lbljenisKelamin.setFont(self.font) self.cmbJenisKelamin = QComboBoxReuse() self.cmbJenisKelamin.addItems(['LAKI-LAKI', 'PEREMPUAN']) self.pilJekel = [JenisKelamin.LAKI_LAKI, JenisKelamin.PEREMPUAN] lbltanggalLahir = QLabelReuse("\n\nTanggal Lahir\n", "grey") lbltanggalLahir.setFont(self.font) self.dateTglLahir = QDateEdit() self.dateTglLahir.setStyleSheet( "border : 0;\n" "outline : 0;\n" "border-bottom : 2px solid rgb(0, 85, 255);") self.dateTglLahir.setDisplayFormat("dd - MMM - yyyy") self.dateTglLahir.setCalendarPopup(True) font2 = QtGui.QFont() font2.setFamily("Product Sans") font2.setPointSize(14) font2.setBold(True) font2.setWeight(75) self.dateTglLahir.setFont(font2) # ======== SECOND LAYOUT ======= framelayout2 = QFrameReuse("white") framelayout2.setContentsMargins(25, 25, 25, 25) layout2 = QGridLayout(framelayout2) lbljudul2 = QLabelReuse("Contact Information", "rgb(0, 85, 255)") lblnoHp = QLabelReuse("\nNo Hp", "grey") lblnoHp.setFont(self.font) self.txtnoHp = EditLineReuse("+62") # ======== CRUD BUTTON =========== frameCrudSection = QFrameReuse("white") frameCrudSection.setContentsMargins(5, 5, 5, 5) layoutCrudSection = QHBoxLayout(frameCrudSection) self.btnTambah = QPushButtonReuse("", "assets/img/button.png") self.btnTambah.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnTambah.setIconSize(QtCore.QSize(75, 54)) self.btnView = QPushButtonReuse("", "assets/img/view62.png") self.btnView.setStyleSheet("background-color : rgb(0, 85, 255);\n" "height : 80%;\n") self.btnView.setIconSize(QtCore.QSize(75, 54)) # ======== LAYOUT SECTION ====== self.layoutUtama.addWidget(framelayout1, 0, 0, 1, 9, Qt.AlignTop) self.layoutUtama.addWidget(framelayout2, 2, 0, 1, 9) self.layoutUtama.addWidget(frameCrudSection, 5, 0, 1, 9, Qt.AlignBottom | Qt.AlignRight) self.layoutUtama.setContentsMargins(35, 35, 35, 35) 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(lblalamat, 4, 0, 1, 3, Qt.AlignLeft) layout1.addWidget(self.txtalamat, 5, 0, 2, 3) layout1.addWidget(lbljenisKelamin, 1, 5, 1, 3) layout1.addWidget(self.cmbJenisKelamin, 2, 5, 2, 3) layout1.addWidget(lbltanggalLahir, 4, 5, 1, 3, Qt.AlignLeft) layout1.addWidget(self.dateTglLahir, 5, 5, 2, 3) layout2.addWidget(lbljudul2, 0, 0, 1, 3, Qt.AlignLeft) layout2.addWidget(lblnoHp, 1, 0, 1, 3, Qt.AlignLeft) layout2.addWidget(self.txtnoHp, 2, 0, 2, 3) layoutCrudSection.addWidget(self.btnView) layoutCrudSection.addWidget(self.btnTambah) self.setLayout(self.layoutUtama) self.show() @pyqtSlot() def insertData(self): self.nama = self.txtnama.text() self.alamat = self.txtalamat.text() self.jenisKelamin = self.pilJekel[self.cmbJenisKelamin.currentIndex()] self.tanggalLahir = self.dateTglLahir.date().toPyDate() self.noTelp = self.txtnoHp.text() def clear(self): self.txtnama.setText("") self.txtalamat.setText("") self.cmbJenisKelamin.setCurrentIndex(0) self.txtnoHp.setText("")