Link to home
Start Free TrialLog in
Avatar of Murtaza Ginwala
Murtaza GinwalaFlag for United Arab Emirates

asked on

HOW TO PRINT CONTINUOUS CRYSTAL REPORTS

Want to print continuous crystal report using from range, below attaching image of what i want to achieve:

User generated image
Also i'm using this code to print single report
public void GetInvoiceRpt(string strReportName, string strVno)
        {
            try
            {
                int compcode = Convert.ToInt32(Application.Current.Properties["CompId"]);

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


                cryRpt.Load(strReportName);

                crConnectionInfo.ServerName = clsconnection.SQLServerName();
                crConnectionInfo.DatabaseName = "MyApplication" + clsconnection.getCompanyCode(compcode);
                crConnectionInfo.UserID = clsconnection.SQLLoginID();
                crConnectionInfo.Password = clsconnection.SQLPW();
                CrTables = cryRpt.Database.Tables;
                foreach (Table CrTable in CrTables)
                {
                    crtableLogoninfo = CrTable.LogOnInfo;
                    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
                    CrTable.ApplyLogOnInfo(crtableLogoninfo);
                }
                cryRpt.Refresh();

                cryRpt.SetParameterValue("@voucherno", strVno);

                FormCrViewer frm = new FormCrViewer();

                frm.crviewer.ViewerCore.ReportSource = cryRpt;
                frm.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }

Open in new window

Avatar of Mike McCracken
Mike McCracken

In a single print job with all the invoices included (1 report header and 1 Report footer) or do you want each invoice printed separately each having a report header and footer

For the first just add a second parameter and test for >= Start Invoice and <= End Invoice

For the second it would be a little more difficult.

Are the invoice numbers really like that?

If so you could pull the numeric portion out and loop through the code you have for each invoice
If they could be different then you could create a recordset of the desired invoice numbers and loop through it printing as you go.

mlmcc
Avatar of Murtaza Ginwala

ASKER

Hello mlmcc,

Each invoice has its separate header and footer. Also the actual invoice number will change every month
ex: "INV-MONTHYEAR001", for January it will be  INV-0118001, similarly for December INV-1218001.

But my main concern is to print on single click all the invoices within the range. How will i loop my voucher no, can you share me one sample code for the same?

Thank you!
DO you have the code to get the required invoice numbers from the database?
It seems you do since you provided a screenshot with the list.

It the code with the call to GetInvoiceRpt

Add code to walk through the dataset one record at a time
It will be something like this.  II am not a .net programmer)

RS.Movefirst
While NOT RS.EOF do
    GetInvoiceRpt("REPORTNAME",RS.InvoiceNumber)
    RS.MoveNext
End While Loop

Open in new window

This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.