日期:2012-03-10  浏览次数:20405 次

命名空间为:using CrystalDecisions.Shared        

private void BuildReportViewerParameters(CrystalDecisions.Web.CrystalReportViewer rptViewer, Hashtable ParamTable)
        {
            //定义报表视图的参数的方法
            ParameterFields ParamFields = new ParameterFields();
            foreach (object key in ParamTable.Keys)
            {
                ParameterField ParamField = new ParameterField();
                ParameterValues ParamValues = new ParameterValues();
                ParameterDiscreteValue ParamValue = new ParameterDiscreteValue();
                ParamValue.Value = ParamTable[key].ToString();
                ParamValues.Add(ParamValue);
                ParamField.ParameterFieldName = key.ToString();
                ParamField.CurrentValues = ParamValues;
                ParamFields.Add(ParamField);
            }
            rptViewer.ParameterFieldInfo = ParamFields;
        }

        private void BuildReportClassParameters(CrystalDecisions.CrystalReports.Engine.ReportClass rpt, Hashtable ParamTable)
        {
            //定义报表类的参数的方法
            foreach (object key in ParamTable.Keys)
            {
                ParameterValues ParamValues = new ParameterValues();
                ParameterDiscreteValue ParamValue = new ParameterDiscreteValue();
                ParamValue.Value = ParamTable[key].ToString();
                ParamValues.Add(ParamValue);
                rpt.DataDefinition.ParameterFields[key.ToString()].ApplyCurrentValues(ParamValues);
            }
        }
        
        protected void BuildReportParameters(CrystalDecisions.Web.CrystalReportViewer rpt,Hashtable ParamTable)
        {
            //定义报表参数的方法
            ParameterFields ParamFields = new Parameter