Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. Private print_document As PrintDocument
  2. Private FIRST_TO_PRINT As String = "CHEQUE"
  3. Private fontsize As Integer = 12
  4. Private _ID As Integer = 0
  5. Private CHEQUE_DATE As Date
  6. Private CLIENT_NAME As String
  7. Private CLIENT_NAME_ON_CHEQUE As String
  8. Private AMOUNT As Decimal
  9. Private AMOUNT_IN_WORDS As String
  10.  
  11. Public Sub New(ID As Integer)
  12. _ID = ID
  13. End Sub
  14.  
  15. Public Function PreparePrintDocument() As PrintDocument
  16. ' Make the PrintDocument object.
  17. print_document = New PrintDocument
  18.  
  19.  
  20.  
  21.  
  22. print_document.DefaultPageSettings.PaperSize = New PaperSize("Custom", 336, 768)
  23.  
  24. 'print_document.OriginAtMargins = True
  25. 'print_document.DefaultPageSettings.Margins.Left = 200
  26. 'print_document.DefaultPageSettings.Margins.Right = 10
  27. 'print_document.DefaultPageSettings.Margins.Bottom = 10
  28. 'print_document.DefaultPageSettings.Margins.Top = 200
  29. AddHandler print_document.BeginPrint, AddressOf Print_BeginPrint
  30. ' Install the PrintPage event handler.
  31. AddHandler print_document.PrintPage, AddressOf Print_PrintPage
  32.  
  33. ' Return the object.
  34. Return print_document
  35. End Function
  36. Protected Sub Print_BeginPrint(sender As Object, e As PrintEventArgs)
  37.  
  38. GetVoucherDetails()
  39. End Sub
  40.  
  41. Private Sub GetVoucherDetails()
  42. Dim objVOUCHER_BLL As VOUCHER_BLL
  43. Try
  44. objVOUCHER_BLL = New VOUCHER_BLL
  45. Dim temps As VOUCHERDataTable = objVOUCHER_BLL.GetVoucherByID(_ID)
  46. If temps.Count > 0 Then
  47. Dim temp As VOUCHERRow = temps(0)
  48. CHEQUE_DATE = temp.CHEQUE_DATE
  49. CLIENT_NAME = temp.CLIENT_NAME
  50. CLIENT_NAME_ON_CHEQUE = temp.CLIENT_NAME_ON_CHEQUE
  51. AMOUNT = temp.AMOUNT
  52. AMOUNT_IN_WORDS = numToWords.AmtInWord(temp.AMOUNT)
  53. End If
  54. Catch ex As Exception
  55. Finally
  56. objVOUCHER_BLL = Nothing
  57. End Try
  58. End Sub
  59.  
  60. ' Print the next page.
  61. Private Sub Print_PrintPage(ByVal sender As Object, ByVal e _
  62. As System.Drawing.Printing.PrintPageEventArgs)
  63.  
  64.  
  65. Dim our_brush As Brush = Brushes.Black
  66. Dim font As New Font("Verdana", fontsize)
  67. If FIRST_TO_PRINT = "CHEQUE" Then
  68.  
  69.  
  70. e.PageSettings.PaperSize = New PaperSize("Custom", 336, 768)
  71. e.Graphics.ResetTransform()
  72. e.Graphics.TranslateTransform(306, 580)
  73. e.Graphics.RotateTransform(90)
  74. e.Graphics.DrawString(CHEQUE_DATE.ToString("dd MM yyyy"), font, our_brush, New Point(0, 0))
  75.  
  76. e.Graphics.ResetTransform()
  77. e.Graphics.TranslateTransform(262, 20)
  78. e.Graphics.RotateTransform(90)
  79. e.Graphics.DrawString(CLIENT_NAME_ON_CHEQUE, font, our_brush, New Point(70, 0))
  80.  
  81. e.Graphics.ResetTransform()
  82. e.Graphics.TranslateTransform(232, 140)
  83. e.Graphics.RotateTransform(90)
  84. e.Graphics.DrawString(AMOUNT_IN_WORDS.Replace("Rupees ", String.Empty).ToUpper, font, our_brush, New Point(0, 0))
  85.  
  86. e.Graphics.ResetTransform()
  87. e.Graphics.TranslateTransform(206, 600)
  88. e.Graphics.RotateTransform(90)
  89. e.Graphics.DrawString(AMOUNT.ToString("F2") & " /-", font, our_brush, New Point(0, 0))
  90.  
  91. ' e.HasMorePages = True
  92. ' e.Graphics.ResetTransform()
  93. ' FIRST_TO_PRINT = "VOUCHER"
  94. 'Else
  95. ' e.PageSettings.PaperSize = New PaperSize("Custom", 612, 792)
  96.  
  97. ' e.Graphics.DrawString("VOUCHER", font, our_brush, New Point(200, 200))
  98. ' FIRST_TO_PRINT = "CHEQUE"
  99. e.Graphics.ResetTransform()
  100. e.HasMorePages = False
  101. End If
  102.  
  103. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement