Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.99 KB | None | 0 0
  1. Private Sub prtReceipt_PrintPage(sender As Object, e As Printing.PrintPageEventArgs) Handles prtReceipt.PrintPage
  2. Dim x, y, FontHeight As Integer
  3. Dim HeadingFont As New Font("Britannic Bold", 16, FontStyle.Bold)
  4. Dim SubHeadingFont As New Font("Calibri (body)", 13, FontStyle.Regular)
  5. Dim MyFont As New Font("Calibri (body)", 10, FontStyle.Regular)
  6. Dim ListFont As New Font("Courier New", 10, FontStyle.Regular)
  7. Dim StockListFormat As String = "{0,-10}{1,-20}{2,-10}"
  8. Dim Printline As String
  9.  
  10. FontHeight = HeadingFont.GetHeight(e.Graphics)
  11.  
  12. x = 5
  13. y = 70
  14. e.Graphics.DrawString("Central Games Receipt", HeadingFont, Brushes.DarkRed, x, y)
  15.  
  16. x = 10
  17. y = y + FontHeight + 20
  18. Printline = ""
  19. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  20. FontHeight = MyFont.GetHeight(e.Graphics)
  21.  
  22. y = y + FontHeight + 10
  23.  
  24. Printline = "Customer Details "
  25. e.Graphics.DrawString(Printline, SubHeadingFont, Brushes.Black, x, y)
  26. FontHeight = SubHeadingFont.GetHeight(e.Graphics)
  27.  
  28. y = y + FontHeight
  29.  
  30. Printline = "CustomerID: " & cboCustomerID.Text
  31. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  32. FontHeight = MyFont.GetHeight(e.Graphics)
  33. y = y + FontHeight
  34.  
  35. FileOpen(3, CustomerFilename, OpenMode.Random,,, Len(CustomerDetails))
  36. While Not EOF(3)
  37. FileGet(3, CustomerDetails)
  38. If CInt(cboCustomerID.Text) = CustomerDetails.CustomerID Then
  39. FontHeight = MyFont.GetHeight(e.Graphics)
  40. Printline = "Name: " & CustomerDetails.Name
  41. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  42.  
  43. y = y + FontHeight
  44. Printline = "Address: " & CustomerDetails.Address
  45. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  46.  
  47. y = y + FontHeight
  48. Printline = "Postcode: " & CustomerDetails.Postcode
  49. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  50.  
  51. y = y + FontHeight
  52. Printline = "Phone Number: " & CustomerDetails.phone
  53. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  54.  
  55. y = y + FontHeight
  56. Printline = "Email: " & CustomerDetails.email
  57. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  58. End If
  59. End While
  60. FileClose(3)
  61.  
  62. y = y + FontHeight
  63. Printline = ""
  64. e.Graphics.DrawString(Printline, SubHeadingFont, Brushes.Black, x, y)
  65. FontHeight = SubHeadingFont.GetHeight(e.Graphics)
  66.  
  67. y = y + FontHeight
  68.  
  69. Printline = "Order Details"
  70. e.Graphics.DrawString(Printline, SubHeadingFont, Brushes.Black, x, y)
  71. FontHeight = SubHeadingFont.GetHeight(e.Graphics)
  72.  
  73. y = y + FontHeight + 10
  74.  
  75. Printline = "Ordered Items:"
  76. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  77. FontHeight = MyFont.GetHeight(e.Graphics)
  78. y = y + FontHeight
  79.  
  80. Printline = ""
  81. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  82. FontHeight = MyFont.GetHeight(e.Graphics)
  83. y = y + FontHeight
  84.  
  85.  
  86. Printline = (String.Format(StockListFormat, "StockID", "Name", "Price"))
  87. e.Graphics.DrawString(Printline, ListFont, Brushes.Black, x, y)
  88. FontHeight = ListFont.GetHeight(e.Graphics)
  89. y = y + FontHeight
  90.  
  91. For count = 0 To lstBasket.Items.Count - 1
  92. Printline = lstBasket.Items(count).ToString()
  93. e.Graphics.DrawString(Printline, ListFont, Brushes.Black, x, y)
  94. y = y + FontHeight
  95. Next
  96.  
  97. FontHeight = MyFont.GetHeight(e.Graphics)
  98. Printline = ""
  99. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  100. FontHeight = MyFont.GetHeight(e.Graphics)
  101.  
  102. y = y + FontHeight
  103.  
  104. Printline = "Total cost before VAT: " & txtTotal.Text
  105. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  106. FontHeight = MyFont.GetHeight(e.Graphics)
  107. y = y + FontHeight
  108.  
  109. Printline = "VAT: " & txtVAT.Text
  110. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  111. FontHeight = MyFont.GetHeight(e.Graphics)
  112. y = y + FontHeight
  113.  
  114. Printline = "Gross Cost: " & txtGrossCost.Text
  115. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  116. FontHeight = MyFont.GetHeight(e.Graphics)
  117. y = y + FontHeight
  118.  
  119. Printline = ""
  120. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  121. FontHeight = MyFont.GetHeight(e.Graphics)
  122. y = y + FontHeight
  123.  
  124. Printline = "Thank you for your purchase!"
  125. e.Graphics.DrawString(Printline, MyFont, Brushes.Black, x, y)
  126. FontHeight = MyFont.GetHeight(e.Graphics)
  127.  
  128. End Sub
  129. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement