提示未将对象引用设置到对象的实例。
2,694次浏览
编辑于2016年11月07日 09:46:44
应收单到收款单转换插件代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Kingdee.BOS;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.CN.App.Core;
using Kingdee.K3.FIN.Core;
using Kingdee.BOS.Core;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.App;
using Kingdee.BOS.Resource;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.App.Core.PlugInProxy;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.App.Core.DefaultValueService;
using Kingdee.K3.FIN.CN.App.ServicePlugIn.BillConvertPlugIn;
namespace SYLHWL.K3.CW.App.CTEx
{
[Description("应收to收款botp")]
public class YSDToSKDbillNew : ReceivableToRecConvert
{
public override void OnAfterCreateLink(CreateLinkEventArgs e)
{
base.OnAfterCreateLink(e);
//应收单的信息
ExtendedDataEntity[] headEntity = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead");
foreach (var extendedDataEntity in headEntity)
{
//收款单的明细
DynamicObjectCollection entryCollection = null;
entryCollection = extendedDataEntity.DataEntity["RECEIVEBILLENTRY"] as DynamicObjectCollection;
//if (entryCollection != null && entryCollection.Count > 0)
//{
// entryCollection.Clear();
//}
//收款单的源单明细
DynamicObjectCollection srcentryCollection = null;
srcentryCollection = extendedDataEntity.DataEntity["RECEIVEBILLSRCENTRY"] as DynamicObjectCollection;
//2、这是第二种方案:把明细的清理掉,然后再处理,这样明细和源单明细都是一一对应的
//DynamicFormModelProxy modelProxy = GetModelProxy(e);
DynamicFormModelProxy modelProxy = base.GetModelProxy(e);
// 明细单据体
Entity entity = e.TargetBusinessInfo.Entrys.FirstOrDefault(c => c.EntryName.Equals("RECEIVEBILLENTRY", StringComparison.OrdinalIgnoreCase));
for (int i = 0; i < srcentryCollection.Count; i++)
{
modelProxy.CreateNewEntryRow(entity, i);
}
}
}
}
}
运行到modelProxy.CreateNewEntryRow(entity, i);提示未将对象引用设置到对象的实例。
请老师指点一下是什么原因导致?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Kingdee.BOS;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.CN.App.Core;
using Kingdee.K3.FIN.Core;
using Kingdee.BOS.Core;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.App;
using Kingdee.BOS.Resource;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.App.Core.PlugInProxy;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.App.Core.DefaultValueService;
using Kingdee.K3.FIN.CN.App.ServicePlugIn.BillConvertPlugIn;
namespace SYLHWL.K3.CW.App.CTEx
{
[Description("应收to收款botp")]
public class YSDToSKDbillNew : ReceivableToRecConvert
{
public override void OnAfterCreateLink(CreateLinkEventArgs e)
{
base.OnAfterCreateLink(e);
//应收单的信息
ExtendedDataEntity[] headEntity = e.TargetExtendedDataEntities.FindByEntityKey("FBillHead");
foreach (var extendedDataEntity in headEntity)
{
//收款单的明细
DynamicObjectCollection entryCollection = null;
entryCollection = extendedDataEntity.DataEntity["RECEIVEBILLENTRY"] as DynamicObjectCollection;
//if (entryCollection != null && entryCollection.Count > 0)
//{
// entryCollection.Clear();
//}
//收款单的源单明细
DynamicObjectCollection srcentryCollection = null;
srcentryCollection = extendedDataEntity.DataEntity["RECEIVEBILLSRCENTRY"] as DynamicObjectCollection;
//2、这是第二种方案:把明细的清理掉,然后再处理,这样明细和源单明细都是一一对应的
//DynamicFormModelProxy modelProxy = GetModelProxy(e);
DynamicFormModelProxy modelProxy = base.GetModelProxy(e);
// 明细单据体
Entity entity = e.TargetBusinessInfo.Entrys.FirstOrDefault(c => c.EntryName.Equals("RECEIVEBILLENTRY", StringComparison.OrdinalIgnoreCase));
for (int i = 0; i < srcentryCollection.Count; i++)
{
modelProxy.CreateNewEntryRow(entity, i);
}
}
}
}
}
运行到modelProxy.CreateNewEntryRow(entity, i);提示未将对象引用设置到对象的实例。
请老师指点一下是什么原因导致?
推荐阅读