码迷,mamicode.com
首页 > 其他好文 > 详细

Cloud开发动态列的简单账表

时间:2020-02-18 20:42:55      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:material   list   comm   实现   time   his   and   ice   column   

业务场景:客户需要根据过滤条件的不同显示不同的列。如下方式可以实现动态的列名。

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;

namespace Report
{
    [Description("部门每月领用数量统计表")]
    public class Report : SysReportBaseService
    {
        public DataSet ds = new DataSet();
        public override void Initialize()
        {
            base.Initialize();
            this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;
            this.ReportProperty.ReportName = new LocaleValue("部门每月领用数量统计表", base.Context.UserLocale.LCID);
            this.ReportProperty.BillKeyFieldName = "dept";
        }

        public override string GetTableName()
        {
            var result = base.GetTableName();
            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;
        }
    }

}

 

Cloud开发动态列的简单账表

标签:material   list   comm   实现   time   his   and   ice   column   

原文地址:https://www.cnblogs.com/zfangfang/p/12327594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!