I am doing billing application, so I need to print a bill without Preview of Report. And, I don't like selecting a printer in a printer dialog popup. It should select the default printer.
'PrintToPrinter' is not working for my requirement. I need to send latest created BillID as parameter to get latest details.
If I don't use 'PrintToPrinter
' syntax, the Printer dialog popup screen is coming with the "select printer" dialog.
Please guide me in solving this issue.
For your reference, I am attaching a snippet of my code:
Report_Path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + "\\Reports\\StandardBill.rpt";
ReportDocument rd = new ReportDocument();
rd.Load(Report_Path);
rd.SetDatabaseLogon(AccessingData.DBUserName, AccessingData.DBPassword);
ParameterFields paramFields = new ParameterFields();
ParameterField BillID = new ParameterField();
ParameterDiscreteValue discreteVal_BillID = new ParameterDiscreteValue();
BillID.ParameterFieldName = "BillNo";
discreteVal_BillID.Value = Convert.ToInt32(Bill_id);
BillID.CurrentValues.Add(discreteVal_BillID);
ParameterField CType = new ParameterField();
ParameterDiscreteValue discreteVal_CType = new ParameterDiscreteValue();
CType.ParameterFieldName = "ClientType";
discreteVal_CType.Value = ClientType;
CType.CurrentValues.Add(discreteVal_CType);
// Add parameter to the parameter fields collection.
paramFields.Add(BillID);
paramFields.Add(CType);
CRViewer1.ParameterFieldInfo = paramFields;
CRViewer1.ReportSource = rd;
CRViewer1.PrintReport();
rd.Close();
rd.Dispose();