def search(self, values): connect = DBconnector() query = "SELECT * from " + self.table + " WHERE " for i in range(len(self.column)): query += self.column[i] + " LIKE '%" + values + "%' OR " query = query[:-3] connect.execute(query)
def cekamar(self): connect = DBconnector() query = "SELECT kamar.id,no_kamar,kelas.nama_kelas as kelas,kelas.harga,status.nama_status FROM kamar JOIN kelas ON kelas.id=kamar.kelas_id JOIN status ON status.id = kamar.status_id WHERE status.id = 2 ORDER BY no_kamar" result = connect.executeRead(query) t = PrettyTable( ["id", "no_kamar", "nama_kelas", "harga", "nama_status"]) for i in range(len(result)): t.add_row(result[i]) print(t)
def total(): connect = DBconnector() query = "SELECT nama,no_ktp,no_telp,alamat,kamar.no_kamar,kelas.nama_kelas,kelas.harga,transaksi.cek_out,DATEDIFF(cek_out,cek_in)as selisih,(DATEDIFF(cek_out,cek_in)*(kelas.harga))as TOTAL from transaksi JOIN kamar ON kamar.id = transaksi.kamar_id JOIN kelas ON kamar.kelas_id = kelas.id" result = connect.executeRead(query) print( "[nama][no_ktp][no_telepon][alamat][kamar][kelas][harga][cek_out][waktu][total]" ) for i in range(len(result)): print(result[i])
def update(self, values, inputanID): connect = DBconnector() query = "UPDATE " + self.table + " SET " for i in range(len(self.column)): query += self.column[i] + "=" query += "'" + values[i] + "'," query = query[:-1] query += " WHERE id ='%d'" % (inputanID) connect.execute(query) print("\t***UPDATE BERHASIL***")
def read(self): connect = DBconnector() query = "SELECT * from " + self.table result = connect.executeRead(query) x = ["id"] for j in range(len(self.column)): x.append(self.column[j]) t = PrettyTable(x) for i in range(len(result)): t.add_row(result[i]) print(t)
def insert(self, values): connect = DBconnector() query = "INSERT INTO " + self.table + " (" for column in self.column: query += column + "," query = query[:-1] query += ") VALUES (" for val in values: query += "'" + val + "'," query = query[:-1] query += ")" connect.execute(query) print("\t***INSERT BERHASIL***")
def login(inputuser, inputpassw): connect = DBconnector() query = "SELECT nama,role.nama_role FROM user JOIN role ON user.role_id = role.id WHERE username = '******' and passw ='%s'" % ( inputuser, inputpassw) result = connect.executeRead(query) if not result: return True else: print(result[0]) if (result[0][1]) == "RESEPSIONIS": main.menu_resepsionis() elif (result[0][1]) == "ADMIN": main.menu_admin()
def delete(self, inputanID): connect = DBconnector() query = "DELETE FROM " + self.table + " WHERE id = '%d'" % (inputanID) connect.execute(query) print("\t***DELETE BERHASIL***")
def update_statusada(self, kamar_id): connect = DBconnector() query = "SELECT no_kamar,kelas_id FROM kamar WHERE id = '%d'" % ( kamar_id) result = connect.executeRead(query) kamar().update([(result[0][0]), "1", (str(result[0][1]))], kamar_id)