def CBUsahaEnter(self): kode = self.comboBoxUsaha.currentText() sqld = "SELECT kodeItem, nama, qty, reportDetail.harga, subtotal FROM reportDetail,barang WHERE kodeProduk = '%s' AND kode = kodeItem"%kode bard, jumd = eksekusi(sqld) if jumd == 0: self.normal() self.comboBoxUsaha.setEnabled(False) else: self.comboBoxUsaha.setEnabled(False) self.pushButtonSimpan.setText('Update') sql = "SELECT hargaTotal, hargaJual FROM report WHERE kodeProduk = '%s'"%kode bar, jum = eksekusi(sql) self.lineEditTotal.setText(format(bar[0][0],',.2f')) self.lineEditHargaJual.setText(format(bar[0][1],',.0f')) self.tableWidget.setRowCount(jumd) for i in range(jumd): kodeItem = bard[i][0] nama = bard[i][1] qty = format(bard[i][2],',.2f') harga = format(bard[i][3],',.2f') subtotal = format(bard[i][4],',.2f') teks = (kodeItem, nama, qty, harga,subtotal) for c in range(len(teks)): item = QtGui.QTableWidgetItem() item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) item.setToolTip(teks[c]) item.setText(teks[c]) self.tableWidget.setItem(i, c, item) self.hitung() self.hitungProfit() self.comboBoxItem.setEnabled(True) self.comboBoxItem.setFocus()
def buatKode(self): kode = str(self.lineEditKode.text()) nama = str(self.lineEditNama.text()).replace(" ", "").replace( "'", "").upper()[:5] a = (re.sub('[, -:\".\']', '', nama)) if self.lineEditKode.isEnabled(): kode = kode else: sql = "SELECT kode FROM usaha WHERE kode LIKE '%s%%'" % a bar, jum = eksekusi(sql) if jum == 0: self.lineEditKode.setText(a + str(1)) else: self.lineEditKode.setText(a + str(jum + 1))
def isiTabel(self): sql = "SELECT kode, nama, keterangan FROM produk" bar, jum = eksekusi(sql) self.tableWidget.setRowCount(jum) for data in range(jum): kode = bar[data][0] nama = bar[data][1] keterangan = bar[data][2] teks = (kode, nama, keterangan) for i in range(len(teks)): item = QtGui.QTableWidgetItem() item.setText(str(teks[i])) self.tableWidget.setItem(data, i, item) self.warnaTabel()
def onKodeEnter(self): kode = str(self.lineEditKode.text()).upper() sql = "SELECT kode, nama, keterangan FROM produk WHERE kode = '%s'" % kode bar, jum = eksekusi(sql) if kode == "" or jum == 0: self.lineEditKode.setText("(menunggu...)") self.lineEditKode.setEnabled(False) self.lineEditNama.setEnabled(True) self.lineEditNama.setFocus() elif kode.isalnum() == False: self.errorinput() else: self.lineEditKode.setEnabled(False) self.lineEditNama.setEnabled(True) self.lineEditNama.setFocus() self.lineEditKode.setText(bar[0][0]) self.lineEditNama.setText(bar[0][1]) self.plainTextEdit.setPlainText(bar[0][2])
def isiTabel(self): sql = "SELECT kodeProduk, nama, hargaTotal, hargaJual FROM report, produk WHERE kodeProduk = kode" bar, jum = eksekusi(sql) self.tableWidgetUsaha.setRowCount(jum) for i in range(jum): kodeItem = bar[i][0] nama = bar[i][1] hargaTotal = format(bar[i][2],',.2f') hargaJual = format(bar[i][3],',.2f') teks = (kodeItem, nama, hargaTotal, hargaJual) for c in range(len(teks)): item = QtGui.QTableWidgetItem() item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) item.setToolTip(teks[c]) item.setText(teks[c]) self.tableWidgetUsaha.setItem(i, c, item) self.warnaTabel()
def isiTabel(self): sql = "SELECT kode, nama, model, harga, ada FROM barang" bar, jum = eksekusi(sql) self.tableWidget.setRowCount(jum) for data in range(jum): kode = bar[data][0] nama = bar[data][1] model = bar[data][2] harga = format(bar[data][3], ',.2f') if bar[data][4] == 1: ada = "Yes" else: ada = "-" teks = (kode, nama, model, harga, ada) for i in range(len(teks)): item = QtGui.QTableWidgetItem() item.setText(str(teks[i])) self.tableWidget.setItem(data, i, item) self.warnaTabel()
def onTabelKlik(self): r = self.tableWidgetUsaha.currentRow() kodeProduk = self.tableWidgetUsaha.item(r,0).text() sql = "SELECT kodeItem, barang.nama, qty, reportDetail.harga, Subtotal FROM reportDetail,barang WHERE kodeProduk = '%s' AND kode = kodeItem"%kodeProduk bar, jum = eksekusi(sql) self.tableWidgetItem.setRowCount(jum) for i in range(jum): kodeItem = bar[i][0] nama = bar[i][1] qty = format(bar[i][2],',.2f') harga = format(bar[i][3],',.2f') subtotal = format(bar[i][4],',.2f') teks = (kodeItem, nama, qty, harga, subtotal) for c in range(len(teks)): item = QtGui.QTableWidgetItem() item.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) item.setToolTip(teks[c]) item.setText(teks[c]) self.tableWidgetItem.setItem(i, c, item) self.warnaTabelItem()
def onKodeEnter(self): kode = str(self.lineEditKode.text()).upper() sql = "SELECT kode,nama,model,spesifikasi,harga,kelebihan,kekurangan,ada FROM barang WHERE kode = '%s'" % kode bar, jum = eksekusi(sql) if kode == "" or jum == 0: self.lineEditKode.setText("(menunggu...)") self.lineEditKode.setEnabled(False) self.lineEditNama.setEnabled(True) self.lineEditNama.setFocus() elif kode.isalnum() == False: self.errorinput() else: self.lineEditKode.setEnabled(False) self.lineEditNama.setEnabled(True) self.lineEditNama.setFocus() self.lineEditKode.setText(kode) self.lineEditNama.setText(bar[0][1]) self.lineEditModel.setText(bar[0][2]) self.plainTextEdit.setPlainText(bar[0][3]) self.lineEditHarga.setText(format(bar[0][4], ',.2f')) self.lineEditKelebihan.setText(bar[0][5]) self.lineEditKekurangan.setText(bar[0][6]) self.checkBox.setChecked(bar[0][7])
def namaUsaha(self): kode = self.comboBoxUsaha.currentText() sql = "SELECT nama FROM produk WHERE kode = '%s'"%kode bar, jum = eksekusi(sql) self.lineEditNamaUsaha.setText(bar[0][0])
def isiUsaha(self): sql = "SELECT kode FROM produk" bar, jum = eksekusi(sql) for i in range(jum): self.comboBoxUsaha.addItem(bar[i][0])
def namaItem(self): kode = self.comboBoxItem.currentText() sql = "SELECT nama, harga FROM barang WHERE kode = '%s'"%kode bar, jum = eksekusi(sql) self.lineEditNamaItem.setText(bar[0][0]) self.lineEditHarga.setText(format(bar[0][1],',.2f'))
def isiItem(self): sql = "SELECT kode FROM barang" bar, jum = eksekusi(sql) for i in range(jum): self.comboBoxItem.addItem(bar[i][0])