Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
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
C#
{
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.
Posted
Updated 18-Aug-12 7:54am
v2
Comments
Sergey Alexandrovich Kryukov 18-Aug-12 14:06pm    
Yes, something wrong with printing, maybe even hardware. You might need to simplify down, say, use some primitive POS printer. However, I see a number of decent POS apparently based on Windows and very rich applications, working very fast despite of printing in graphics, line going fast...
--SA
Kenneth Haugland 18-Aug-12 18:35pm    
From OP:
Thanks for your quick reply. but I am not the owner of the general store. They are using TVS justbill printer. But that doesn't matter, to send the instruction to the printer it is taking 6 secs, afterwards I don't have to taking care of. I want to decrease that 6 secs.
[no name] 19-Aug-12 10:47am    
What Kenneth?
[no name] 18-Aug-12 14:19pm    
Thanks for your quick reply.
but
I am not the owner of the general store.
They are using TVS justbill printer.
But that doesn't matter, to send the instruction to the printer it is taking 6 secs, afterwards I don't have to taking care of.
I want to decrease that 6 secs.
Sergey Alexandrovich Kryukov 18-Aug-12 22:24pm    
Yes, I see... do you have to use Report based approach at all. You could format and print data directly, where all the code in your hands. Maybe reports are not speed-savvy in principle, one of its main goal is to reduce the labor in developers; and many of such developers are not so qualified; so doing it by yourself could be a solution, I don't know exactly. Did you think about it? Everything should be prototypes and evaluated, speed too...
--SA

1 solution

SSRS reports are much faster, when compared to Crystal reports.
I think you should go for it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900