Sunday, 25 August 2013

Printing multiple reports at once in crystal report

Printing multiple reports at once in crystal report

My requirement is to generate/print mark-sheet of all student of a
particular class at a single click, in crystal report.
WHEN I USED For loop then it shows only the last record/page of the report.
AND My code is
private void btnGenerate_Click(object sender, 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!");
}
}
how can i append multiple marksheet at once and print them at once??

No comments:

Post a Comment