服务插件中实现触发相关单据实体服务规则

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

服务插件中实现触发相关单据实体服务规则

关键以下三句:
/*
 //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;
            }
        }


服务插件中实现触发相关单据实体服务规则

关键以下三句:/* //IDynamicFormViewService dynamicFormView = view as IDynamicFormViewService; IBillViewService dynamicFormView = v...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息