服务插件中实现触发相关单据实体服务规则原创
金蝶云社区-云社区用户26064194
云社区用户26064194
3人赞赏了该文章 1,235次浏览 未经作者许可,禁止转载编辑于2021年10月14日 09:17:45
关键以下三句:
/*
 //IDynamicFormViewService dynamicFormView = view as IDynamicFormViewService;
  IBillViewService dynamicFormView = view as IBillViewService;

   dynamicFormView.UpdateValue(FFieldId, iRow, dto.TAXPRICE);
*/

public static void UpdateAmt(Context context, string formId, string fId, string ormEntry, HashSet<SelfDto> hashEntry)
        {
            try
            {
                IOperationResult operationLocalResult = null;
                try
                {
                    if (formId.IsNullOrEmptyOrWhiteSpace()
                    || fId.IsNullOrEmptyOrWhiteSpace()
                    || ormEntry.IsNullOrEmptyOrWhiteSpace()
                    || hashEntry.IsEmpty()
                    ) return;

                    IBillView view = Utils.CreateView(context, null, formId);
                    DynamicObject billObejct = Utils.LoadBillObjects(context, formId, fId);
                    view.Model.DataObject = billObejct;
                    DynamicObjectCollection entryCollect = billObejct[ormEntry] as DynamicObjectCollection;
                    if (entryCollect.IsEmpty()) return;
                    //IDynamicFormViewService dynamicFormView = view as IDynamicFormViewService;
                    IBillViewService dynamicFormView = view as IBillViewService;

                    //处理 表头 变更价 赋值为 1:变更,0:未变更
                    dynamicFormView.UpdateValue(string.Format("{0}_H",hashEntry.First().OrmISCHANGE), 0, hashEntry.First().ISCHANGE);

                    //处理 表体 变更价及含税单价等
                    for (int iRow = 0, ilen = entryCollect.Count; iRow < ilen; iRow++)
                    {
                        foreach (SelfDto dto in hashEntry)
                        {
                            if (entryCollect[iRow].GetPrimaryKeyValue<long>() == dto.EntryId)
                            {
                                //含税单价:标准字段 标识,字段名,绑定实体属性 此三者名称不相同
                                string FFieldId;
                                if (string.IsNullOrEmpty(dto.FTAXPRICE2))
                                    FFieldId = string.Format(@"F{0}", dto.OrmTAXPRICE);
                                else
                                    FFieldId = dto.FTAXPRICE2;

                                dynamicFormView.UpdateValue(FFieldId, iRow, dto.TAXPRICE);
                                dynamicFormView.UpdateValue(dto.OrmISCHANGE, iRow, dto.ISCHANGE);
                            }
                        }
                    }
                    operationLocalResult = ServiceHelper.GetService<ISaveService>().Save(context, view.BusinessInfo, new DynamicObject[] { view.Model.DataObject });
                }
                catch (Exception ex)
                {
                    if (operationLocalResult != null)
                    {
                        bool bRet = operationLocalResult.IsSuccess;
                        string strRet = operationLocalResult.ValidationErrors.Count > 0 ? operationLocalResult.ValidationErrors.FirstOrDefault().Message : String.Empty;
                        Kingdee.BOS.Log.Logger.Info("采购订单变更单审核操作", string.Format(@"catch IsSuccess:{0},产生异常信息:{1},ex:{2}", bRet, strRet, ex.StackTrace.ToString()));
                    }
                    else
                        Kingdee.BOS.Log.Logger.Info("采购订单变更单审核操作", string.Format(@"catch 产生异常信息:ex:{0}", ex.StackTrace.ToString()));
                }
                finally
                {
                    if (operationLocalResult != null)
                    {
                        bool bRet = operationLocalResult.IsSuccess;
                        string strRet = operationLocalResult.ValidationErrors.Count > 0 ? operationLocalResult.ValidationErrors.FirstOrDefault().Message : String.Empty;
                        Kingdee.BOS.Log.Logger.Info("采购订单变更单审核操作", string.Format(@"finally IsSuccess:{0},产生异常信息:{1}", bRet, strRet));
                    }
                }
            }
            catch (Exception ex)
            {
                //throw ex;
            }
        }


图标赞 3
3人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!