其他分享
首页 > 其他分享> > 重写金蝶简单账表示例

重写金蝶简单账表示例

作者:互联网

重写金蝶标准应收款明细表添加应收单上的自定义文本字段

点击查看代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Kingdee.K3.FIN.AR.App.Report;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core.Report;

namespace JY.SCM.AR.ARDetailReportService1
{
    [Description("【应收款明细表-自定义字段】")]
    [Kingdee.BOS.Util.HotUpdate]
    public class CustomReportService : ARDetailReportService
    {

        private string[] customReportTempTableNames; 

        public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
        {
            //创建临时表
            IDBService dBService = Kingdee.BOS.App.ServiceHelper.GetService<IDBService>();
            //需要传入context上下文,已经int count数量
            customReportTempTableNames = dBService.CreateTemporaryTableName(this.Context,1);
            //customReportTempTableNames返回一个string类型的数组
            string strTable = customReportTempTableNames[0];
            //获取标准报表插件创建出来的临时表
            base.BuilderReportSqlAndTempTable(filter, strTable);
            //对初步的查询结果进行处理,然后写会基类默认的存放查询结果的临时表
            StringBuilder sb = new StringBuilder();
            //重写BuilderReportSqlAndTempTable时系统默认生成的唯一临时表名,注意into前有空格,调试后可复制sql执行
            string strsql = "/*dialect*/ SELECT t0.*, case when ISNULL(F_WASD_Text,'')<>'' then F_WASD_Text end F_WASD_Text " +
                "into {0} " +
                " from {1} t0 " +
                "left join  t_AR_receivable t1 on t0.FFORMId = 'AR_receivable' and t0.fid = t1.fid" +
                "  left join t_AR_receivableEntry t2 on t1.fid = t2.fid";
            //传入需要拼接的字符串,以及对应的占位符需要的值,新生成的临时表名,标准插件的临时表名
            sb.AppendFormat(strsql,tableName,strTable);
            DBUtils.Execute(this.Context, sb.ToString());
        }

        //关闭报表时执行
        public override void CloseReport()
        {
            if (customReportTempTableNames.IsNullOrEmptyOrWhiteSpace())
            {
                return;
            }
            IDBService dbService   = Kingdee.BOS.App.ServiceHelper.GetService<Kingdee.BOS.Contracts.IDBService>();
            dbService.DeleteTemporaryTableName(this.Context, customReportTempTableNames);
            base.CloseReport();
        }

    }
}

说明:参考金蝶云社区帖子实现,原贴路径https://vip.kingdee.com/article/285118202751868703?productLineId=1

标签:customReportTempTableNames,string,金蝶,BOS,System,Kingdee,简单,using,重写
来源: https://www.cnblogs.com/hqc-for-s/p/16369370.html