我想使用 VB.NET 2010 使用存折打印机(Epson PLQ 20)在存折(用于记录银行交易的纸质书)上打印。
我当前的mysql表结构是,
1. tblLoanRegistry(LoanID pk, EMPNumber, Date, Amount, NoOfInstallments, Teller)
2. tblLoanAccount(ID pk, LoanID fk, Date, Payment, Interest, Total, Auto bool, Installment int, teller)
我的问题是:
- 如何检测打印的最后一行?
- 如何在书的正确位置(正确行)打印第一行未打印的行。
我决定在上面提到的每个表中添加一个字段“打印”(布尔值)。打印与否。我可以在 vb.net 中使用同一台打印机打印文本、数字等(例如:首页上的帐户持有人详细信息)。但是我在打印交易时遇到了上述问题。非常感谢您的帮助/意见。
更多信息: 实际上,我为非营利组织开发了一个使用 php 和 mysql 的基于 Web 的帐户处理系统,作为我的学位项目。现在他们想像我之前描述的那样在存折上打印交易。
因此,我正在使用 VB.NET 创建一个应用程序(我对 VB.NET 完全陌生。但在 vb6 方面有经验),而我正在学习它。我设法进行了简单的打印,但这是不同的。
我没有解决上述两个问题的好主意。
更新: 我以不同的(可能是不好的)方式做到了。打印按钮的单击事件。
    Dim sqlLoan As String
    conn = New MySqlConnection(cnString)
    sqlLoan = "SELECT tblLoanAccount.Date,if(Installment = 0, 'Interest', concat('Installment : ', Installment)) as Description, tblLoanAccount.Payment, tblLoanAccount.Interest, " &
        " tblLoanAccount.Total, tblLoanAccount.Auto, tblLoanAccount.Installment FROM tblLoanAccount join tblloanRegistry on  tblloanRegistry.LoanID = tblLoanAccount.LoanID " &
        " where(tblloanRegistry.EMPNumber = " & cmbEMPN.Text & " And tblLoanAccount.LoanID = tblLoanRegistry.LoanID) AND tblLoanAccount.Total <> 0 ORDER BY tblLoanAccount.ID"
    Using conn As New MySqlConnection(cnString)
        Using cmd As New MySqlCommand(sqlLoan, conn)
            conn.Open()
            Using myReader As MySqlDataReader = cmd.ExecuteReader()
                Using writer As StreamWriter = New StreamWriter("c:\file.txt")
                    While myReader.Read()
                        writer.WriteLine("{0}, {1}, {2}, {3}, {4}", myReader.Item(0), myReader.Item(1), myReader.Item(2), myReader.Item(3), myReader.Item(4))
                    End While
                End Using
                Call Printing()
            End Using
        End Using
    End Using
    ' Print the file. 
Public Sub Printing()
    Try
        streamToPrint = New StreamReader(("c:\file.txt"))
        Try
            printFont = New Font("Arial", 10)
            Dim pd As New PrintDocument()
            AddHandler pd.PrintPage, AddressOf pd_PrintPage
            ' Print the document.
            pd.Print()
        Finally
            streamToPrint.Close()
        End Try
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub 'Printing
其他代码为 msdn PrintDocument Class。