Reportmigration:CrystalReports 到 SSRS 参数已应用但未使用

Reportmigration: CrystalReports to SSRS Parameter is applied but not used

我目前正在尝试将报表从 CrystalrReports 迁移到 SSRS。我对报告还很陌生,之前还没有使用过其中的八个报告系统。

我有一个主报告,有 2 个子报告。它们工作正常并显示所需的数据。 有 2 个参数,AllFields 参数和 SelectedId 参数。

AllFields 告知是否应为每个数据行保留空字段。 SelectedId 表明在查看器中 select 编辑了哪个数据行,因此报告只能与该特定数据有关。

当我调试我的代码时,应用了正确的参数。我完全不知道为什么他仍在处理所有数据,不管我 select.

这是报告下方的 C# 代码:

    public HauptformularReportForm(DataTable themen, GespraechprotokollDAO gespraechprotokollDao, GrundlagendokumenteDAO grundlagendokumenteDao, bool onlyFilledFiels, int themaId)
        : this()
    {
        themaDS = new ReportDataSource("DataSet1", themen);
        // fill themen to display
        bewertungDS = ComputeAndFillBewertungs(themen);
        // display all fields = also empty ones
        ReportParameter rp = new ReportParameter("AllFields", (!onlyFilledFiels).ToString());
        // -1 means all themen
        tid = new ReportParameter("SelectedId", themaId.ToString());
        parameterList = new List<ReportParameter>();
        parameterList.Add(rp);
        parameterList.Add(tid);
        this.crystalReportViewer.LocalReport.SetParameters(parameterList);
        this.crystalReportViewer.LocalReport.DataSources.Clear();
        this.crystalReportViewer.LocalReport.DataSources.Add(themaDS);
        this.crystalReportViewer.LocalReport.DataSources.Add(bewertungDS);
        this.crystalReportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SetSubDataSource);
        //this.crystalReportViewer.LocalReport.Refresh();
        this.crystalReportViewer.RefreshReport();
    }

    public void SetSubDataSource(object sender, SubreportProcessingEventArgs e)
    {
        // display all fields = also empty ones
        e.DataSources.Add(themaDS);
        e.DataSources.Add(bewertungDS);
    }

    /// <summary>
    /// The report will only display the given thema
    /// </summary>
    /// <param name="themaId"></param>
    public void DisplaySingleThema(int themaId)
    {
        tid.Values.Clear();
        tid.Values.Add(themaId.ToString());
        parameterList.Add(tid);
    }

    /// <summary>
    /// Compute the average Bewertungs for all given themen, 
    /// fill a DataTable with the computed averages and use is as datasource in the report.
    /// </summary>
    /// <param name="themen"></param>
    private ReportDataSource ComputeAndFillBewertungs(DataTable themen)
    {
        HauptformularReportDataSet.BewertungDataTable bewertungDataTable = new HauptformularReportDataSet.BewertungDataTable();

        // get bewertungs of all themen
        Dictionary<int, IList<IFrageWithBewertung>> dictionary = BewertungsExtractor.Extract(themen);

        // fill table with thema_id and computed bewertung
        foreach (KeyValuePair<int, IList<IFrageWithBewertung>> themaBewertung in dictionary)
        {
            HauptformularReportDataSet.BewertungRow row = bewertungDataTable.NewBewertungRow();

            row.THEMA_ID = themaBewertung.Key;
            row.BewertungOfAllFragen = BewertungAverageComputer.ComputeAverage(themaBewertung.Value);
            row.BewertungOfFragenWithStatus = BewertungAverageComputer.ComputeAverage(themaBewertung.Value, true);

            bewertungDataTable.AddBewertungRow(row);
        }

        // set datasource in report
        report.Database.Tables["Bewertung"].SetDataSource(bewertungDataTable as DataTable);
        return new ReportDataSource("DataSet2", bewertungDataTable as DataTable);

    }
}

我错过了什么或做错了什么?为什么我的参数应用正确(我在调试器中看到正确的值)但仍然没有真正使用?

好吧,代码大部分是正确的,除了我在上面的例子中给子报表提供了错误的数据源。

我不知道过滤器,当我用谷歌搜索我的问题时甚至没有提到它们。无论如何它现在工作,需要根据 report/subreport.

过滤内容