单据转换插件之携带子单据体

上才艺:
/// <summary>
/// 关联关系子表已经创建并填写完毕后触发,
/// 此时,已经在关联子表中,记录了源单与目标单之间的关系
/// </summary>
/// <param name="e"></param>
/// <remarks>
/// 可以在此事件中,对关联关系子表内容进行调整,
/// </remarks>
public override void OnAfterCreateLink(CreateLinkEventArgs e)
{
#region
// 获取源单子单据体元数据
//SubEntryEntity YsubEntity = e.SourceBusinessInfo.GetEntity("FNoticeBOMSubEntry") as SubEntryEntity;
// 获取目标子单据体元数据
SubEntryEntity subEntity = e.TargetBusinessInfo.GetEntity("FSerialSubEntity") as SubEntryEntity;
// 获取子单据体行中的一个文本字段:创建新行时要对此字段赋值
//序列号
Field FSerialNo = e.TargetBusinessInfo.GetField("FSerialNo");
//备注
Field FSerialNote = e.TargetBusinessInfo.GetField("FSerialNote");
//锻批号
Field F_PALE_DPH = e.TargetBusinessInfo.GetField("F_PALE_DPH");
//客户序列号
Field F_PALE_KHXLH = e.TargetBusinessInfo.GetField("F_PALE_KHXLH");
//锭节号
Field F_PALE_DJH = e.TargetBusinessInfo.GetField("F_PALE_DJH");
//BaseDataField FMater = e.TargetBusinessInfo.GetField("FMaterialIdBOM") as BaseDataField;
//BaseDataField FUnit = e.TargetBusinessInfo.GetField("FUnitIDUint") as BaseDataField;
// 获取目标单据体
var entryRows = e.TargetExtendedDataEntities.FindByEntityKey("FEntity");
//var entryRows = e.Result.FindByEntityKey("FEntity");
foreach (var entryRow in entryRows)
{
// 获取当前单据体行的子单据体行集合
DynamicObjectCollection subEntryRows = subEntity.DynamicProperty.GetValue(entryRow.DataEntity) as DynamicObjectCollection;
DynamicObject rowObj = entryRow.DataEntity;
DynamicObjectCollection linkRows = rowObj["FEntity_Link"] as DynamicObjectCollection;
foreach (var linkRow in linkRows)
{
string sql = "/*dialect*/select FSerialNo,FSerialId,FSerialNote,F_PALE_DPH,F_PALE_KHXLH,F_PALE_DJH from PALE_WWYLQD_XLH where FEntryID=" + linkRow["Sid"];
DataSet ds = DBUtils.ExecuteDataSet(this.Context, sql);
DataTable dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
// 创建子单据体行数据包
DynamicObject newRow = new DynamicObject(subEntity.DynamicObjectType);
if (dt.Rows[i]["F_PALE_DPH"] != null)
{
IViewService viewService = ServiceHelper.GetService<IViewService>();
F_PALE_DPH.DynamicProperty.SetValue(newRow, dt.Rows[i]["F_PALE_DPH"].ToString());
FSerialNote.DynamicProperty.SetValue(newRow,
单据转换插件之携带子单据体
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



