0

我的要求是在水晶报表中单击生成/打印特定班级所有学生的评分表。

当我使用 For 循环时,它只显示报告的最后一条记录/页面。

并且我的代码是

私人无效btnGenerate_Click(对象发送者,EventArgs e){

        try
        {
            axCrystalActiveXReportViewer1.ReportSource = null;

            ReportDocument cryRpt = new ReportDocument();
            TableLogOnInfos crtableLogoninfos = new TableLogOnInfos();
            TableLogOnInfo crtableLogoninfo = new TableLogOnInfo();
            ConnectionInfo crConnectionInfo = new ConnectionInfo();
            Tables CrTables;


            crConnectionInfo.ServerName = Configuration.ServerName;
            crConnectionInfo.DatabaseName = Configuration.DataBaseName;
            crConnectionInfo.UserID = Configuration.Server_userName;
            crConnectionInfo.Password = Configuration.Server_password;



            CrTables = cryRpt.Database.Tables;
            foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
            {
                crtableLogoninfo = CrTable.LogOnInfo;
                crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                CrTable.ApplyLogOnInfo(crtableLogoninfo);
            }

           for(int i=0; i<=x; i++)
            {
                DataSet ds_ViewTermMarkSheet = new DataSet();
                Hashtable htViewTermMarkSheet = new Hashtable();

                htViewTermMarkSheet.Add("@Year", txtYear.Text);
                htViewTermMarkSheet.Add("@Faculty", cboFaculty.Text);
                htViewTermMarkSheet.Add("@Level", cboClass.Text);
                htViewTermMarkSheet.Add("@Section", cboSection.Text);
                htViewTermMarkSheet.Add("@term", cboTerm.Text);
                htViewTermMarkSheet.Add("@CRN",.ToString());

                DbOperations _dbAccess = new DbOperations();
                _dbAccess.selectStoredProcedure(ds_ViewTermMarkSheet, "spSelectExamView_Exam_TermWiseMarkSheet", htViewTermMarkSheet, "Marks");





            cryRpt.SetDataSource(ds_ViewTermMarkSheet.Tables["Marks"]);
           }



                axCrystalActiveXReportViewer1.Refresh();


            cryRpt.Close();

        }
        catch (Exception ex)
        {
            MessageBox.Show("Mark Sheet generation was not successful.\r" + ex.Message, "Error!");
        }
    }

我怎样才能一次附加多个标记表并一次打印它们?

4

2 回答 2

0

你必须打电话:

cryRpt.SetDataSource(ds_ViewTermMarkSheet.Tables["Marks"]); 

..从外部for循环

在 for 循环中,使用您需要的所有信息填充您的数据表。然后从外部循环调用SetDataSource() method.

干杯

于 2013-08-26T04:54:23.377 回答
0

您的代码将循环并多次设置数据源,但只会为最后一个刷新报告。您需要移动刷新索引循环并在那里打印报告:

        cryRpt.SetDataSource(ds_ViewTermMarkSheet.Tables["Marks"]);
        axCrystalActiveXReportViewer1.Refresh();
        // print the rpeort
       }

处理这个问题的正确方法是创建一个报告,显示所有学生的信息。您可以按学生ID或姓名分组,并在分组后设置新页面。然后打印此报告(只需 1 次)。

于 2013-08-26T14:39:06.187 回答