def readMenuItem(): try: session = SessionFactory() for item in session.query(MenuItemOrm).all(): print("ID = {},Nama Item = {}, Jenis Item = {}, Merek Item = {}, Harga Item = {}, Kuantitas Item = {}" .format(item.id, item.namaItem, item.jenisItem.name, item.merekItem, item.hargaItem, item.kuantitasItem)) except Exception as e: print("Error -->", e)
def readKas(): try: session = SessionFactory() for item in session.query(KasOrm).all(): print( "Id Kas = {}\nTanggal = {}\nPemasukan = {}\nPengeluaran = {}\nLaba Bersih = {}\n" .format(item.id, item.labaBersih)) except Exception as e: print("-->", e)
def read(): try: session = SessionFactory() for admin in session.query(AdminOrm).all(): print("ID = {}, Nama = {}, Email = {}, Password = {}, Jenis Akun = {}".format(admin.id, admin.nama, admin.email, admin.password, admin.jenisAkun.name)) except Exception as e: print("Error -->", e)
def readTransaksi(): try: session = SessionFactory() for transaksi in session.query(TransaksiOrm).all(): print( "ID = {}, Tanggal = {}, Jenis Transaksi = {}, Total Transaksi = {}" .format(transaksi.id, transaksi.tanggalTransaksi, transaksi.jenisTransaksi, transaksi.totalTransaksi)) except Exception as e: print("Error -->", e)
def read(): try: session = SessionFactory() for pembeli in session.query(PembeliOrm).all(): print("ID = {}, Nama = {}, Email = {}, Password = {}, Jenis Akun = {}, saldo = {}".format(pembeli.id, pembeli.nama, pembeli.email, pembeli.password, pembeli.jenisAkun, pembeli.saldo)) except Exception as e: print("Error -->", e)
def read(): try: session = SessionFactory() for penjual in session.query(PenjualOrm).all(): print("ID = {}, Nama = {}, Email = {}, Password = {}, Jenis Akun = {}, saldo = {}, menu = {}".format( penjual.id, penjual.nama, penjual.email, penjual.password, penjual.jenisAkun, penjual.saldo, penjual.menu)) except Exception as e: print("Error -->", e)
def deleteKas(id): try: session = SessionFactory() session.query(KasOrm).filter_by(id=id).delete() session.commit() session.close() except Exception as e: print("-->", e) else: print("Hapus Berhasil")
def deleteMenuItem(x): try: session = SessionFactory() session.query(MenuItemOrm).filter_by(id=x).delete() session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Delete Berhasil")
def insert(self): try: session = SessionFactory() session.add(AdminOrm(self.nama, self.email, self.password, self.jenisAkun)) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Insert Berhasil")
def insertMenuItem(self, ): try: session = SessionFactory() menuItemOrm = MenuItemOrm(self.getNamaItem(), self.getJenisItem(), self.getMerekItem(), self.getHargaItem(), self.getKuantitasItem()) session.add(menuItemOrm) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Insert Berhasil")
def insertKas(self): try: session = SessionFactory() kasOrm = KasOrm(self.getTglKas(), self.getPemasukan(), self.getPengeluaran(), self.hitungLabaBersih()) session.add(kasOrm) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Insert Berhasil")
def update(x): try: dNama = input("Masukkan Nama Baru: ") session = SessionFactory() session.query(AdminOrm).filter_by(id=x).update({ AdminOrm.nama: dNama }, synchronize_session=False) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Update Berhasil")
def insertTransaksi(self): try: session = SessionFactory() trsOrm = TransaksiOrm(self.getTanggalTransaksi(), self.getJenisTransaksi(), self.getTotalTransaksi()) session.add(trsOrm) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Insert Berhasil")
def login(self): session = SessionFactory() query1 = session.query(AdminOrm).filter_by(email=self.__emailLogin).first() query2 = session.query(PenjualOrm).filter_by(email=self.__emailLogin).first() query3 = session.query(PembeliOrm).filter_by(email=self.__emailLogin).first() if query1 != None: if query1.email == self.__emailLogin and query1.password == self.__passwordLogin: self.__statusLogin = True self.__roleLogin = query1.jenisAkun elif query2 != None: if query2.email == self.__emailLogin and query2.password == self.__passwordLogin: self.__statusLogin = True self.__roleLogin = query2.jenisAkun elif query3 != None: if query3.email == self.__emailLogin and query3.password == self.__passwordLogin: self.__statusLogin = True self.__roleLogin = query3.jenisAkun else: print('Email %s not found' % (self.__emailLogin)) self.__statusLogin = False print(self.__statusLogin)
def updateTransaksi(x): try: dTotal = input("Masukkan Total Transaksi Baru: ") session = SessionFactory() session.query(TransaksiOrm).filter_by(id=x).update( { TransaksiOrm.tanggalTransaksi: datetime.now().date(), TransaksiOrm.totalTransaksi: dTotal }, synchronize_session=False) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Update Berhasil")
def updateKas(id): try: newPemasukan = input("Masukkan Jumlah Pemasukan: ") newPengeluaran = input("Masukkan Jumlah Pengeluaran: ") session = SessionFactory() session.query(KasOrm).filter_by(id=id).update( { KasOrm.pemasukan: newPemasukan, KasOrm.pengeluaran: newPengeluaran }, synchronize_session=False) session.commit() session.close() except Exception as e: print("-->", e) else: print("Update Berhasil")
def updateMenuItem(x): try: dNama = input("Masukkan Nama Baru: ") djenisItem = int(input("Masukkan Jenis Item Baru (1/2): ")) dmerekItem = input("Masukkan Merek Item Baru: ") dhargaItem = input("Masukkan Harga Item Baru: ") dkuantitasItem = input("Masukkan Kuantitas Item Baru: ") session = SessionFactory() session.query(MenuItemOrm).filter_by(id=x).update({ MenuItemOrm.namaItem: dNama, MenuItemOrm.jenisItem: JenisItem(djenisItem), MenuItemOrm.merekItem: dmerekItem, MenuItemOrm.hargaItem: dhargaItem, MenuItemOrm.kuantitasItem: dkuantitasItem }, synchronize_session=False) session.commit() session.close() except Exception as e: print("Error -->", e) else: print("Update Berhasil")