def on_tableView_currentChanged(self, index1, index2): if index2.row() != -1: if self.checkDirty(): self.saveRight(index2) uid = self.dataInfo.DataRows[index1.row()].Data(0) ins_sql = """ INSERT INTO sysuserright (fUserID, fRightID, fHasRight) SELECT {uid}, fNMID, fDefault FROM sysnavigationmenus WHERE fEnabled = 1 AND NOT fNMID IN ( SELECT fRightID FROM sysuserright WHERE fUserID = {uid})""" sql = """ SELECT u.fUsername, m.*, ord(ur.fHasRight) AS fHasRight FROM sysnavigationmenus m LEFT JOIN sysuserright ur ON m.fNMID = ur.fRightID LEFT JOIN sysusers u ON ur.fUserID = u.fUserID WHERE ur.fUserID = {} AND ord(m.fEnabled) = 1 ORDER BY fDispIndex """ db = JPDb() db.executeTransaction(ins_sql.format(uid=uid)) items = db.getDict(sql.format(uid)) self.ui.treeWidget.itemChanged.disconnect(self.onItemChanged) loadTreeview(self.ui.treeWidget, items) self.ui.treeWidget.itemChanged.connect(self.onItemChanged)
def on_CmdSubmit_clicked(self): cu_id = self.getCurrentSelectPKValue() if not cu_id: return db = JPDb() info = self.model.TabelFieldInfo submitted = info.getOnlyData([ self.tableView.selectionModel().currentIndex().row(), self.fSubmited_column ]) if submitted == 1: msg = '记录【{cu_id}】已经提交,不能重复提交!\nThe order [{cu_id}] ' msg = msg + 'has been submitted, can not be repeated submission!' msg = msg.replace("{cu_id}", str(cu_id)) QMessageBox.warning(self, '提示', msg, QMessageBox.Ok, QMessageBox.Ok) return msg = '提交后订单将不能修改!确定继续提交记录【{cu_id}】吗?\n' msg = msg + 'The order "{cu_id}" will not be modified after submission. ' msg = msg + 'Click OK to continue submitting?' msg = msg.replace("{cu_id}", str(cu_id)) reply = QMessageBox.question(self, '确认', msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: sql = "update {tn} set fSubmited=1 where {pk_n}='{pk_v}';" sql1 = "select '{pk_v}';" sql = sql.format(tn=self.EditFormMainTableName, pk_n=self.EditFormPrimarykeyFieldName, pk_v=cu_id) db.executeTransaction([sql, sql1.format(pk_v=cu_id)]) JPPub().broadcastMessage(tablename="t_order", PK=cu_id, action='Submit') self.refreshListForm()
def on_CmdSubmit_clicked(self): cu_id = self.getCurrentSelectPKValue() if not cu_id: return db = JPDb() info = self.model.TabelFieldInfo submitted = info.getOnlyData([ self.tableView.selectionModel().currentIndex().row(), self.fSubmited_column ]) if submitted == 1: msg = '记录【{cu_id}】已经提交,不能重复提交!\nThe order [{cu_id}] ' msg = msg + 'has been submitted, can not be repeated submission!' msg = msg.replace("{cu_id}", str(cu_id)) QMessageBox.warning(self, '提示', msg, QMessageBox.Ok, QMessageBox.Ok) return msg = '提交后出库单将不能修改!确定继续提交记录【{cu_id}】吗?\n' msg = msg + 'The order "{cu_id}" will not be modified after submission. ' msg = msg + 'Click OK to continue submitting?' msg = msg.replace("{cu_id}", str(cu_id)) reply = QMessageBox.question(self, '确认', msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: sql0 = f"""UPDATE t_product_outbound_order set fSubmited=1 where fOrderID='{cu_id}';""" sql2 = "select '{cu_id}';" db.executeTransaction([sql0, sql2]) JPPub().broadcastMessage(tablename="t_product_outbound_order", PK=cu_id, action='Submit') self.refreshListForm()
def on_CmdDelete_clicked(self): cu_id = self.getCurrentSelectPKValue() if not cu_id: return if self.beforeDeleteRow(cu_id): msg = "确认要删除记录【{}】吗?".format(cu_id) if QMessageBox.question(self, '确认', msg, QMessageBox.Yes, QMessageBox.Yes) == QMessageBox.Yes: db = JPDb() info = self.model.TabelFieldInfo sql = "delete from {tn} where {pk_n}='{pk_v}'" sql = sql.format(tn=self.EditFormMainTableName, pk_n=self.EditFormPrimarykeyFieldName, pk_v=cu_id) if db.executeTransaction(sql): del_i = ( self.tableView.selectionModel().currentIndex().row()) info.deleteRow(del_i)
def tryNumberControl(self, obj): obj_cus = self.ui.fCustomerID obj_esp = self.ui.fEspecieID nm = obj.objectName() if nm == 'fCustomerID': c_id = self.ui.fCustomerID.Value() sql = f'''select fNUIT,fCity,fContato,fAreaCode, fCelular,fTelefone,fEndereco,fEmail, fWeb,fFax,fNote,fTaxRegCer from t_customer where fCustomerID={c_id}''' dic = JPDb().getDict(sql)[0] self.ui.fCelular.refreshValueNotRaiseEvent(dic['fCelular'], True) self.ui.fContato.refreshValueNotRaiseEvent(dic['fContato'], True) self.ui.fTelefone.refreshValueNotRaiseEvent(dic['fTelefone'], True) self.ui.fNUIT.setText(dic['fNUIT']) self.ui.fCity.setText(dic['fCity']) self.ui.fEndereco.setText(dic['fEndereco']) self.ui.fEmail.setText(dic['fEmail']) ID = dic['fTaxRegCer'] ZT = True if ID else False self.ui.butTaxCer.setEnabled(ZT) self.ui.butTaxCer.ID = ID # 判断是否需要单据管理,不需要管理则退出 if obj_cus.currentIndex() == -1 or obj_esp.currentIndex() == -1: self.setNumberNeedControl(False) return else: if obj_esp.currentData()[2] != '1': self.setNumberNeedControl(False) return # 需要管理情况下: # 新增状态 # 检查数据库中是否存在同客户同类型未确认的单据 # 如果有,则清除当前控件的输入,提示信息并退出 db = JPDb() orderSQL = " ORDER BY fNumerEnd DESC" if self.isNewMode: where = """ WHERE fCustomerID={uid} and fEspecieID={tid} and fConfirmed={zt} and fCanceled=0 """ sql = 'select fOrderID from t_order' sql = sql + where.format( uid=obj_cus.Value(), tid=obj_esp.Value(), zt=0) bc, result = db.executeTransaction(sql) if result: txt = '选择的客户名(相同分公司类型)下有同类型但未确认的单据,不能增加新单据!\n' txt = txt + 'There are identical but uncertain documents ' txt = txt + 'under the name of the selected customer, ' txt = txt + 'and no new documents can be added' QMessageBox.information(self, "提示", txt) return else: num_sql = self.sql_base + where.format( uid=obj_cus.Value(), tid=obj_esp.Value(), zt=1) self.setNumberNeedControl(num_sql + orderSQL) return # 需要管理情况下: # 编辑状态 if self.isEditMode or self.isReadOnlyMode: where = """ WHERE fCustomerID={uid} and fEspecieID={tid} and fConfirmed={zt} and fOrderID<'{id}'""" where = where.format(uid=obj_cus.Value(), tid=obj_esp.Value(), zt=1, id=self.ui.fOrderID.Value()) num_sql = self.sql_base + where self.setNumberNeedControl(num_sql + orderSQL)