批量新增及批量修改
金蝶云社区-assassinl10
assassinl10
5人赞赏了该文章 4,319次浏览 未经作者许可,禁止转载编辑于2017年09月26日 11:46:04

代码摘要备注

var targetBillMeta = MetaDataServiceHelper.Load(this.Context, "YEA_ChinaPhone_SI") as FormMetadata;
BusinessInfo info = targetBillMeta.BusinessInfo;
//更新单据的数据列表
List updateObj = new List();

Kingdee.BOS.Core.Bill.IBillView billView = YEA.K3.MIS.APP.Core.CommonUtil.CreateBillView(this.Context,
YEA.K3.MIS.APP.Core.CommonUtil.GetFormMetadata(this.Context, "YEA_ChinaPhone_SI"));
//新增单据的数据列表
List saveObj = new List();

//TODO 后台未存在,需要新增单据
((IBillViewService)billView).LoadData();
this.FillBillPropertys(billView, dataRow);
saveObj.Add(billView.Model.DataObject);

//TODO 后台单据已存在,需要更新
object[] obs = { fid };
DynamicObject dynamicObject = BusinessDataServiceHelper.Load(this.Context, obs,
targetBillMeta.BusinessInfo.GetDynamicObjectType())[0];
UpdateData(dynamicObject, dataRow, info);
updateObj.Add(dynamicObject);

if (updateObj.Count > 0)
{
//批量保存
IOperationResult result = BusinessDataServiceHelper.Save(this.Context, targetBillMeta.BusinessInfo, updateObj.ToArray());
if (result != null)
{
foreach (OperateResult operateResult in result.OperateResult)
{
if (!operateResult.SuccessStatus)
{
string msg1 = operateResult.Message;
judgeStr.AppendLine(msg1);
}
}
}
}