【二开】采购[历史价格]查询功能代码案例

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

【二开】采购[历史价格]查询功能代码案例

场景解释:

采购相关的单据,明细体里的查询有【历史价格】查询的按钮,很多二开反馈想到别的单据也实现这个功能采购业务单据或基础资料支持快捷查询历史价格和价目表价格 (kingdee.com),一下贴出代码案例,供各位参考




using System;
using System.Collections.Generic;
using System.Linq;
using Kingdee.BOS.Business.Bill.Service.Tax;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Objects.Permission.Objects;
using Kingdee.BOS.Core.Permission;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.Core.SCM;
using Kingdee.K3.SCM.ServiceHelper;


public override void EntryBarItemClick(BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e)
{
  switch (e.BarItemKey.ToUpperInvariant())
  {
      case "TBHISPRICE"://历史价格查询
             
             //当前行
           int currentRow = 0; 
           //其余单据,注意替换单据体标识FPUR_PATENTRY
          currentRow =this.View.Model.GetEntryCurrentRowIndex("FPUR_PATENTRY");
          //组织信息,根据二开需求和二开单据获取,替换FPurchaseOrgId
          DynamicObject purOrgId = this.View.Model.GetValue("FPurchaseOrgId") as DynamicObject;
          
          //物料、单位、辅助属性、结算币别、是否含税等字段的获取
                    if (currentRow > -1)
                    {
                        DynamicObject materailId = this.View.Model.GetValue("FMaterialId", currentRow) as DynamicObject;
                        DynamicObject materialName = this.View.Model.GetValue("FMaterialName", currentRow) as DynamicObject;
                        DynamicObject unitIdObj = this.View.Model.GetValue("FUnitID", currentRow) as DynamicObject;
                        DynamicObject auxPropId = this.View.Model.GetValue("FAuxPropId", currentRow) as DynamicObject;
                        DynamicObject settleCurrId = this.View.Model.GetValue("FCurrencyID", currentRow) as DynamicObject;
                        string FISINCLUDEDTAX = this.View.Model.GetValue("FIsIncludedTax", currentRow).ToString();
                        string materialIds = materailId != null ? Convert.ToString(materailId["Id"]) : "0";
                        string materialNames = materailId != null ? Convert.ToString(materailId["Name"]) : "";
                        string materialNumbers = materailId != null ? Convert.ToString(materailId["NUMBER"]) : "";
                        string auxPropIds = auxPropId != null ? Convert.ToString(auxPropId["Id"]) : "0";
                        string unitIds = unitIdObj != null ? Convert.ToString(unitIdObj["Id"]) : "0";
                        if (purOrgId == null || settleCurrId == null || materailId == null)
                        {
                            this.View.ShowErrMessage(Kingdee.BOS.Resource.ResManager.LoadKDString("采购组织、币别、物料为必填项,请先确认录入", "004011030002017", BOS.Resource.SubSystemType.SCM), "", MessageBoxType.Error);
                            e.Cancel = true;
                            return;
                        }
                        
                        
                        //以报表形式展示历史价格数据
                        PriceQueryRpt(
                            Convert.ToString(purOrgId["Id"]),
                            materialIds,
                            materialNames,
                            materialNumbers,
                            unitIds,
                            auxPropIds,
                            Convert.ToString(settleCurrId["Id"]),
                            0,
                            FISINCLUDEDTAX);
                    }
                    break;
            }
        }
        
        
            /// <summary>
        /// 报表展示界面
        /// </summary>
        /// <param name="purOrgId"></param>
        /// <param name="supplierId"></param>
        /// <param name="sourceType"></param>
        /// <param name="dateFrom"></param>
        /// <param name="dateTo"></param>
        /// <param name="dataSource"></param>
        private void PriceQueryRpt(string purOrgId, string materials, string materialNames, string materailNumbers, string unitIds, string auxPropIds, string settleCurrId, long currentRow, string FISINCLUDEDTAX)
        {
            DynamicFormShowParameter dyForm = new DynamicFormShowParameter();
            dyForm.FormId = "PUR_HistoryPrice";
            dyForm.ParentPageId = this.View.PageId;
            dyForm.CustomParams.Add("PurOrgId", purOrgId);
            dyForm.CustomParams.Add("MaterialNames", materialNames);
            dyForm.CustomParams.Add("MaterialNumbers", materailNumbers);
            dyForm.CustomParams.Add("MaterialIds", materials);
            dyForm.CustomParams.Add("UnitIds", unitIds);
            dyForm.CustomParams.Add("AuxPropIds", auxPropIds);
            dyForm.CustomParams.Add("SettleCurrId", settleCurrId);
            dyForm.CustomParams.Add("CurrentRow", currentRow.ToString());
            dyForm.CustomParams.Add("FISINCLUDEDTAX", FISINCLUDEDTAX);
            dyForm.CustomParams.Add("SOURCEFORMID", this.View.BusinessInfo.GetForm().Id);
            dyForm.CustomParams.Add("DateNow", Convert.ToString(Kingdee.BOS.ServiceHelper.TimeServiceHelper.GetSystemDateTime(this.Context)));
            this.View.ShowForm(dyForm);
        }



【二开】采购[历史价格]查询功能代码案例

场景解释:采购相关的单据,明细体里的查询有【历史价格】查询的按钮,很多二开反馈想到别的单据也实现这个功能采购业务单据或基础资料支持...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息