def deleteRecord(self): msg = QtGui.QMessageBox.question(self, 'Message', 'Are you sure to delete this record ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if msg == QtGui.QMessageBox.Yes: row = self.ui.tableWidget.currentRow() appInst.delete(self.tableName, self.primaryKeys[row]) appInst.updateTableViews()
def addRecord(self): try: self.getValues() appInst.insert(self.table, self.values) appInst.updateTableViews() self.close() except IntegrityError: showMessage('Error', 'The same record already exists')
def editRecord(self): values = dict() for i, edit in enumerate(self.edits): values[edit.field] = self.getValue(edit) if self.values[len(self.values) - 1]['name'] == 'state': values['state'] = self.values[len(self.values) - 1]['value'] appInst.update(self.table, self.keys, values) appInst.updateTableViews() self.close()
def editRecord(self): try: values = dict() for i, edit in enumerate(self.edits): values[edit.field] = self.getValue(edit) appInst.update(self.table, self.keys, values) appInst.updateTableViews() self.close() except IntegrityError: showMessage('Error', 'The same record already exists')
def deleteRecord(self): msg = QtGui.QMessageBox.question(self, 'Message', 'Are you sure to delete this record ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if msg == QtGui.QMessageBox.Yes: row = self.ui.tableWidget.currentRow() if len(dbi.session.execute(''' select 1 from tasks as a, projectemployees as b where a.projectId = b.projectId and a.employeeId = b.employeeId and a.state != %s''' % STAGE_TASK_FINISHED).fetchall()): raise DBException('There are unfinished tasks and on this project assigned on this employee ') appInst.delete(self.tableName, self.primaryKeys[row]) appInst.updateTableViews()
def deleteRecord(self): msg = QtGui.QMessageBox.question(self, 'Message', 'Are you sure to delete this record ?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No) if msg == QtGui.QMessageBox.Yes: row = self.ui.tableWidget.currentRow() if len(dbi.session.execute(''' select 1 from projectemployees as a, employees as b, contracts as c, projects as d where a.projectId = c.projectId and a.employeeId = b.id and b.companyId = c.companyId and c.id = %s''' % self.primaryKeys[row][0]['value']).fetchall()): raise DBException('There are employees of this company that are assigned on this project') appInst.delete(self.tableName, self.primaryKeys[row]) appInst.updateTableViews()