单据转换后事件开发案例
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.App;
using Kingdee.BOS.Util;
using Kingdee.BOS.App.Data;
namespace HW.K3Cloud.ZXB.Plugin
{
[Description("采购订单下推采购入库单携带BOM版本")]
public class PurOrderChonvertPurInStock : AbstractConvertPlugIn
{
/// <summary>
/// 单据下推完毕,结束下推前,触发本事件
/// </summary>
/// <param name="e"></param>
/// <remarks>
/// 重载此事件,以便在调试代码时,观察最终生成的数据包是否符合预期
/// </remarks>
public override void AfterConvert(AfterConvertEventArgs e)
{
base.AfterConvert(e);
// 目标单单据体元数据
Entity entity = e.TargetBusinessInfo.GetEntity("FInStockEntry");
ExtendedDataEntitySet bill = e.Result;
// DynamicObjectCollection rows = bill[0]["InStockEntry"] as DynamicObjectCollection;
ExtendedDataEntity[] rows = e.Result.FindByEntityKey("FInStockEntry");
//
if (rows.Length>0)
{
for (int i=0;i<rows.Length ;i++)
{
DynamicObject row = rows[i].DataEntity as DynamicObject;
Int64 FMaterialId = Convert.ToInt64(row["MaterialId_Id"]);
string Filter = String.Format(" FMATERIALID='{0}' AND FDOCUMENTSTATUS='C' AND FFORBIDSTATUS='A' AND FBOMCATEGORY='1' ", FMaterialId);
DynamicObjectCollection bomIds=UtilZxbK3.GetQueryDatas2("ENG_BOM", Filter,"FID",this.Context);
if (bomIds.Count>0)
{
string FBomId = Convert.ToString(bomIds[0]["FID"]);
DynamicObject BOM=UtilZxbK3.GetObjectByFID("ENG_BOM", this.Context, FBomId);
if (!ObjectUtils.IsNullOrEmptyOrWhiteSpace(BOM))
{
row["BOMId_Id"] = FBomId;
row["BOMId"] = BOM;
}
}
}
}
}
}
}
这个插件是部署在哪个里面 转换规则的转换策略里面嘛 还是表单插件即可?
单据转换后事件开发案例
本文2024-09-16 17:23:57发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-15460.html