Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在VB.NET 2010中打印_Vb.net_Printing - Fatal编程技术网

在VB.NET 2010中打印

在VB.NET 2010中打印,vb.net,printing,Vb.net,Printing,我想使用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, t

我想使用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)
我的问题是:

  • 如何检测打印的最后一行
  • 如何在书的正确位置(正确行)打印未打印的第一行 我决定在上面提到的每个表中添加一个字段“Printed”(布尔值)。要打印还是不打印。我可以在vb.net中使用相同的打印机打印文本、数字等(例如:首页上的帐户持有人详细信息)。但我在打印交易时面临上述问题。非常感谢你的帮助/意见

    更多信息: 实际上,作为我的学位项目,我为一个非营利组织开发了一个基于web的帐户处理系统,使用php和mysql。现在他们想要像我前面描述的那样在存折上打印交易

    因此,我在学习VB.NET的同时,正在使用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
    
    Dim sqlLoan作为字符串
    conn=新的MySqlConnection(cnString)
    sqlLoan=“选择TBLLOANCOUNT.Date,如果(分期=0,‘利息’,concat(‘分期:’,分期))作为说明,TBLLOANCOUNT.Payment,TBLLOANCOUNT.利息,”&
    TBLLOANCOUNT.Total、TBLLOANCOUNT.Auto、TBLLOANCOUNT.TBLLOANCOUNT的分期付款从TBLLOANCOUNT加入TBLLOANCREGISTRY上的TBLLOANCOUNT.LoanID=TBLLOANCOUNT.LoanID&
    “其中(tblloanRegistry.EMPNumber=“&cmbEMPN.Text&”和tblLoanAccount.LoanID=tblloanRegistry.LoanID)和tblLoanAccount.Total 0按tblLoanAccount.ID排序”
    将conn用作新的MySqlConnection(cnString)
    使用cmd作为新的MySqlCommand(康涅狄格州sqlLoan)
    康涅狄格州公开赛
    将myReader用作MySqlDataReader=cmd.ExecuteReader()
    将writer用作StreamWriter=newstreamwriter(“c:\file.txt”)
    而myReader.Read()
    writer.WriteLine(“{0},{1},{2},{3},{4}”,myReader.Item(0),myReader.Item(1),myReader.Item(2),myReader.Item(3),myReader.Item(4))
    结束时
    终端使用
    呼叫打印()
    终端使用
    终端使用
    终端使用
    '打印文件。
    公共子打印()
    尝试
    streamToPrint=新的StreamReader(((“c:\file.txt”))
    尝试
    printFont=新字体(“Arial”,10)
    Dim pd作为新的打印文档()
    AddHandler pd.PrintPage,pd_PrintPage的地址
    '打印文档。
    pd.Print()
    最后
    streamToPrint.Close()
    结束尝试
    特例
    MessageBox.Show(例如Message)
    结束尝试
    “结束子”打印
    

    其他代码如msdn。

    在这个问题中有很多未知数。例如,当您将某个项目标记为已打印时,您是希望对其进行全局标记(针对所有应用程序、所有事务和所有时间),还是仅在有限的上下文(特定应用程序、事务或时间范围)内进行标记

    事务是在单个.NET线程中启动和完成的,还是此应用程序是多线程的,还是跨多个独立执行的?您是否需要打印在物理纸张之外的项目记录

    假设您希望仅在特定事务中打印某个项目的记录,那么您可能希望创建第三个表,称为tblPrintTransaction,其中包含主键或其他标识符列以及所需的任何其他列(事务开始日期、结束日期、用户ID、上下文信息等)。启动应用程序时,在此表中创建新行并获取行ID

    现在,创建第四个表,称为tblPrintTransactionArtifact,至少有两列。一列是标识事务的外键(来自tblPrintTransaction表),一列或多列用于标识已打印的项目。例如,您的表可以包含两列来标识打印的项目:一列指定“注册表”或“帐户”,另一列指定项目的ID

    当然,所有这些信息都可以在应用程序本身中创建和维护(使用变量等),但将它们存储在表中意味着它们将在应用程序执行之后继续存在,从而为您提供一个永久记录。我建议您在应用程序中跟踪打印页面上的当前“行”,因为我认为这在您的数据库中没有什么用处。

    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
    
    conn=newmysqlconnection(cnString)
    sqlLoan=“选择TBLLOANCOUNT.Date,如果(分期=0,‘利息’,concat(‘分期:’,分期))作为说明,TBLLOANCOUNT.Payment,TBLLOANCOUNT.利息,”&
    TBLLOANCOUNT.Total、TBLLOANCOUNT.Auto、TBLLOANCOUNT.TBLLOANCOUNT的分期付款从TBLLOANCOUNT加入TBLLOANCREGISTRY上的TBLLOANCOUNT.LoanID=TBLLOANCOUNT.LoanID&
    “其中(tblloanRegistry.EMPNumber=“&cmbEMPN.Text&”和tblLoanAccount.LoanID=tblloanRegistry.LoanID)和tblLoanAccount.Total 0按tblLoanAccount.ID排序”
    将conn用作新的MySqlConnection(cnString)
    使用cmd作为新的MySqlCommand(康涅狄格州sqlLoan)
    康涅狄格州公开赛
    将myReader用作MySqlDataReader=cmd.ExecuteReader()
    将writer用作StreamWriter=newstreamwriter(“c:\file.txt”)
    而myReader.Read()
    writer.WriteLine(“{0},{1},{2},{3},{4}”,myReader.Item(0),myReader.Item(1),myReader.Item(2),myReader.Item(3),myReader.Item(4))