金蝶云星空二开-供应商对账单添加字段!!!

一、供应商对账单二开添加字段,继承原来供应商对账单表单插件Statement基类
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.K3.FIN.AP.Business.PlugIn;
using Kingdee.K3.FIN.AP.ServiceHelper;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Dynamic;
using System.Linq;
namespace Demo.BusinessPlugIn
{
    /// <summary>
    /// khdzdBillPlugin 的摘要说明
    /// </summary>
    [Kingdee.BOS.Util.HotUpdate]
    [Description("供应商对账单二开添加字段")]
    public class GysdzdBillPlugin : Statement
    {
        string customerName = ""; //过滤条件往来单位
        string newtempTable = ""; //新的临时表
        bool NewSearch = false; //是否是新查询的数据
        public override void BarItemClick(BarItemClickEventArgs e)
        {
            if (e.BarItemKey == "tbFilter")
            {
                this.customerName = "";
                NewSearch = true;
            }
            if (e.BarItemKey == "tbRefresh")
            {
                NewSearch = true;
            }
            base.BarItemClick(e);
        }
        public override void DataChanged(DataChangedEventArgs e)
        {
            if (e.Field.Key == "FCombo")
            {
                NewSearch = false;
            }
            base.DataChanged(e);
        }
        protected override void Refresh()
        {
            
            if (this.filterPara == null)
            {
                return;
            }
            string oldSelectedValue = Convert.ToString(this.View.Model.GetValue("FCombo"));
            if (Convert.ToBoolean(this.filterPara.CustomFilter["FByContact"]))
            {
                customerName = this.GetSupplierData(oldSelectedValue);
            }
            dropTempTable();
            base.Refresh();
        }
        public override void BeforeClosed(BeforeClosedEventArgs e)
        {
            dropTempTable();
            base.BeforeClosed(e);
        }
        /// 将标准的对账单生成的临时表数据复制到带有扩展字段的临时表里面去
        public void CopyDataToNewTempTable()
        {
            var custmoFilter = this.filterPara.CustomFilter;
            
            this.newtempTable = GetTempTable();
            string sql = string.Format(@"/*dialect*/ 
            select * into {1} from (
            select  
t1.*,'CCCCCCCC' 'F_TAIC_Text'
                       from {0} t1
                ) tab  ",
                   this.tempTable, this.newtempTable);
            DBUtils.Execute(this.Context, sql);
        }
        /// 获取新的带有扩展字段的数据
        public DynamicObjectCollection GetNewData()
        {
            CopyDataToNewTempTable();
            DynamicObjectCollection dataByContactUnit = StatementServiceHelper.GetDataByContactUnit(base.Context, this.newtempTable, customerName);
            return dataByContactUnit;
        }
        /// 获取新的带扩展字段的汇总数据
        public DynamicObjectCollection GetNewSumDate()
        {
            DynamicObjectCollection sumDataByContactUnit = StatementServiceHelper.GetSumDataByContactUnit(base.Context, this.newtempTable, this.agingKeys.Keys.ToList(), customerName);
            return sumDataByContactUnit;
        }
      
        public override void SetListData(DynamicObjectCollection data)
        {
            if (NewSearch)
            {
                DynamicObjectCollection dt = GetNewData();
                string oldTempTable = this.tempTable;
                this.tempTable = this.newtempTable;
                this.newtempTable = oldTempTable;
                base.SetListData(dt);
            }
            else
            {
                base.SetListData(data);
            }
        }
        public override void SetListSumData(DynamicObjectCollection data)
        {
            if (NewSearch)
            {
                DynamicObjectCollection dt = GetNewSumDate();
                base.SetListSumData(dt);
            }
            else
            {
                base.SetListSumData(data);
            }
        }
        /// 删除临时表
        private void dropTempTable()
        {
            if (!string.IsNullOrWhiteSpace(this.newtempTable))
            {
                IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
                dbservice.DeleteTemporaryTableName(this.Context, new string[] { this.newtempTable });
                this.newtempTable = "";
            }
        }
        /// 获取临时表名称
        private string GetTempTable()
        {
            IDBService dbservice = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
            string[] temptables = dbservice.CreateTemporaryTableName(this.Context, 1);
            return temptables[0];
        }
    }
}
二,供应商对账单界面添加字段,和注册插件

1,供应商对账单添加文本字段,标识和插件里面的sql对应F_TAIC_Text

 2,供应商对账单过滤条件添加字段显示

3,供应商对账单注册表单插件,禁用原来的插件 

 

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值