def cargarviewtbarniz(self): self.modeltbarniz = QtSql.QSqlTableModel(self) self.modeltbarniz.setTable("tipo_barniz") listaref = self.cadenadereferencias( DAO.TBarnizFicha().leerTBarnizEnFicha(self.edicion)) self.modeltbarniz.setFilter("idTBarniz in {0}".format(listaref)) self.modeltbarniz.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit) self.modeltbarniz.select() self.ui.viewTipoBarniz.setModel(self.modeltbarniz) self.ui.viewTipoBarniz.hideColumn(0) pass
def deleteRecordsTBarniz(self): try: fila = [] for col in range(self.modeltbarniz.columnCount()): index = self.modeltbarniz.index( self.ui.viewTipoBarniz.currentIndex().row(), col) fila.append(str(self.modeltbarniz.data(index).toString())) tbarniz = DTO.TipoBarniz() tbarniz.setIdTBarniz(fila[0]) DAO.TBarnizFicha().eliminarReferencia(fila[0], self.edicion) DAO.TipoBarniz(tbarniz).eliminarTBarniz() except Exception as e: MostrarError(str(e.message)) else: self.modeltbarniz.submitAll()
def insertRecordsTBarniz(self): try: tbarniz = DTO.TipoBarniz() tbarniz.setProveedor(self.ui.leProveedorTBarnizMod.text()) tbarniz.setTipo(self.ui.leTipoTBarnizMod.text()) tbarniz.setAnilox(self.ui.leAniloxTBarnizMod.text()) DAO.TipoBarniz(tbarniz).ingresarTBarniz() "crear referencia de forma inmediata" tbf = DAO.TBarnizFicha() tbf.setIdFicha(self.edicion) tbf.setIdTBarniz(DAO.TipoBarniz().idUltimoTBarniz()) tbf.insertarTBarnizFicha() self.cargarviewtbarniz() except Exception as e: MostrarError(str(e.message)) else: self.modeltbarniz.submitAll()