def getConfigData(self) -> dict: sql = "select fValue from sysconfig where fName='configValue'" conn = JPDb().currentConn cur = conn.cursor() cur.execute(sql) conn.commit() mydic = loads(b64decode(cur._result.rows[0][0])) # 防止没有设置信息时,给定初始值 # copys copys = [ 'BillCopys_Order', 'BillCopys_PrintingOrder', 'BillCopys_OutboundOrder', 'BillCopys_WarehouseRreceipt', 'BillCopys_QuotationOrder', 'BillCopys_QuotationPrintingOrder' ] for item in copys: if item not in mydic.keys(): mydic[item] = 'atendimento;1;producao;0;cliente;1;caixa;1' if 'TaxRegCerPath' not in mydic.keys(): mydic['TaxRegCerPath'] = '' txt = '您还没有设置客户税务登记证件位置\n' txt = txt + 'You haven\'t set up the location of the customer\'s tax registration certificate yet' QMessageBox.information(self.MainForm, '提示', txt) else: if not ospath.exists(mydic['TaxRegCerPath']): txt = '您设置的客户税务登记证件位置不存在\n' txt = txt + 'The location of the customer tax registration certificate you set does not exist' QMessageBox.information(self.MainForm, '提示', txt) return mydic
def getConfigData(self) -> dict: sql = "select fValue from sysconfig where fName='configValue'" conn = JPDb().currentConn cur = conn.cursor() cur.execute(sql) conn.commit() mydic = loads(b64decode(cur._result.rows[0][0])) # 防止没有设置信息时,给定初始值 # copys copys = [ 'BillCopys_Order', 'BillCopys_PrintingOrder', 'BillCopys_OutboundOrder', 'BillCopys_WarehouseRreceipt', 'BillCopys_QuotationOrder', 'BillCopys_QuotationPrintingOrder' ] for item in copys: if item not in mydic.keys(): mydic[item] = 'atendimento;1;producao;0;cliente;1;caixa;1' if 'archives_path' not in mydic.keys(): mydic['archives_path'] = '' txt = '您还没有设置附件文件存放位置' QMessageBox.information(self.MainForm, '提示', txt) else: if not ospath.exists(mydic['archives_path']): txt = '您设置的设置附件文件存放位置不存在' QMessageBox.information(self.MainForm, '提示', txt) return mydic
def saveConfigData(self, data: dict): sql = "update sysconfig set fValue=%s where fName='configValue'" conn = JPDb().currentConn cur = conn.cursor() cur.execute(sql, b64encode(dumps(data))) conn.commit() # 保存后刷新当前配置文件 self.__ConfigData = data
def getSql(self, tablename): sql = "select * from {fn}".format(fn=tablename) con = JPDb().currentConn cur = con.cursor() cur.execute(sql) con.commit() tab = cur._result.rows if len(tab) == 0: return c_col = len(cur._result.fields) fns = ['`{}`'.format(r.name) for r in cur._result.fields] fg = ", " sql_ins = 'INSERT INTO `{tn}` ({f}) VALUES \n{v};' values = [] vs = [] for r in range(len(tab)): d = tab[r] vs = [] for col in range(c_col): v = d[col] if v is None: vs.append('Null') continue elif isinstance(v, str): vs.append("'{}'".format(v.replace("'", "\\'"))) elif isinstance(v, (int, float, Decimal)): vs.append('{}'.format(v)) elif isinstance(v, bytes): v = 0 if v == bytes([0]) else 1 vs.append('{}'.format(v)) elif isinstance(v, (datetime.datetime, datetime.date)): vs.append("'{}'".format(JPDateConver(v), str)) else: raise TypeError("没有该类型的转换器【{v}】={t}".format(v=fns[col], t=type(v))) vs = [str(r) for r in vs] values.append('(' + fg.join(vs) + ')') self.exportOneRecord.emit() sql_ins = sql_ins.format(tn=tablename, f=fg.join(fns), v=(fg + '\n\t').join(values)) return sql_ins