业务需求是实现 在复核人网银复核时候,便于核对对应的凭证号,希望付款单备注(也就是提交网银摘要),包含备注+凭证期间+凭证号 举例 差旅费12-1111。从社区其他python学习贴获取到基本模板,修改而来。只是基本实现需求,未做更多条件判定。
实现代码如下:
#【Python】【表单插件】执行SQL
import clr
clr.AddReference("mscorlib")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS.App")
clr.AddReference('System')
clr.AddReference("System.Data")
clr.AddReference('Kingdee.BOS.ServiceHelper')
clr.AddReference('Kingdee.BOS.DataEntity')
from Kingdee.BOS import *
from Kingdee.BOS.Core import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.Core.DynamicForm.PlugIn import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import *
from Kingdee.BOS.Util import *
from Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel import *
from Kingdee.BOS.Core.List.PlugIn import *
from Kingdee.BOS.Core.SqlBuilder import *
from Kingdee.BOS.Core.Metadata import *
from System import *
from System.Collections.Generic import *
from System.Data import *
from Kingdee.BOS.Core.Bill import *
from Kingdee.BOS.Core.Bill.PlugIn import *
from Kingdee.BOS.App.Data import *
from Kingdee.BOS.ServiceHelper import *
from System.Collections.Generic import List
def BarItemClick(e):
btnKey = e.BarItemKey.ToUpper();
if(btnKey=="TBSQL"):#列表自定义菜单按钮大写
selectedRowsInfo=this.ListView.SelectedRowsInfo;#列表勾选的数据集
datas=this.ListModel.GetData(selectedRowsInfo);#这句代码似乎选中的数据行超过1000多行,会报错,请做处理!
listEntryId=List[str]();
for row in selectedRowsInfo:
selectEntryId=str(row.EntryPrimaryKeyValue);
entityKey=str(row.EntryEntityKey);
#列表一定要显示出需要更新的明细字段所在的单据体,不然无法获取明细行ID
if(selectEntryId=="" or selectEntryId==None or entityKey<>"FPAYBILLENTRY"):
this.View.ShowWarnningMessage("请在过滤里面显示单据体[FEntity]!");
return;
listEntryId.Add(selectEntryId);
rowIndexs = str.Join(',', listEntryId.ToArray());#将获取到的明细行ID构造成逗号隔开的字符串,
#this.View.ShowMessage("当前选中行:" + rowIndexs);
sql =( "/*dialect*/UPDATE t4 set t4.fcomment= t4.fcomment+convert (varchar ,t2.fperiod)+'-'+convert(varchar,t2.FVOUCHERGROUPNO) from t_bas_voucher t1 left join t_ap_paybill t3 on t1.FSOURCEBILLNO=t3.fbillno left join t_ap_paybillentry t4 on t3.fid=t4.fid left join t_gl_voucher t2 on t1.FGLVOUCHERID=t2.FVOUCHERID where t4.fentryid in ({0})").format(rowIndexs);
#x=DBServiceHelper.Execute(this.Context,Sql);
# 执行SQL并返回受影响行数
returnValue = DBUtils.Execute(this.Context, sql);
msg = "受影响行数:" + returnValue.ToString()
this.View.ShowMessage(msg)
return
推荐阅读