Advertisement
Advertisement
| 06.16.2008 at 01:50PM PDT, ID: 23489608 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: |
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PrintPreviewDialog1.Document = PrintDocument1
Me.CheckNumber = 1
Dim result As DialogResult = PrintPreviewDialog1.ShowDialog()
' If the result is OK then print the document.
If (result = Windows.Forms.DialogResult.OK) Then
'PrintDocument1.Print()
End If
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Initialize the font to be used for printing.
Dim font As New Font("Microsoft Sans Serif", 12)
Dim intLVUbound As Integer
Dim intLVUboundC As Integer
Dim intLVIdx As Integer
Dim intLVIdxC As Integer
Dim ItemNo As String
Dim ItemNo2 As String
Dim x1, x2, x3, x4, x5, x6, x7, x8, x9 As Integer
Dim y1, y2, y3, y4, y5, y6, y7, y8, y9 As Integer
Dim X As Integer = 1
Dim Y As Integer = 0
Dim Col1 As String = ""
Dim Col1x As String = ""
Dim Col2 As String = ""
Dim Col2Parsed As String = ""
Dim decAmount As Decimal
Dim decAmount2 As Decimal
Dim strAmount As String = Nothing
Dim CoName As String = "The Consignment Shop"
Dim Address1 As String = "6906 Camp Bowie Blvd."
Dim Address2 As String = "Suite 132"
Dim CityStateZip As String = "Fort Worth, TX. 76116"
Dim ForLine As String = "John Doe Consignment"
Dim Now As DateTime = DateTime.Now
Dim ShortDate As String = Now.ToString("d")
Dim MAX_PAGE_COUNT As Integer = 2
intLVUboundC = lvwConsignors.Items.Count - 1 'Get number of Consignors
intLVUbound = lvwItems.Items.Count - 1 'Get number of Items for this consignor
'Define the Company Header Position
x1 = 35 : y1 = 30 ' Company Name
x2 = 35 : y2 = 45 ' Address 1
x3 = 35 : y3 = 60 ' Address 2
x4 = 35 : y4 = 75 ' City/State/Zip
x5 = 678 : y5 = 68 ' Date
x6 = 110 : y6 = 120 'John Doe y is up and down, x is left and right
x7 = 675 : y7 = 120 'Amount Box
x8 = 42 : y8 = 150 'Money String.
x9 = 90 : y9 = 185 'For Line
'Start the Loop for each Consignor
For intLVIdxC = 0 To intLVUboundC - 1
'write the Consignors Info on the Check
e.Graphics.DrawString(CoName, font, Brushes.Black, x1, y1)
e.Graphics.DrawString(Address1, font, Brushes.Black, x2, y2)
e.Graphics.DrawString(Address2, font, Brushes.Black, x3, y3)
e.Graphics.DrawString(CityStateZip, font, Brushes.Black, x4, y4)
'Get the detail for the check and add up the amounts
For intLVIdx = 0 To intLVUbound - 1
Col1 = lvwConsignors.Items(intLVIdxC).SubItems(1).Text 'Get the Item
Col1x = lvwConsignors.Items(intLVIdxC).Tag 'Get the Consignor ID
ItemNo = lvwItems.Items(intLVIdx).Tag 'Get the Item Number
ItemNo2 = lvwItems.Items(intLVIdx).Tag 'Get the Item Number
MarkAsPaid(ItemNo) 'Mark This Item As Paid
Col2 = lvwItems.Items(intLVIdx).SubItems(3).Text
Col2Parsed = Col2.Substring(1)
'Process the text String for Dollar Amount
'convert the text into a decimal
decAmount = Convert.ToDecimal(Col2Parsed)
'set the number of decimal places to 2
decAmount = Decimal.Round(decAmount, 2)
'Add the Amounts
decAmount2 = decAmount2 + decAmount
strAmount = DecimalToText.ConvertDecimalToText(decAmount2)
Call AddToLog(ItemNo, Col2Parsed, ItemNo2, Col1x) 'Add This Item To the Transaction Log
Next ' Next Item No.
'For X = X To 3 'Start Check Counter - 3 Checks per page
'Process the text String for Dollar Amount
e.Graphics.DrawString(ShortDate, font, Brushes.Black, x5, y5)
e.Graphics.DrawString(Col1, font, Brushes.Black, x6, y6)
e.Graphics.DrawString(decAmount2, font, Brushes.Black, x7, y7)
e.Graphics.DrawString(strAmount, font, Brushes.Black, x8, y8)
e.Graphics.DrawString(ForLine, font, Brushes.Black, x9, y9)
e.Graphics.DrawString("* * * * * * * * * * * * * * * * * * * * * * * *", font, Brushes.Black, x8 + 360, y8 + 4)
'Next X
'Change print position on page
y1 = y1 + 350
y2 = y2 + 350
y3 = y3 + 350
y4 = y4 + 350
y5 = y5 + 350
y6 = y6 + 350
y7 = y7 + 350
y8 = y8 + 350
y9 = y9 + 350
Call UpdateBalances(decAmount2, Col1x)
Next ' Next Consignor
If Me.CheckNumber = MAX_PAGE_COUNT Then
'We have printed all the pages.
e.HasMorePages = False
'Reset the page number because if this is a preview and the user presses
'the Print button the printing routine will be executed a second time.
Me.CheckNumber = 1
Else
'There are more pages to print.
e.HasMorePages = True
'Increment the page number.
Me.CheckNumber += 1
End If
End Sub
|