当我们在服务端代码里通过修改数据包或者sql更新数据的时候是无法触发值更新事件和实体服务规则等前端逻辑的,这种情况可以通过创建view,修改数据的方式来触发更新
List<DynamicObject> datas = new List<DynamicObject>();
List<IDynamicFormView> dfvs = new List<IDynamicFormView>();
FormMetadata metaData = AppServiceContext.MetadataService.Load(this.Context, MFGFormIdConst.SubSys_PRD.PPBOMBill) as FormMetadata;
IDynamicFormView dfv = MFGBaseDataHelperUtil.CreateBillEditView(this.Context, metaData, 480852, true);//480852是用料清单内码,根据情况赋值(MFGBaseDataHelperUtil需要引用Kingdee.K3.MFG.App)
IBillView ibv = dfv as IBillView;
IBillViewService ibvs = dfv as IBillViewService;
ibvs.UpdateValue("FNumerator", 0, 11);//第二个参数0是序号,对应子项明细的FSeq-1
ibvs.UpdateValue("FDenominator", 0, 1);
datas.Add(dfv.Model.DataObject);
dfvs.Add(dfv);
if (!datas.IsEmpty())
{
var result = AppServiceContext.SaveService.Save(this.Context, metaData.BusinessInfo, datas.ToArray());
} //关闭单据,以释放网控
foreach (IDynamicFormView item in dfvs)
{
(item as IBillView).Model.DataChanged = false;
(item as IBillView).Close();
}
推荐阅读