def cargarviewtroquel(self): self.modeltroquel = QtSql.QSqlTableModel(self) self.modeltroquel.setTable("troquel") listaref = self.cadenadereferencias( DAO.TroquelFicha().leerTroquelEnFicha(self.edicion)) self.modeltroquel.setFilter("idTroquel in {0}".format(listaref)) self.modeltroquel.setEditStrategy(QtSql.QSqlTableModel.OnManualSubmit) self.modeltroquel.select() self.ui.viewTroquel.setModel(self.modeltroquel) self.ui.viewTroquel.hideColumn(0) pass
def deleteRecordsTroquel(self): try: fila = [] for col in range(self.modeltroquel.columnCount()): index = self.modeltroquel.index( self.ui.viewTroquel.currentIndex().row(), col) fila.append(str(self.modeltroquel.data(index).toString())) troquel = DTO.Troquel() troquel.setIdTroquel(fila[0]) DAO.TroquelFicha().eliminarReferencia(fila[0], self.edicion) DAO.Troquel(troquel).eliminarTroquel() except Exception as e: MostrarError(str(e.message)) else: self.modeltroquel.submitAll()
def insertRecordsTroquel(self): try: troquel = DTO.Troquel() troquel.setProveedor(self.ui.leProveedorTroquelMod.text()) DAO.Troquel(troquel).ingresarTroquel() "crear referencia de forma inmediata" trf = DAO.TroquelFicha() trf.setIdFicha(self.edicion) trf.setIdTroquel(DAO.Troquel().idUltimoTroquel()) trf.insertarTroquelFicha() self.cargarviewtroquel() except Exception as e: MostrarError(str(e.message)) else: self.modeltroquel.submitAll()