业务场景:销售订单下推销售出库单,在销售出库单填写项目名称,点保存,反写到销售订单上面
通过数据库,找到销售出库单关联销售订单,行内码,更新销售订单,项目名称;
打开BOS,销售订单和销售出库单,都新建一个单据体文本字段,项目名称 F_YDIE_ProjectName
把项目名称移到最前面
//保存后,触发
public override void AfterSave(BOS.Core.Bill.PlugIn.Args.AfterSaveEventArgs e)
{
base.AfterSave(e);
}
//如果保存成功,则触发
if(e.OperationResult.IsSuccess)
{
}
//引用Kingdee.BOS.App.Data,才能执行sql
using Kingdee.BOS.App.Data;
--T_SAL_ORDERENTRY --销售订单,单据体明细表 F_YDIE_ProjectName --待更新的字段
--T_SAL_OUTSTOCKENTRY --销售出库单,单据体明细表 F_YDIE_ProjectName --待更新的字段
--FID
update t1 set F_YDIE_ProjectName =F_YDIE_ProjectName
from T_SAL_ORDERENTRY t1
--销售订单和销售出库单关联
where
--FSOEntryId在T_SAL_OUTSTOCKENTRY_R表;
--F_YDIE_ProjectName在T_SAL_OUTSTOCKENTRY表
select FSOEntryId, * from T_SAL_OUTSTOCKENTRY_R
select FSOEntryId,F_YDIE_ProjectName from T_SAL_OUTSTOCKENTRY_R x
INNER JOIN T_SAL_OUTSTOCKENTRY y
on x.FENTRYID = y.FENTRYID
//执行sql
DBUtils.Execute
if(e.OperationResult.IsSuccess)
{
// 方言,转义"/*dialect*/
//销售出库单,反写到销售订单上面
//获取FID this.View.Model.DataObject["Id"].ToString()
string sql = @"/*dialect*/update t1 set F_YDIE_ProjectName =t2.F_YDIE_ProjectName
from T_SAL_ORDERENTRY t1,
(select FSOEntryId,F_YDIE_ProjectName from T_SAL_OUTSTOCKENTRY_R x
INNER JOIN T_SAL_OUTSTOCKENTRY y
on x.FENTRYID = y.FENTRYID
where x.FID ="+this.View.Model.DataObject["Id"].ToString()+") t2 "+
"where t1.FENTRYID =t2.FSOENTRYID";
//执行sql
DBUtils.Execute(this.Context,sql);
最终效果:重新打开销售订单,下推销售出库单,填写项目名称后反写到销售订单上面。