zoukankan      html  css  js  c++  java
  • 水晶报表参数构建和数据传入显示函数

      #region 参数构建
            private ParameterFields GetParameterFields(Dictionary<string,string > dicValue)
            {
                ParameterFields fields = new ParameterFields();

                foreach (string key in dicValue.Keys)
                {
                    fields.Add(this.CreateParameterField(key, dicValue[key]));
                }
                return fields;
            }
            private ParameterField CreateParameterField(string FieldName, object FieldValue)
            {
                ParameterField field = new ParameterField();
                ParameterDiscreteValue pvalue = new ParameterDiscreteValue();


                pvalue.Value = FieldValue;
                field.Name = FieldName;
                field.CurrentValues.Add(pvalue);
                field.AllowCustomValues = false;

                //返回参数字段
                return field;
            }
            #endregion
            #region 显示报表
            /// <summary>
            /// 显示报表
            /// </summary>
            /// <param name="formularFieldsValue">显示字段离散值</param>
            /// <param name="dicValue">参数键值对</param>
            /// <param name="reportData">报表数据</param>
            /// <param name="reportFile">报表文件</param>
            /// <param name="reportView">报表控件</param>
            public void ShowReport(string[] formularFieldsValue, Dictionary<string, string> dicValue, DataSet reportData, string reportFile, CrystalReportViewer reportView)
            {
                //使用报表对象加载报表
                ReportDocument myReport = new ReportDocument();        
                myReport.Load(reportFile);
                DataDefinition dataDefinition = myReport.DataDefinition;
                //获取数据对象中的公式字段集合
                string[] Text4formularFields = formularFieldsValue;           
                FormulaFieldDefinitions formularFields = dataDefinition.FormulaFields;
                for (int i = 0; i < formularFieldsValue.Length; i++)
                {
                    formularFields[i].Text = formularFieldsValue[i];
                }
                myReport.SetDataSource(reportData);
                reportView.ParameterFieldInfo = GetParameterFields(dicValue);
                reportView.ReportSource = myReport;

            }
            public void ShowReport(string[] formularFieldsValue, Dictionary<string, string> dicValue, DataTable reportData, string reportFile, CrystalReportViewer reportView)
            {
                //使用报表对象加载报表
                ReportDocument myReport = new ReportDocument();
                myReport.Load(reportFile);
                DataDefinition dataDefinition = myReport.DataDefinition;
                //获取数据对象中的公式字段集合
                string[] Text4formularFields = formularFieldsValue;
                FormulaFieldDefinitions formularFields = dataDefinition.FormulaFields;
                for (int i = 0; i < formularFieldsValue.Length; i++)
                {
                    formularFields[i].Text = formularFieldsValue[i];
                }
                myReport.SetDataSource(reportData);
                reportView.ParameterFieldInfo = GetParameterFields(dicValue);
                reportView.ReportSource = myReport;

            }
            public void ShowReport <T>(string[] formularFieldsValue, Dictionary<string, string> dicValue, List<T> reportData, string reportFile, CrystalReportViewer reportView)
            {
                //使用报表对象加载报表
                ReportDocument myReport = new ReportDocument();
                myReport.Load(reportFile);
                DataDefinition dataDefinition = myReport.DataDefinition;
                //获取数据对象中的公式字段集合
                string[] Text4formularFields = formularFieldsValue;
                FormulaFieldDefinitions formularFields = dataDefinition.FormulaFields;
                for (int i = 0; i < formularFieldsValue.Length; i++)
                {
                    formularFields[i].Text = formularFieldsValue[i];
                }
                myReport.SetDataSource(reportData);
                reportView.ParameterFieldInfo = GetParameterFields(dicValue);
                reportView.ReportSource = myReport;

            }
            #endregion

  • 相关阅读:
    JavaScript进阶系列06,事件委托
    JavaScript进阶系列05,事件的执行时机, 使用addEventListener为元素同时注册多个事件,事件参数
    JavaScript进阶系列04,函数参数个数不确定情况下的解决方案
    JavaScript进阶系列03,通过硬编码、工厂模式、构造函数创建JavaScript对象
    JavaScript进阶系列02,函数作为参数以及在数组中的应用
    JavaScript进阶系列01,函数的声明,函数参数,函数闭包
    委托、Lambda表达式、事件系列07,使用EventHandler委托
    委托、Lambda表达式、事件系列06,使用Action实现观察者模式,体验委托和事件的区别
    委托、Lambda表达式、事件系列05,Action委托与闭包
    委托、Lambda表达式、事件系列04,委托链是怎样形成的, 多播委托, 调用委托链方法,委托链异常处理
  • 原文地址:https://www.cnblogs.com/wanyuan8/p/2217467.html
Copyright © 2011-2022 走看看