【金蝶二开,获取系统单据并赋值可调用值更新实体服务规则】

// 获取元数据集合,可以对数据进行修改,新增等操作
var materailMetadata = ServiceHelper.GetService<Kingdee.BOS.Contracts.IMetaDataService>().Load(Context, "PUR_PAT") as FormMetadata;
// 获取业务元素据
var materailBiz = materailMetadata.BusinessInfo;
// 定义一个DynamicObject包为量体单动态实体定义
DynamicObject dynObj = new DynamicObject(materailMetadata.BusinessInfo.GetDynamicObjectType());
// 设置单据体
var entityInvPty = materailBiz.GetEntity("FPUR_PATENTRY");
var entityInvPtyData = dynObj[entityInvPty.EntryName] as DynamicObjectCollection;
dynObj["Name"] = "CS101";
dynObj["Date"] = dateOnlyString;
dynObj["PurchaseOrgId_Id"] = e.DataEntitys[0]["PurchaseOrgId_Id"];
dynObj["UseORGId_Id"] = e.DataEntitys[0]["PurchaseOrgId_Id"];
dynObj["EffectiveDate"] = dateOnlyString;
dynObj["CreatorId_Id"] = e.DataEntitys[0]["ApproverId_Id"];
dynObj["EffectiveUserId_Id"] = e.DataEntitys[0]["ApproverId_Id"];
dynObj["CreateDate"] = dateOnlyString;
dynObj["PaReason_Id"] = "7590e08cf9064cdfbfe7e3a7fb0741e2";
// 本方法可以直接加载基础资料,辅助资料等数据
DBServiceHelper.LoadReferenceObject(Context,new[{dynObj},materailMetadata.BusinessInfo.GetDynamicObjectType(), true);
MoView.Model.DataObject = dynObj;
// 遍历单据体
int k = 0;
foreach (var it in pair.Value)
{
// 获取匹配数据
var thdj = a1.Where(t => Convert.ToString(t["FMATERIALID"]).Equals(Convert.ToString(it["FMATERIALID"]))).Distinct().ToList();
var entityInvPtyRow = new DynamicObject(entityInvPty.DynamicObjectType);
entityInvPtyRow["MaterialId_Id"] = Convert.ToInt32(it["FMATERIALID"]);
entityInvPtyRow["PriceListId_Id"] = Convert.ToString(it["FID"]);
entityInvPtyRow["SupplierId_Id"] = Convert.ToInt32(it["FSUPPLIERID"]);
entityInvPtyRow["UnitID_Id"] = Convert.ToInt32(it["FUNITID"]);
entityInvPtyRow["AdjustRange"] = 1;
DBServiceHelper.LoadReferenceObject(Context, new[] { entityInvPtyRow }, entityInvPty.DynamicObjectType, true);
// 在元数据中调用实体服务规则和值更新
MoView.RuleContainer.RaiseDataChanged("FMaterialId", dynObj, new BOSActionExecuteContext(MoView));
MoView.InvokeFieldUpdateService("FMaterialId", k);
MoView.RuleContainer.RaiseDataChanged("FPriceListId", dynObj, new BOSActionExecuteContext(MoView));
MoView.InvokeFieldUpdateService("FPriceListId", k);
MoView.RuleContainer.RaiseDataChanged("FSupplierId", dynObj, new BOSActionExecuteContext(MoView));
MoView.InvokeFieldUpdateService("FSupplierId", k);
entityInvPtyData.Add(entityInvPtyRow);
entityInvPtyData[k]["Seq"] = k;
entityInvPtyData[k]["IsIncludedTax"] = false;
entityInvPtyData[k]["FIsPriceExcludeTax"] = true;
entityInvPtyData[k]["BeforePrice"] = Convert.ToDouble(it["FPRICE"]);
entityInvPtyData[k]["AfterPrice"] = Convert.ToDouble(thdj[0]["F_YDL_DJ"]);
//entityInvPtyData[k]["BeforePriceCoefficient"] = 1;
//entityInvPtyData[k]["AfterPriceCoefficient"] = 1;
var sx = (Convert.ToDecimal(1) + (privateKey / 100)) * Convert.ToDecimal(thdj[0]["F_YDL_DJ"]);
var xx = (Convert.ToDecimal(1) - (privateKey / 100)) * Convert.ToDecimal(thdj[0]["F_YDL_DJ"]);
entityInvPtyData[k]["EffectiveDate"] = dateOnlyString;
entityInvPtyData[k]["ExpiryDate"] = endDate;
entityInvPtyData[k]["SrcEntryID"] = Convert.ToInt32(it["FENTRYID"]);
MoView.RuleContainer.RaiseDataChanged("FBeforePrice", dynObj, new BOSActionExecuteContext(MoView));
MoView.InvokeFieldUpdateService("FBeforePrice", k);
MoView.RuleContainer.RaiseDataChanged("FAfterPrice", dynObj, new BOSActionExecuteContext(MoView));
MoView.InvokeFieldUpdateService("FAfterPrice",
【金蝶二开,获取系统单据并赋值可调用值更新实体服务规则】
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



