def __init__(self): m_sql = '''SELECT fID, fCustomerID AS 客户名Cliente, fPaymentMethodID AS 收款方式ModoPago, fReceiptDate as 收款日期ReceiptDate, fAmountCollected AS 金额Amount, fPayeeID, fNote, fOrderID as 单据号码OrderID FROM t_receivables WHERE fID = '{}' ''' super().__init__(Edit_ui(), sql_main=m_sql, PKValue=None, edit_mode=JPEditFormDataMode.New, flags=Qt.WindowFlags()) JPPub().MainForm.addLogoToLabel(self.ui.label_logo) JPPub().MainForm.addOneButtonIcon(self.ui.butSave, 'save.png') JPPub().MainForm.addOneButtonIcon(self.ui.butCancel, 'cancel.png') self.ui.butCancel.clicked.connect(self.close) self.ui.fID.hide() self.readData() self.ui.fPayeeID.refreshValueNotRaiseEvent(JPUser().currentUserID(), ) self.__setEnabled() self.ui.fCustomerID.currentIndexChanged.connect(self.__setEnabled) self.ui.fCustomerID.setEditable(True) self.ui.fOrderID.setEditable(False) self.ui.fOrderID.setEnabled(False) self.ui.fArrears.setEnabled(True) self.ui.fCustomerID.setFocus() self.ui.fReceiptDate.setEnabled(False)
def __init__(self, sql_main=None, PKValue=None, sql_sub=None, edit_mode=JPEditFormDataMode.ReadOnly, flags=Qt.WindowFlags()): super().__init__(Ui_Form(), sql_main=sql_main, PKValue=PKValue, sql_sub=sql_sub, edit_mode=edit_mode, flags=flags) JPPub().MainForm.addLogoToLabel(self.ui.label_logo) self.setPkRole(8) self.cacuTax = True self.ui.fTax.keyPressEvent = self.__onTaxKeyPress self.readData() if self.isNewMode: self.ObjectDict()['fEntryID'].refreshValueNotRaiseEvent( JPUser().currentUserID()) else: self.__customerIDChanged() if edit_mode != JPEditFormDataMode.ReadOnly: self.ui.fCustomerID.setEditable(True) self.ui.fOrderDate.refreshValueNotRaiseEvent(QDate.currentDate()) self.ui.fRequiredDeliveryDate.FieldInfo.NotNull = True self.ui.fCustomerID.setFocus() self.ui.tableView.keyPressEvent = self.mykeyPressEvent self.ui.tableView.doubleClicked.connect(self.table_change) self.productInfo = self.__getProductInfo() self.subModel.getFullProductName = self.getFullProductName self._setEditFormButtonsIcon(self.ui)
def __init__(self, sql_main, sql_sub=None, edit_mode=None, PKValue=None): super().__init__(JPFormPrintingOrder(), sql_main, PKValue=PKValue, edit_mode=edit_mode) JPPub().MainForm.addLogoToLabel(self.ui.label_logo) self.ui.butTaxCer.setIcon(JPPub().MainForm.getIcon('rosette.ico')) self.setPkRole(5) self.cacuTax = True self.NumberControl = False self.ui.fTax.keyPressEvent = self.__onTaxKeyPress self.readData() self.ui.fNumerBegin.setEnabled(False) self.ui.fNumerEnd.setEnabled(False) if self.isNewMode: self.ui.butTaxCer.setEnabled(False) uid = JPUser().currentUserID() self.ui.fEntryID.refreshValueNotRaiseEvent(uid) self.ui.fOrderDate.refreshValueNotRaiseEvent(QDate.currentDate()) # 编辑状态下,更新一次历史单据号列表 if self.isEditMode or self.isReadOnlyMode: self.onDateChangeEvent(self.ui.fCustomerID, None) # 设置必输入字段 self.ui.fCustomerID.FieldInfo.NotNull = True self.ui.fEspecieID.FieldInfo.NotNull = True self.ui.fAvistaID.FieldInfo.NotNull = True self.ui.fQuant.FieldInfo.NotNull = True self.ui.fPagePerVolumn.FieldInfo.NotNull = True self.ui.fTamanhoID.FieldInfo.NotNull = True self.ui.fPrice.FieldInfo.NotNull = True self.ui.fRequiredDeliveryDate.FieldInfo.NotNull = True self.ui.fVendedorID.FieldInfo.NotNull = True self.ui.fNrCopyID.FieldInfo.NotNull = True self.ui.fCustomerID.setFocus() self.ui.fQuant.setIntValidator(-9999999999, 9999999999)
def on_btn_Download_clicked(self, addtionalInfoRow=None): # 生成临时文件夹 tm = time.strftime('%Y%m%d%H%M%S', time.localtime()) uid = JPUser().currentUserID() topath = os.path.join(os.getcwd(), "temp", "{}_{}".format(uid, tm)) if not os.path.exists(topath): os.makedirs(topath) # 下载文件列表 lst = addtionalInfoRow if addtionalInfoRow else \ [item for item in self.addtionalInfo if not item.deleted] copylst = [] for i, item in enumerate(lst): if item.archives_pk: fr = os.path.join(self.archivesPathInDatabase, item.md5FilePath) to = os.path.join(topath, item.original_name) copylst.append([fr, to]) else: fr = item.original_path to = os.path.join(topath, item.original_name) copylst.append([fr, to]) pop = FormPopProgressBar(self) pop.reset(len(copylst) - 1) for r in copylst: pop.dispInfo("复制{}".format(r[1]), i) myCopy(r[0], r[1]) pop.close() txt = '文件保存在:【{}】,点击确定打开该文件夹!'.format(topath) if QMessageBox.question(self, '完成', txt, (QMessageBox.Yes | QMessageBox.No), QMessageBox.Yes) == QMessageBox.Yes: topath1 = os.path.abspath(topath) os.system("start explorer {}".format(topath1))
def onGetFieldsRowSources(self): sql = '''select fSupplierName,fSupplierID, fNUIT,fCity,fContato,fTaxRegCer from t_supplier''' lst_supplier = JPDb().getDataList(sql) u_lst = [[item[1], item[0]] for item in JPUser().getAllUserList()] return [('fSupplierID', lst_supplier, 1), ('fPurchaserID', JPPub().getEnumList(10), 1), ('fEntryID', u_lst, 1)]
def onGetFieldsRowSources(self): pub = JPPub() u_lst = [[item[1], item[0]] for item in JPUser().getAllUserList()] return [('fCustomerID', pub.getCustomerList(), 1), ('fVendedorID', pub.getEnumList(10), 1), ('fEspecieID', pub.getEnumList(2), 1), ('fAvistaID', pub.getEnumList(7), 1), ('fTamanhoID', pub.getEnumList(8), 1), ('fNrCopyID', pub.getEnumList(9), 1), ('fEntryID', u_lst, 1)]
def __init__(self, dataBaseType: JPDbType = JPDbType.MySQL, *args, **kwargs): super(JPMainWindow, self).__init__(*args, **kwargs) try: db = JPDb() db.setDatabaseType(dataBaseType) JPPub().MainForm = self except Exception as e: QMessageBox.warning(self, "提示", str(e)) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.label_Title.setText("") self.commandDict = {} self.logoPixmap = None self.addOneButtonIcon(self.ui.ChangeUser, "changeuser.png") self.addOneButtonIcon(self.ui.ChangePassword, "changepassword.png") # self.addLogoToLabel(self.ui.label_logo) # 用户及密码修改功能 objUser = JPUser() objUser.INIT() # 程序开始时只初始化一次 objUser.userChange.connect(self.onUserChanged) objUser.currentUserID() self.ui.ChangeUser.clicked.connect(objUser.changeUser) self.ui.ChangePassword.clicked.connect(objUser.changePassword) # 堆叠布局 self.ui.stackedWidget.removeWidget(self.ui.page) self.ui.stackedWidget.removeWidget(self.ui.page_2) # 隐藏树标题 self.ui.label_FunPath.setText('') self.ui.treeWidget.setHeaderHidden(True) # 设置状态条中的进度条及标签 self.Label = QLabel(" ") self.ProgressBar = QProgressBar() self.statusBar = self.statusBar() self.statusBar.addPermanentWidget(self.Label) self.statusBar.addPermanentWidget(self.ProgressBar) self.ProgressBar.setGeometry(0, 0, 100, 5) self.ProgressBar.hide() self.statusBar.hide() self.ui.splitter.setStretchFactor(0, 2) self.ui.splitter.setStretchFactor(1, 11) # 连接点击了功能树中的节点到函数 self.ui.treeWidget.itemClicked[QTreeWidgetItem, int].connect(self.treeViewItemClicked)
def __init__(self): super().__init__() JPPub().MainForm = self self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.label_Title.setText("Zion OrderM") #self.ui.label_Title.setText("ColorPro OrderM") #self.setWindowTitle("ColorPro OrderM") self.setWindowTitle("Zion OrderM") # self.icoPath = ":/pic/res/ico/{}" # self.logoPath = ":/logo/res/{}" self.icoPath = getcwd() + "\\res\\ico\\{}" self.logoPath = getcwd() + "\\res\\{}" # 设置主窗体中按钮图标及Logo self.logoPixmap = QPixmap(self.logoPath.format("zions_100.png")) self.backPixmap = QPixmap(self.logoPath.format("zions_tm.png")) self.addOneButtonIcon(self.ui.ChangeUser, "changeuser.png") self.addOneButtonIcon(self.ui.ChangePassword, "changepassword.png") self.addLogoToLabel(self.ui.label_logo) # 用户及密码修改功能 objUser = JPUser() objUser.INIT() # 程序开始时只初始化一次 objUser.userChange.connect(self.onUserChanged) objUser.currentUserID() self.ui.ChangeUser.clicked.connect(objUser.changeUser) self.ui.ChangePassword.clicked.connect(objUser.changePassword) # 堆叠布局 self.ui.stackedWidget.removeWidget(self.ui.page) self.ui.stackedWidget.removeWidget(self.ui.page_2) # 隐藏树标题 self.ui.label_FunPath.setText('') self.ui.treeWidget.setHeaderHidden(True) # 设置状态条中的进度条及标签 self.Label = QLabel("") self.ProgressBar = QProgressBar() self.statusBar().addPermanentWidget(self.Label) self.statusBar().addPermanentWidget(self.ProgressBar) self.ProgressBar.hide() # 连接点击了功能树中的节点到函数 self.ui.treeWidget.itemClicked[QTreeWidgetItem, int].connect(self.treeViewItemClicked)
def getInsertArchiveSQL(self, archive_type, values): """生成插入档案SQL""" archive_type = str(archive_type) flds = ['fUserID'] vals = [sqm(JPUser().currentUserID())] lst = ['issuing_date', 'archive_no', 'key_words', 'title', 'archive_describe', 'archive_type'] for k in lst: if values[k]: flds.append(k) vals.append(values[k]) strFld, strVal = ",".join(flds), ",".join(vals) s = "INSERT INTO t_archives ({}) VALUES ({});" return s.format(strFld, strVal)
def on_CmdConfirm_clicked(self): us = JPUser() uid = us.currentUserID() cu_id = self.getCurrentSelectPKValue() if self.getCurrentColumnValue(13) == 1: msg = '单据已经确认,无法重复确认!\n' msg = msg + 'The payment has been confirmed and cannot be repeated.' QMessageBox.information(JPPub().MainForm, '提示', msg) return sql0 = f"select '{cu_id}';" sql1 = f"update t_order set fConfirmed=1,fConfirmID={uid} where fOrderID='{cu_id}'" sql2 = f"update t_product_outbound_order set fConfirmed=1,fConfirmID={uid} where fOrderID='{cu_id}'" sql3 = f""" UPDATE t_product_information AS p, (SELECT fProductID, sum(fQuant) AS sum_sl FROM t_product_outbound_order_detail WHERE fOrderID='{cu_id}' GROUP BY fProductID) AS q1 SET p.fCurrentQuantity=p.fCurrentQuantity-q1.sum_sl WHERE p.fID=q1.fProductID; """ if not cu_id: return else: sql = [sql2, sql3, sql0] if cu_id[0:2] == 'PO' else [sql1, sql0] db = JPDb() msg = "单据【{pk}】确认后将不能修改。是否要确认此付款单?" + '\n' msg = msg + 'The bill [{pk}] of payment will not be amended after confirmation.' msg = msg + " Do you want to confirm this payment form?" msg = msg.format(pk=cu_id) if QMessageBox.question(JPPub().MainForm, '确认', msg, QMessageBox.Yes | QMessageBox.No, QMessageBox.No) == QMessageBox.Yes: db.executeTransaction(sql) if cu_id[0:2] == 'PO': JPPub().broadcastMessage(tablename="t_product_outbound_order", PK=cu_id, action='confirmation') else: JPPub().broadcastMessage(tablename="t_order", action='confirmation', PK=cu_id) self.refreshListForm()
def listItemDoubleClicked(self, item): def check(item): cunzai = [r for r in self.laseDoubleInfo if r.item is item] if not cunzai: t = datetime.datetime.now() self.laseDoubleInfo.append(lastDoubleItemInfo(item, t)) return True else: n = datetime.datetime.now() if (n - cunzai[0].clickTime).seconds > 3: cunzai[0].clickTime = n return True else: t = "您刚刚点击过本条目,正在调用系统功能打开文件,请不要重复点击!" QMessageBox.warning(self, '提示', t, QMessageBox.ok) if item.picInfo.iconPath: if not check(item): return self.pop = FormPopProgressBar(self) self.pop.setMinimumDuration(0) self.pop.open() self.pop.reset(2) uid = JPUser().currentUserID() tm = time.strftime('%Y%m%d%H%M%S', time.localtime()) topath = os.path.join(os.getcwd(), "temp", "{}_{}".format(uid, tm)) if not os.path.exists(topath): os.makedirs(topath) topath = os.path.join(topath, item.picInfo.originalName.replace(" ", '')) self.pop.dispInfo("正在下载{}".format(item.picInfo.originalName), 1) myCopy(item.picInfo.originalPath, topath) self.pop.dispDelayed( "正在调用系统功能打开文件{},请稍候....".format(item.picInfo.originalName), 2) os.system(topath) else: frm = Form_ViewPic(self, item.picInfo, self.viewPicInfos) # frm.setData(item.picInfo, self.viewPicInfos) frm.show
def onAfterSaveData(self, data): # 重新加载一次用户数据 JPUser().INIT() act = 'new' if self.isNewMode else 'edit' JPPub().broadcastMessage(tablename="sysusers", PK=data, action=act) super().onAfterSaveData(data)
def onGetFieldsRowSources(self): pub = JPPub() u_lst = [[item[1], item[0]] for item in JPUser().getAllUserList()] return [('fCustomerID', pub.getCustomerList(), 1), ('fVendedorID', pub.getEnumList(10), 1), ('fEntryID', u_lst, 1)]
def onGetFieldsRowSources(self): pub = JPPub() u_lst = [[item[1], item[0]] for item in JPUser().getAllUserList()] return [('fCustomerID', pub.getCustomerList(), 1), ('fPaymentMethodID', pub.getEnumList(3), 1), ('fPayeeID', u_lst, 1), ('fOrderID', [['DIBOTO']], 0)]
def __init__(self, sql_main, PKValue, edit_mode, flags=Qt.WindowFlags()): super().__init__(Ui_Form_Edit(), sql_main=sql_main, PKValue=PKValue, edit_mode=edit_mode, flags=flags) self.MainForm = JPPub().MainForm self.MainForm.addLogoToLabel(self.ui.label_logo) self.MainForm.addOneButtonIcon(self.ui.butSave, 'save.png') self.MainForm.addOneButtonIcon(self.ui.butCancel, 'cancel.png') # 设置listWidget的格式 cfg = ConfigInfo() temp = [int(r) for r in cfg.viewpdf.pagesize.split(',')] self.pdfPageSize = QSize(temp[0], temp[1]) self.icoSize = QSize(96, 96) self.ui.listWidget.setSpacing(5) self.ui.listWidget.setGridSize(self.pdfPageSize) self.ui.listWidget.setResizeMode(QListWidget.Adjust) self.ui.listWidget.setIconSize(self.pdfPageSize) self.ui.listWidget.setViewMode(QListWidget.IconMode) self.ui.listWidget.itemDoubleClicked.connect( self.listItemDoubleClicked) # 保存最后一次点击的信息,时间和节点,防止重复点击 self.laseDoubleInfo = [] self.ui.listWidget.setContextMenuPolicy(Qt.CustomContextMenu) self.ui.listWidget.customContextMenuRequested[QPoint].connect( self.rightClicked) # 标签文本自动换行 self.ui.listWidget.setFlow(QListView.LeftToRight) self.ui.listWidget.setWrapping(True) self.ui.label_ProjectLink.setWordWrap(True) self._currentEditModelRow = None self.ui.fUserID.hide() # 附件有无修改的标志 self.addtionalChanged = False self.pop: FormPopProgressBar = None # 存放用户已经选择的关联项目 self.projectKeyList = [] self.projectKeyListChanged = False editStyle = """border: 1px groove gray; border-radius: 3px; padding: 2px 4px; border-width: 1px; border-style: solid; background-color: white; border-color: rgb(171, 171, 171);""" readStyle = """border: 1px groove gray; border-radius: 3px; padding: 2px 4px; border-width: 1px; border-style: solid; border-color: rgb(171, 171, 171);""" if self.isNewMode or self.isEditMode: self.ui.label_ProjectLink.setStyleSheet(editStyle) self.ui.label_ProjectLink.mouseDoubleClickEvent = self.on_but_SelectProject_clicked else: self.ui.label_ProjectLink.setStyleSheet(readStyle) self.ui.listWidget.setStyleSheet( "background-color: rgb(239, 239, 239);") # addtionalInfo用来以文件为行,保存档案的附件数据,用于保存命令等 self.addtionalInfo = [] # listIcos是一个列表,内部存放所有在listWidget中显示的图标 #self.listIcos = [] # 下面的链表,用于存放listIcos中可用于放大显示的图片 self.viewPicInfos = BilateralLinkList() # # 一个只包含PDF页面和图片的列表,由编辑窗体维护,用于放大显示时用 # self.ViewPdfAndPic = [] # self.archivesPathInDatabase = os.path.abspath( JPPub().getConfigData()["archives_path"]) if self.isNewMode: self.ui.fUserID.setText(str(JPUser().currentUserID())) self.readData() if (not self.isNewMode) and self.ui.archives_pk.text(): sql = "select project_pk from " sql = sql + "t_archives_project where archives_pk={}" dic = JPDb().getDict( sql.format(self.ui.archives_pk.text().replace(",", ""))) projects = [str(r['project_pk']) for r in dic] if projects: self.readProject(projects) self.ui.archives_pk.setEnabled(False) self.ui.issuing_date.setFocus() QGuiApplication.processEvents() # QGuiApplication.processEvents() # self.repaint() self.readAddtionalFromDatabase() self.initAdditional(self.addtionalInfo) # 根据窗体编辑状态设置窗体中按钮的显示状态 if self.isReadOnlyMode: self.ui.but_SelectProject.setEnabled(False) # self.ui.btn_Download.setEnabled(False) self.ui.btn_Add.setEnabled(False) self.ui.btn_Delete.setEnabled(False)
def onUserChanged(self, args): self.ui.label_UserName.setText(args[1]) loadTreeview(self.ui.treeWidget, JPUser().currentUserRight(), self) Form_Background(self)