我对我的项目中的更新和打印有疑问。
首先,我使用ExecuteScalar
更新数据并从数据库中获取自动生成号
然后我将发票号码更新到另一张发票编号系统表
TicketNumberUpdate()
lbl_Status.Text = "Updating Ticket Number..."
Application.DoEvents()
System.Threading.Thread.Sleep(200)
然后根据我的发票编号
等待过滤 PrintFunc(" WHERE dbo.tbl_Tickets.TicketNo='" & txtTicket.Text & "' AND dbo.tbl_Tickets.Ticket_Type='" & cboTicketType.Text.Trim & "'")
lbl_Status.Text = "Loading Ticket ..."
Application.DoEvents()
System.Threading.Thread.Sleep(200)
并将该发票详细信息加载到Richtextbox
rtb_TicketFormat.Rtf = rtb_TicketFormat.Rtf.Replace("Duplicate.png", "Original.png")
Dim myFileName As String = IO.Path.Combine(IO.Path.GetTempPath, "_.html")
rtb_TicketFormat.SaveFile(myFileName, RichTextBoxStreamType.PlainText)
lbl_Status.Text = "Printing Ticket ..."
Application.DoEvents()
System.Threading.Thread.Sleep(200)
并等待以html格式保存该发票后,我呼吁PrintTktz
打印该文件
Private Sub PrintTktz()
Dim webBrowserForPrinting As New WebBrowser()
AddHandler webBrowserForPrinting.DocumentCompleted, New _
WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocumentz)
webBrowserForPrinting.Url = New Uri(IO.Path.GetTempPath & "_.html")
End Sub
Private Sub PrintDocumentz(ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs)
Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser)
webBrowserForPrinting.ScriptErrorsSuppressed = True
webBrowserForPrinting.Print()
webBrowserForPrinting.Dispose()
End Sub
问题是,有时它会打印上一个发票,而不是当前发票是否会挂起此代码?我正在尝试不同的方法来做到这一点。