动态表单的单据体上数据返回给父单据的对应单据体上保存操作出错
金蝶云社区-小龙虾米
小龙虾米
0人赞赏了该文章 1,247次浏览 未经作者许可,禁止转载编辑于2019年03月08日 11:53:48

以上出错操作是在点击【保存】时出错!请教大神帮忙解决:/$
具体代码如下:
using Kingdee.BOS.Core.Bill;
using Kingdee.BOS.Core.Bill.PlugIn;

using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.SqlBuilder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Metadata.DataEntity;

using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core;
using Kingdee.BOS.ServiceHelper;
using System.ComponentModel;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Orm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;

namespace helloworld
{
[Description("销售订单表单插件")]
public class buttonEvent : AbstractBillPlugIn
{
public override void BarItemClick(BarItemClickEventArgs e)
{

if (e.BarItemKey == "helloworld")//判断按钮的Key是不是helloworld
{
DynamicFormShowParameter billpara = new DynamicFormShowParameter();
billpara.FormId = "PAEZ_t";
//billpara.FormId = "131bf189-b26d-45ab-9729-ece3dfc63ddc";
//修改状态打开
// billpara.ParentPageId = "131bf189-b26d-45ab-9729-ece3dfc63ddc";
//billpara.ParentPageId = this.View.PageId;

DynamicObject FCustId = (DynamicObject)this.View.Model.GetValue("FCustId", 0);
long FCustId1 = FCustId == null ? 0 : Convert.ToInt64(FCustId["Id"]);
DynamicObject FMaterialId = (DynamicObject)this.View.Model.GetValue("FMaterialId", 0);
long FMaterialId1 = FCustId == null ? 0 : Convert.ToInt64(FMaterialId["Id"]);
DynamicObject FBomId = (DynamicObject)this.View.Model.GetValue("FBomId", 0);
//string type1 = (string)this.View.Model.GetValue("F_THTYPE");
long FBomId1 = FCustId == null ? 0 : Convert.ToInt64(FBomId["Id"]);
decimal FQty = (decimal)this.View.Model.GetValue("FQty");
decimal FPDPrice = (decimal)this.Model.GetValue("FPrice");

// DynamicObject FCustId = (DynamicObject)this.View.Model.GetValue("FCustId", 0);//获取销售单位的值类型

// this.View.Model.SetValue("F_PAEZ_Base", FCustId1);
billpara.CustomParams.Add("Cust", FCustId1.ToString());//客户的传值
billpara.CustomParams.Add("Material", FMaterialId1.ToString());//物料编码的传值
billpara.CustomParams.Add("Bom", FBomId1.ToString());//BOM版本的传值
billpara.CustomParams.Add("Qty", FQty.ToString());//数量的传值
billpara.CustomParams.Add("Price", FPDPrice.ToString());//单价的传值
//billpara.CustomParams.Add("",)
//ReturnInfo returninfo = new ReturnInfo();
// this.View.ShowForm(billpara,);
//打开已有的单据的内码
// billpara.PKey = "100003";
this.View.ShowForm(billpara, new Action((formResult) =>
{
if (formResult != null && formResult.ReturnData != null)
{

var rows = ((ReturnInfo)formResult.ReturnData).rows;
// int rows = this.View.Model.GetEntryRowCount("F_PAEZ_Entity");
//object lists = ((ReturnInfo)formResult.ReturnData).list;

int fatrows = this.View.Model.GetEntryRowCount("FChilEntity");
// var list = this.View.Model.GetEntryRowCount("list");

// object FChilid=((ReturnInfo)formResult.ReturnData).FChilMaterialid;

//获取父界面的单据体集合
Entity entity = this.View.BillBusinessInfo.GetEntity("FChilEntity");
DynamicObjectCollection entrys1 = this.Model.GetEntityDataObject(entity);

//获取动态表单单据体的集合
DynamicObjectCollection tempEntry = ((ReturnInfo)formResult.ReturnData).TempEntry;

// Entity entity = ((ReturnInfo)formResult.ReturnData).entitry;
for (int rowIndex = 0; rowIndex < tempEntry.Count; rowIndex++)
{

//通过索引返回数据
DynamicObject newEntryRow = (DynamicObject)tempEntry[rowIndex].Clone(false, true);
//string newE= newEntryRow.ToString();
//将动态单据的数据加到父单据体上
entrys1.Add(newEntryRow);
}
this.View.UpdateView("FChilEntity");

}
}));

}
}
}

public override void BarItemClick(BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.Equals("tbReturn"))
{

Entity entity1 = this.View.BillBusinessInfo.GetEntity("F_PAEZ_Entity");
var rows=this.View.Model.GetEntryRowCount("F_PAEZ_Entity");
DynamicObjectCollection entrys = this.Model.GetEntityDataObject(entity1);

ReturnInfo returnInfo = new ReturnInfo();
// returnInfo.entitry = entity;
returnInfo.rows = rows;
returnInfo.TempEntry = entrys;
this.View.ReturnToParentWindow(returnInfo);
this.View.Close();
}
else if (e.BarItemKey.Equals("tbExit"))
{
this.View.Close();
}
}
}

class ReturnInfo
{
//public int i{get;set;}

public object FCustId { get; set; }
public object FMaterialId { get; set; }
public object FBomId { get; set; }
public object FQty { get; set; }
public object FSaleOrderEntry { get; set; }
public string FChilMaterialid { get; set; }

public int rows { get; set; }

public object list { get; set; }

public DynamicObjectCollection TempEntry { get; set; }

}
}questionpost