如何通过传递多个值来批量打印报告

时间:2018-10-10 13:36:52

标签: c# sql-server wpf crystal-reports

我有一个学生列表,我想为每个正在使用SQL storageProcedure获取数据和Crystal Reports的学生打印费用清单。我想做的是,打开所有ReportViewer并传递所有studentIds并在预览部分显示它们。

我做到了:

ReportDocument rd = new ReportDocument();

private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
{
    rd.Load(@"C:\\Program Files (x86)\CognitiveDev\TKS Management System\Reports\FeeSlip.rpt");

    try
    {
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = ConfigurationManager.ConnectionStrings["Other"].ConnectionString;
        conn.Open();

        SqlDataAdapter sda = new SqlDataAdapter("PrintFeeSlip", conn);
        sda.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure;

        foreach (int gotId in gotList)
        {
           sda.SelectCommand.Parameters.AddWithValue("@AdmissionNumber", gotId);

            DataSet ds = new DataSet();
            sda.Fill(ds, "FeeSlip");
            rd.SetDataSource(ds);

            reportView.ViewerCore.ReportSource = rd;
            reportView.ViewerCore.RefreshReport();
        }
    }
    catch (Exception err)
    {
        MessageBox.Show(err.ToString());
    }
}

此代码仅适用于单个代码,但多个stdID应该怎么办

enter image description here

0 个答案:

没有答案