单据转换插件新增行不显示
金蝶云社区-tianyake
tianyake
1人赞赏了该文章 2,924次浏览 未经作者许可,禁止转载编辑于2015年08月24日 11:18:48

各位老师,请教一下,在单据转换插件AfterConvert事件中,对DynamicObjectCollection添加New了三个新行,调试时count中也将新行加进去了,但是在单据上并不显示出来

这是什么原因啊 ,是不是应该添加了新行的entrys再重新赋值也单据体的对象

var dataObjs = e.Result.FindByEntityKey("FBillHead");

BaseDataField baseFieldSettle = e.TargetBusinessInfo.GetField("FSETTLETYPEID") as BaseDataField;
BaseDataField baseFieldPurpose = e.TargetBusinessInfo.GetField("FPURPOSEID") as BaseDataField;
BaseDataField baseFieldCost = e.TargetBusinessInfo.GetField("FCOSTID") as BaseDataField;

IViewService service = Kingdee.BOS.App.ServiceHelper.GetService();

foreach (var obj in dataObjs)
{

DynamicObjectCollection srcentrys = obj.DataEntity["PAYBILLSRCENTRY"] as DynamicObjectCollection;
DynamicObjectCollection entrys = obj.DataEntity["PAYBILLENTRY"] as DynamicObjectCollection;

Entity objentry=e.TargetBusinessInfo.GetEntity("FPAYBILLENTRY");

int rowcount = entrys.Count;

for (int seq = rowcount + 1; seq <= rowcount+3; seq++)
{

DynamicObject newEntryRow = new DynamicObject(objentry.DynamicObjectType);

newEntryRow["HANDLINGCHARGEFOR"] = 50;

DynamicObject objSettle = service.LoadSingle(this.Context, 1, baseFieldSettle.RefFormDynamicObjectType);
newEntryRow["SETTLETYPEID"] = objSettle;
newEntryRow["SETTLETYPEID_Id"] = 1;

DynamicObject objpurpose = service.LoadSingle(this.Context, 20017, baseFieldPurpose.RefFormDynamicObjectType);
newEntryRow["PURPOSEID"] = objpurpose;
newEntryRow["PURPOSEID_Id"] = 20017;

DynamicObject objcost = service.LoadSingle(this.Context, 20045, baseFieldCost.RefFormDynamicObjectType);
newEntryRow["FCOSTID"] = objcost;
newEntryRow["FCOSTID_Id"] = 20045;

newEntryRow["PAYTOTALAMOUNTFOR"] = 500;
newEntryRow["SETTLEPAYAMOUNTFOR"] = 500;
newEntryRow["PAYTOTALAMOUNT"] = 500;
newEntryRow["SETTLEPAYAMOUNT"] = 500;

entrys.Add(newEntryRow);

objentry.SeqDynamicProperty.SetValue(newEntryRow, seq);

}