下推插件,单据体基础资料赋值出现的问题,求大神解答
金蝶云社区-云社区用户97x31224
云社区用户97x31224
0人赞赏了该文章 1,803次浏览 未经作者许可,禁止转载编辑于2017年09月06日 12:17:39

需求是想在报销单下推付款单时,根据组织和结算方式是电汇的时候,把我方银行账号设置固定值(是基础资料赋值)
问题:下推下来的付款单银行账号是赋了值的,但是一保存,再进来这个单子的时候,这个字段就没了
代码如下:
public override void AfterConvert(AfterConvertEventArgs e)
{

BaseDataField FBANKACNTID = e.TargetBusinessInfo.GetField("FACCOUNTID") as BaseDataField;
IViewService viewService = ServiceHelper.GetService();
//分公司
long Bankid1 = 221983;
long Bankid2 = 221974;
DynamicObject[] BankObjs1 = viewService.LoadFromCache(this.Context,
new object[] { Bankid1 },
FBANKACNTID.RefFormDynamicObjectType);
//子公司
DynamicObject[] BankObjs2 = viewService.LoadFromCache(this.Context,
new object[] { Bankid2 },
FBANKACNTID.RefFormDynamicObjectType);
//stockFld.RefIDDynamicProperty.SetValue(newRowObj, stockId);
//stockFld.DynamicProperty.SetValue(newRowObj, stockObjs[0]);

// 目标单第二单据体:明细
Entity secondEntity = e.TargetBusinessInfo.GetEntity("FPAYBILLENTRY");
// 目标单关联子单据体
Entity linkEntity = null;
Form form = e.TargetBusinessInfo.GetForm();
if (form.LinkSet != null
&& form.LinkSet.LinkEntitys != null
&& form.LinkSet.LinkEntitys.Count != 0)
{
linkEntity = e.TargetBusinessInfo.GetEntity(
form.LinkSet.LinkEntitys[0].Key);
}

if (linkEntity == null)
{
return;
}
// 获取生成的全部下游单据
ExtendedDataEntity[] data = e.Result.FindByEntityKey("FBillHead");
if (data != null && data.Length > 0)
{
foreach (ExtendedDataEntity entity in data)
{
DynamicObject billObj = entity.DataEntity;
// 定义一个集合,用于收集本单对应的源单内码
//HashSet srcBillIds = new HashSet();
//// 开始到主单据体中,读取关联的源单内码

long SETTLEORGID = Convert.ToInt64(billObj["SETTLEORGID_Id"]);

if (SETTLEORGID == 100004)
{
//&& PaySettlleTypeID==4
DynamicObjectCollection secondEntityRows =
secondEntity.DynamicProperty.GetValue(billObj) as DynamicObjectCollection;
foreach (var secondEntryRow in secondEntityRows)
{
long PaySettlleTypeID = Convert.ToInt64(secondEntryRow["SETTLETYPEID_Id"]);
if (PaySettlleTypeID == 4)
{
//secondEntryRow["FACCOUNTID_Id"] = 214347;
//secondEntryRow["FACCOUNTID"] = BankObjs1[0];

FBANKACNTID.RefIDDynamicProperty.SetValue(secondEntryRow, 214347);
FBANKACNTID.DynamicProperty.SetValue(secondEntryRow, BankObjs1[0]);
}
}
}
else if (SETTLEORGID == 100005)
{
DynamicObjectCollection secondEntityRows =
secondEntity.DynamicProperty.GetValue(billObj) as DynamicObjectCollection;
foreach (var secondEntryRow in secondEntityRows)
{
long PaySettlleTypeID = Convert.ToInt64(secondEntryRow["SETTLETYPEID_Id"]);
if (PaySettlleTypeID == 4)
{
//secondEntryRow["FACCOUNTID_Id"] = 213762;
//secondEntryRow["FACCOUNTID"] = BankObjs2[0];
FBANKACNTID.RefIDDynamicProperty.SetValue(secondEntryRow, 213762);
FBANKACNTID.DynamicProperty.SetValue(secondEntryRow, BankObjs2[0]);
}
}
}
}
}
}

这是我赋值完后付款单的数据包图片,我所赋值字段是红线圈住的