用C#打印多页-来自VB6 [英] Print Multiple pages in C# - Comming from VB6

查看:55
本文介绍了用C#打印多页-来自VB6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是Visual Basic 6(VB6)开发人员大约10年了...
最后,我决定选择一种新语言...,然后选择Visual C#(现已在VS2010中使用).

我在VB6中的主要程序是使用Printer.CurrentX,Printer.CurrenY和Printer.Print ...来处理打印机,以发出发票.

但是现在在VC#中有所不同,主要是关于何时我们希望在一个文档中有多个页面(我知道HasMorePages标志...).

仅举一个例子,我如何在VB6中对发票进行标准编码

Hi everyone,

I am a Visual Basic 6 (VB6) developer for about 10 years...
Finally I have 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
            'Address and some other client data saved on tabCustomer
            Printer.CurrentX = 10
            Printer.CurrentY = 10 + newLine * fontHeight
            Printer.Print Trim(adoDet.Fields("Date") & "")
            Printer.CurrentX = 20
            Printer.CurrentY = 10 + newLine * fontHeight
            Printer.Print Trim(adoDet.Fields("Description") & "")
            Printer.CurrentX = 60
            Printer.CurrentY = 10 + newLine * fontHeight
            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
                  newLine = 0
               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
          Printer.NewPage
       End If
       
    Loop
    adoCust.Close
    Set adoCust = Nothing
    Set adoDet = Nothing
   End Sub


现在我的问题是:有了这种新的(至少对我来说)C#,最好的方法是什么?
我主要担心的是,我们需要退出printDoc_PrintPage(object sender,PrintPageEventArgs e)并使用标志HasMorePages = True 强制具有新页面,然后返回以继续进行发票打印.
我将在客户上释放ID,并保留详细信息,保留ID并取回,这是在打印时犯错误的一半.

感谢您的帮助.
最好的问候,
Antonio


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

推荐答案

您可以从MSDN ^ ].
You can get information on printing multiple pages from MSDN here[^].


这篇关于用C#打印多页-来自VB6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆