- 分享
- 0
- 人气
- 0
- 主题
- 39
- 帖子
- 7914
- UID
- 100604
- 积分
- 3143
- 阅读权限
- 21
- 注册时间
- 2007-9-21
- 最后登录
- 2018-1-12
- 在线时间
- 4526 小时
|
tomiverson 发表于 2013-7-18 12:07 PM
可以把你中error的code放出来看看吗?
Imports System.IO
Imports System.Data.OleDb
Public Class frmPrintCash
Dim ListDetails As ListViewItem
Dim countReceipt As Integer
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;data source=SS Snow.accdb")
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim printFont As New Font("Cambria", 17, FontStyle.Regular)
Dim headingFont As New Font("Cambria", 18, FontStyle.Bold)
Dim sngLineHeight As Single = printFont.GetHeight + 2
Dim sngXLocation As Single = e.MarginBounds.Left
Dim sngYLocation As Single = e.MarginBounds.Top
'set up header
e.Graphics.DrawString("===============================================", headingFont, Brushes.Black, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString(vbTab & vbTab & Space(3) & "SS Snow Furniture Sdn Bhd" & vbTab & vbTab, headingFont, Brushes.DarkSlateBlue, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString(vbTab & vbTab & vbTab & Space(6) & "Receipt" & vbTab & vbTab, headingFont, Brushes.DarkSlateBlue, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString("Product Name" & Space(57) & Space(9) & "Amount(RM)", headingFont, Brushes.Purple, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
' set up detail
For i As Integer = 0 To lvwProduct.Items.Count - 1
e.Graphics.DrawString(lvwProduct.Items(i).Text & vbTab & vbTab & lvwProduct.Items(i).SubItems(1).Text & vbTab & lvwProduct.Items(i).SubItems(2).Text, printFont, Brushes.DimGray, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
Next
''If txtProductName.TextLength > 28 Then
'' e.Graphics.DrawString(txtProductName.Text & vbTab & vbTab & lblWarrantyFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
'' sngYLocation += sngLineHeight
''ElseIf txtProductName.TextLength > 18 And txtProductName.TextLength < 28 Then
'' e.Graphics.DrawString(txtProductName.Text & vbTab & vbTab & vbTab & Space(15) & lblWarrantyFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
'' sngYLocation += sngLineHeight
''Else
'' e.Graphics.DrawString(txtProductName.Text & vbTab & vbTab & vbTab & vbTab & vbTab & Space(6) & lblWarrantyFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
'' sngYLocation += sngLineHeight
''End If
e.Graphics.DrawString("Delivery Fee" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(8) & lblDeliveryFee.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString(vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & Space(4) & "----------", printFont, Brushes.Crimson, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Total Amount" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(8) & lblTotal.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Amount Payment" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(6) & "(" & lblPaid.Text & ")", printFont, Brushes.Crimson, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString(vbTab & vbTab & vbTab & vbTab & vbTab & vbTab & Space(4) & "----------", printFont, Brushes.Crimson, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("Balance" & vbTab & vbTab & vbTab & vbTab & vbTab & Space(24) & lblBalance.Text, printFont, Brushes.Crimson, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
sngYLocation += sngLineHeight
e.Graphics.DrawString(vbTab & vbTab & Space(4) & "**Have a Nice Day**" & vbTab & vbTab, headingFont, Brushes.LightCoral, sngXLocation, sngYLocation)
sngYLocation += sngLineHeight
e.Graphics.DrawString("===============================================", headingFont, Brushes.Black, sngXLocation, sngYLocation)
End Sub
Private Sub frmPrintCash_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SS_SnowDataSet.Receipt_Item' table. You can move, or remove it, as needed.
Me.Receipt_ItemTableAdapter.Fill(Me.SS_SnowDataSet.Receipt_Item)
'TODO: This line of code loads data into the 'SS_SnowDataSet.Receipt' table. You can move, or remove it, as needed.
Me.ReceiptTableAdapter.Fill(Me.SS_SnowDataSet.Receipt)
'Dim ReceiptID As StreamReader
'ReceiptID = New StreamReader("ReceiptNo.txt")
'Do Until ReceiptID.EndOfStream
' ReceiptID.ReadLine()
' countReceipt = countReceipt + 1
'Loop
'txtReceiptNo.Text = "RE" & countReceipt.ToString("0000")
'ReceiptID.Close()
' txtReceiptNo.Text = frmSumOrderCash.txtReceiptNo.Text
End Sub
Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
With PrintPreviewDialog1
.Document = PrintDocument1
.ShowDialog()
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'con.Open()
'' For i As Integer = 0 To lvwProduct.Items.Count - 1
'Dim ReceiptItemNo As OleDbCommand = New OleDbCommand("SELECT * FROM [Receipt Item] WHERE ReceiptID = '" & txtReceiptNo.Text & "'", con)
'Dim ReceiptItemEr As OleDbDataReader = ReceiptItemNo.ExecuteReader()
'Dim ReceiptNo As OleDbCommand = New OleDbCommand("SELECT * FROM [Receipt] WHERE ReceiptID = '" & txtReceiptNo.Text & "'", con)
'Dim ReceiptER As OleDbDataReader = ReceiptNo.ExecuteReader()
'While ReceiptItemEr.Read()
' ListDetails = lvwProduct.Items.Add(ReceiptItemEr("ProName"))
' ListDetails.SubItems.Add(ReceiptItemEr("ProQty"))
' ListDetails.SubItems.Add(ReceiptItemEr("UnitPrice"))
'End While
'While ReceiptER.Read()
' lblTotal.Text = ReceiptER("ReceiptAmount")
' lblDiscount.Text = ReceiptER("Discount")
' lblDeliveryFee.Text = ReceiptER("DeliveryFee")
' lblAmount.Text = lblTotal.Text - lblDiscount.Text + lblDeliveryFee.Text
' lblPaid.Text = frmSumOrderCash.lblPaid.Text
' lblBalance.Text = frmSumOrderCash.lblBalance.Text
'End While
'' Next
'con.Close()
For x As Integer = 0 To SS_SnowDataSet.Receipt_Item.Rows.Count - 1
If txtReceiptNo.Text = SS_SnowDataSet.Receipt_Item.Rows(x).Item(0) Then
ListDetails = lvwProduct.Items.Add(SS_SnowDataSet.Receipt_Item(x).Item(2))
ListDetails.SubItems.Add(SS_SnowDataSet.Receipt_Item(x).Item(3))
ListDetails.SubItems.Add(SS_SnowDataSet.Receipt_Item(x).Item(4))
End If
Next x
For w As Integer = 0 To SS_SnowDataSet.Receipt.Rows.Count - 1
If txtReceiptNo.Text = SS_SnowDataSet.Receipt.Rows(w).Item(0) Then
lblAmount.Text = SS_SnowDataSet.Receipt.Rows(w).Item(1)
lblDiscount.Text = SS_SnowDataSet.Receipt.Rows(w).Item(2)
lblDeliveryFee.Text = SS_SnowDataSet.Receipt.Rows(w).Item(3)
lblTotal.Text = SS_SnowDataSet.Receipt.Rows(w).Item(4)
lblPaid.Text = SS_SnowDataSet.Receipt.Rows(w).Item(5)
lblBalance.Text = SS_SnowDataSet.Receipt.Rows(w).Item(6)
End If
Next w
End Sub
Private Sub ReceiptBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.ReceiptBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.SS_SnowDataSet)
End Sub
End Class |
|