Cloud dynamic development of simple accounts table columns

Business scenario: Customers need to display different filtering criteria different column. A way that enables dynamic column name.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS.Core.Report.PlugIn;
using Kingdee.BOS.Core.Report;
using System.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Util;
using Kingdee.BOS;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.List;
using System.ComponentModel;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using Kingdee.BOS.Core.DynamicForm;

the Report namespace
{
    [the Description ( "requisitioned number of monthly tables")]
    public class the Report: SysReportBaseService
    {
        public new new the DataSet the DataSet DS = ();
        public void the override the Initialize ()
        {
            base.Initialize ();
            this.ReportProperty. = ReportType.REPORTTYPE_NORMAL ReportType;
            this.ReportProperty.ReportName = new new LocaleValue ( "requisitioned the number of monthly statistics", base.Context.UserLocale.LCID);
            this.ReportProperty.BillKeyFieldName = "the dept";
        }

        public String GetTableName the override ()
        {
            var base.GetTableName Result = ();
            return Result;
        }

        public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
        {
            base.BuilderReportSqlAndTempTable(filter, tableName);
            // 获取过滤条件
            DynamicObject customFil = filter.FilterParameter.CustomFilter;
            String StartTime = customFil["F_Dev_StartTime"].ToString();
            String StopTime = customFil["F_Dev_StopTime"].ToString();

            string seqFld = string.Format(base.KSQL_SEQ, " dept ");

            KSQL_SEQ = string.Format(KSQL_SEQ, "dept asc");
            string sSQL = @"exec P_ExportToChart '" + StartTime + "','" + StopTime + "','{0}','{1}'";
            string sSQLWithNoTempTable = @"exec P_ExportToChartWithNoTempTable '" + StartTime + "','" + StopTime + "'";
            ds = DBServiceHelper.ExecuteDataSet(this.Context, sSQLWithNoTempTable);
            sSQL = string.Format(sSQL, this.KSQL_SEQ, tableName);
            DBUtils.Execute(this.Context, sSQL);
        }

        public override ReportTitles GetReportTitles(IRptParams filter)
        {
            ReportTitles titles = new ReportTitles();
            // 获取过滤条件
            DynamicObject customFil = filter.FilterParameter.CustomFilter;
            String StartTime = customFil["F_Dev_StartTime"].ToString();
            String StopTime = customFil["F_Dev_StopTime"].ToString();

            titles.AddTitle("FSTARTTIME", StartTime);
            titles.AddTitle("FSTOPTIME", StopTime);
            return titles;
        }
        /// <summary>
        /// 构建动态列
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public override ReportHeader GetReportHeaders(IRptParams filter)
        {
            // TODO:fentryid,fid,fbaseunitqty,fmaterialid,fbomid,fqty
            ReportHeader header = new ReportHeader();
            //header.AddChild("fwname", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("物料", "002460030014689", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
            //header.AddChild("fcustid", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("客户", "002460030014692", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
            //header.AddChild("FQty", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("数量", "002460030014695", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID), SqlStorageType.SqlDecimal);
            //header.AddChild("fprice", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("单价", "002460030014698", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID), SqlStorageType.SqlDecimal);
            //header.AddChild("famount", new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString("金额", "002460030014701", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID), SqlStorageType.SqlDecimal);
            header = this.GetHeaders(ds);
            return header;
        }

        public ReportHeader GetHeaders(DataSet ds)
        {
            ReportHeader header = new ReportHeader();
            int count = ds.Tables[0].Columns.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    header.AddChild(ds.Tables[0].Columns[i].ToString(), new LocaleValue(Kingdee.BOS.Resource.ResManager.LoadKDString(ds.Tables[0].Columns[i].ToString(), "002460030014689", Kingdee.BOS.Resource.SubSystemType.BOS), this.Context.UserLocale.LCID));
                }
            }
            return header;
        }
    }

}

 

Guess you like

Origin www.cnblogs.com/zfangfang/p/12327594.html