Hi everyone
I'm a Visual Basic 6 (VB6) developer for about 10 years...
Finally I've decided to go for a new language… and choose Visual C# (now on VS2010).
My main programs in VB6 were working with printers using the Printer.CurrentX, Printer.CurrenY and Printer.Print… for invoice emission.
But now in VC# is a little different, mainly regarding when we want to have more than one page in one document (I know about the HasMorePages flag…).
Just to give you a example how is my standard coding in VB6 regarding invoices:
Private sub printInvoice()
Dim adoCust As ADODB.Recordset
Dim adoDet As ADODB.Recordset
Dim newLine As Integer
Dim fontHeight As Double
Set adoCust = New ADODB.Recordset
Set adoDet = New ADODB.Recordset
fontHeight = 5
adoCust.Open "Select * from tabCustomer order by idCustomer", adoCon, adOpenForwardOnly, adLockReadOnly
Do Until adoCust.EOF
'Address and some other client data saved on tabCustomer
Printer.CurrentX = 10
Printer.CurrentY = 10
Printer.Print Trim(adoCust.Fields("CustName") & "")
'...
'... some more adoCust fields....
'now lets go for the invoice details
adoDet.Open "select * from tabInvoiceDetails where idCustommer =" & Val(adoCust.Fields("idCustomer")) & " order by idDetail", adoCon, adOpenForwardOnly, adLockReadOnly
newLine = 0
Do Until adoDet.EOF
'details...
Printer.CurrentY = 10 + newLine * fontHeight
Printer.Print Trim(adoDet.Fields("Date") & "")
Printer.CurrentX = 20
Printer.Print Trim(adoDet.Fields("Description") & "")
Printer.CurrentX = 60
Printer.Print Trim(adoDet.Fields("Value") & "")
'... some more adoDet fields....
newLine = newLine + 1
adoDet.MoveNext
If Not adoDet.EOF Then
If newLine = 50 Then
'we put over here the second page
Printer.NewPage
End If 'newLine = 50 Then
End If
Loop
adoDet.Close
adoCust.MoveNext
If adoCust.EOF Then
'we finished the print document with n pages
Printer.EndDoc
Else
'we go for a new page because there are more invoices
adoCust.Close
Set adoCust = Nothing
Set adoDet = Nothing
End Sub
Now my question is: with this new (at least to me) C# how is the best way to do it? My main concern is that we need to exit the printDoc_PrintPage(object sender, PrintPageEventArgs e) and have the flag HasMorePages = True to force to have a new page and then get back to continue the invoice printing…I will loose the ID on the Customer and also for the details… keep ids and get back… this is half way to make a mistake on printing…
Thanks for your help.
Best regards,
Antonio