Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
  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??
Posted

1 solution

Many years ago I tried to use Crystal Reports for (C++) output. I was frustrated with various obstacles to simply changing values at runtime.

I resorted to the .NET 2Dimensional graphics routines and never looked back to Crystal Reports.

Ultimately, you can simply write whatever you want where-ever you want on each page. No restrictions and data handling is done within your code in terms familiar to you by your own design.

If you've not familiar with them, there is, of course, a learning curve. Clearly, once you can lay out a page, you can use that to lay out any number of copies with the values of your symbols changed.

Should you go in this direction, I found it useful to use a 10x10 inch matrix (different if you use different units on your system). My trick, which allows me to create/fill out forms is to print the matrix on top of the form and simply count the number of printing units for the distance from the margins (mine are 1/100", ca. 0.24 mm.). Lay down the form as your background and then print data in appropriate locations.

Bonus: these same methods work for application design on the screen, allowing some very attractive UI's using .NET's "native" abilities (no awkward presumptions requirements of user systems.

Crystal Reports aficionados will probably get you through this, but consider this option and play with it. Simple raw power.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900