I am devolving a project for a General Store.
There I need to print the bill as and when it is saved to my database.
I am using Crystal Report. But I didn't make it visible. It is printing directly.
My Code is
{
after saving.....
SqlDataAdapter da3 = new SqlDataAdapter("select * from SalesDetails where BillNo='" + textBox1.Text + "'", con);
DataSet ds3 = new DataSet();
da3.Fill(ds3, "SalesDetails");
rptSalesbill abc = new rptSalesbill();
abc.SetDataSource(ds3.Tables[0]);
System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument();
int i;
int rawKind = 0;
for (i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++)
{
if (printDoc.PrinterSettings.PaperSizes[i].PaperName == "4x1")
{
rawKind = (int)GetField(printDoc.PrinterSettings.PaperSizes[i], "kind");
}
}
abc.PrintOptions.PaperSize = (CrystalDecisions.Shared.PaperSize)rawKind;
abc.PrintToPrinter(1, true, 0, 0);
}
private object GetField(Object obj, String fieldName)
{
System.Reflection.FieldInfo fi = obj.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
return fi.GetValue(obj);
}
But the bill is printing slowly it is taking around 6 secs to print bill.
How can I decrease the time to print.
6 secs is too much for the general store because they have lots of customer in a queue.
Not for the first time! all the time. First time it is taking around 12 secs.
Please please help me I am in a big problem.