This example of printing crystal report in Desktop application
Dim DsPrint As New DataSet
//In DsPrint I have my data for printing in crystal reply. Assume that Record only One.
If (DsPrint.Tables(0).Rows.Count - 1) >= 0 Then
Dim ObjR As New CrystalDecisions.CrystalReports.Engine.ReportDocument
ObjR.FileName = "F:\Myproject\CrystalReceipt.rpt" // this is physical path of crystal report.
ObjR.ParameterFields.Item("Trans_ID").CurrentValues.AddValue(Int_TransID)
ObjR.ParameterFields.Item("Str_M").CurrentValues.AddValue(DsPrint.Tables(0).Rows(0).Item(5).ToString)
ObjR.ParameterFields.Item("Str_S").CurrentValues.AddValue(DsPrint.Tables(0).Rows(0).Item(0).ToString)
ObjR.ParameterFields.Item("Str_C").CurrentValues.AddValue(DsPrint.Tables(0).Rows(0).Item(2).ToString)
ObjR.ParameterFields.Item("Str_Con").CurrentValues.AddValue(DsPrint.Tables(0).Rows(0).Item(3).ToString)
ObjR.ParameterFields.Item("Str_Del").CurrentValues.AddValue(DsPrint.Tables(0).Rows(0).Item(1).ToString)
ObjR.ParameterFields.Item("Str_Price").CurrentValues.AddValue(DsPrint.Tables(0).Rows(0).Item(4).ToString)
ObjR.ParameterFields.Item("Str_Status").CurrentValues.AddValue("Deducted")
ObjR.PrintOptions.PrinterName = str_ReceiptPrinter
ObjR.PrintOptions.PaperOrientation = CrystalDecisions.Shared.PaperOrientation.Landscape // You can change as per your need.
ObjR.PrintToPrinter(1, False, 1, 1)
End If
No comments:
Post a Comment