Printing C # Winforms Invoices

I wrote an application in C # and now I want to print its contents in the form of an invoice, as shown in the figure. I want to print customer data only once, but the tasks that he asked to perform on his car, shown in the datagrid view, should be in the form of a list with labor and general labor at the end of the invoice. some people suggested using crystal reports that I never used for them, looking for a simpler solution reducing it, how can we print the required values ​​from the form alt text

+6
c # printing invoice
source share
3 answers

The easiest and fastest solution is to use the PowerPack PrintForm Visual Basic control (you can also use it in C # projects).

http://msdn.microsoft.com/en-us/vbasic/bb735936.aspx

Just drag the control onto your form and then from the code call

printForm1.Print(); 

This will print everything on the form, so just create a report on the form, then call this code, and you're done.

+6
source share

The last time I needed to print several fields from a C # form, I just created a bitmap image using the "Bitmap" and "Graphics" objects and used the "PrintDocument" to print it. A.

The layout of the printed report is executed in the code by specifying the coordinates of the printed elements. It is cheap and dirty, but it works.

+3
source share

You can use the local SSRS report (extension .rdlc). In the "Reporting" section, to create a report, there must be a new template. The report is displayed in Winforms using the Viewer Report control (the control can also be used in a WPF application using WindowsFormsHost). The only drawback is the necessary dependency that must be installed with your application. Here is a redistributable package for viewing 2010 reports.

A plus - the report can be easily placed in the SSRS instance if / when it needs to be viewed from the browser. The viewer can also display reports locally hosted on an SSRS instance.

There are many guides available on the Internet for using the report viewer, depending on the data source that will be used to populate the report. The following example uses a generic list as a data source. The labels in the new row of ReportDataSource should be the same as the name of the dataset in the report definition. The properties of the shared object must also match the column names of the dataset.

  public ReportViewer(IEnumerable<UnprocessedLabel> labels) { InitializeComponent(); var reportViewer = new Microsoft.Reporting.WinForms.ReportViewer { ProcessingMode = ProcessingMode.Local }; reportViewer.LocalReport.ReportPath = System.IO.Path.GetDirectoryName(Application.ResourceAssembly.Location) + "\\UnprocessedPalletLabel.rdlc"; var ds = new ReportDataSource("labels", labels); reportViewer.LocalReport.DataSources.Add(ds); reportViewer.RefreshReport(); } 
+3
source share

All Articles