python点击按钮后查询数据并做校验
系统以批号查询外储入库单的总数量与出库单的总数量进行比对,如果相同允许出库,不相同不允许出库,此功能点要注意的是点击保存按钮之后才能触发插件使用AfterBarItemClick事件
###########
import sys
import clr
clr.AddReference('System')
clr.AddReference('Kingdee.BOS')
clr.AddReference('Kingdee.BOS.Core')
clr.AddReference('Kingdee.BOS.Contracts')
clr.AddReference('Kingdee.BOS.DataEntity')
clr.AddReference('Kingdee.BOS.ServiceHelper')
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
import System
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import EndOperationTransactionArgs
from Kingdee.BOS.Orm.DataEntity import *
from Kingdee.BOS.Core.Metadata import *
from Kingdee.BOS.Contracts import *
from System import DateTime
from Kingdee.BOS.ServiceHelper import *
def AfterBarItemClick(e): '''按钮点击后事件'''
if (e.BarItemKey=="tbSplitSave"):
row = this.Model.GetEntryRowCount("FEntity");'''获取行号'''
i=0;
messfl = " ";
for i in range(0,row):'''循环明细行取出批号字段'''
fl= this.Model.GetValue("FLOT",i);'''取明细行批号'''
maid= this.Model.GetValue("FMATERIALID",i)["Id"];'''取明细行物料ID'''
inqty =sqlReturn_inqty(str(maid),str(fl));'''调用下面入库数量函数'''
outqty =sqlReturn_outqty(str(maid),str(fl));'''调用下面出库数量函数'''
if inqty<>outqty:
if fl not in messfl:
messfl= messfl + " " + fl;
if messfl <>" ":
this.View.ShowErrMessage("批号为:"+messfl + "入库与出库数量不一致");
def sqlReturn_inqty(maid,flid):
"""
根据物料编码id及批号id查询外储入库单,相同物料相同批号数量和
"""
sql="select sum(FQTY) from ROTS_t_Cust_Entry100001 t,T_BD_LOTMASTER f where t.FLOT=f.FLOTID and t.FMATERIALID='"+maid + "' and f.FNUMBER='" +flid + "';"
"this.View.ShowMessage(sql);"
qty = DBServiceHelper.ExecuteScalar(this.Context,sql,None);
return qty;
def sqlReturn_outqty(maid,flid):
"""
根据物料编码id及批号id查询外储出库单,相同物料相同批号数量和
"""
sql="select sum(FQTY) from ROTS_t_Cust_Entry100004 t,T_BD_LOTMASTER f where t.FLOT=f.FLOTID and t.FMATERIALID='"+maid + "' and f.FNUMBER='" +flid + "';"
'''this.View.ShowMessage(sql);'''
qty = DBServiceHelper.ExecuteScalar(this.Context,sql,None);
return qty;
python点击按钮后查询数据并做校验
本文2024-09-16 17:41:24发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-17329.html