Advertisement
Lord_Seagull

Unit 14 Assignment 2

Jun 19th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Imports System.IO
  2. Public Class frmFormBooking
  3.     Dim strCustomers() As String = {"John Doe", "Jane Doe"}
  4.     Dim strEvents() As String = {"Hydro pool", "Multi-sensory room", "Art room", "Music Room", "Sensory Garden", "Soft Play Area"}
  5.     Dim strTime() As String = {"8:00", "8:15", "8:30", "8:45", "9:00", "9:15", "9:30", "9:45", "10:15", "10:30", "10:45", "11:00", "11:15", "11:30", "11:45", "12:00", "12:15", "12:30", "12:45", "13:00", "13:15", "13:30", "13:45", "14:00", "14:15", "14:30", "14:45", "15:00", "15:15", "15:30", "15:45", "16:00", "16:15", "16:30", "16:45", "17:00", "17:15", "17:30", "17:45", "18:00"}
  6.     Dim Index As Integer = 1
  7.     Dim Index2 As Integer = 5
  8.     Dim Index3 As Integer = 39
  9.     Dim check As Boolean = False
  10.     Dim strEvent As String
  11.     Dim AdultPrice As Decimal
  12.     Dim ChildPrice As Decimal
  13.     Dim GroupPrice As Decimal
  14.     Dim AdultNo As Integer = 1
  15.     Dim ChildNo As Integer = 1
  16.     Dim TotalNo As Integer = 1
  17.     Const Filename As String = "Customers.txt"
  18.  
  19.  
  20.     Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  21.  
  22.         drpFormCustomer.Items.Clear()
  23.         For i As Integer = 0 To Index
  24.             drpFormCustomer.Items.Add(strCustomers(i))
  25.         Next
  26.  
  27.         drpFormEvent.Items.Clear()
  28.         For i As Integer = 0 To Index2
  29.             drpFormEvent.Items.Add(strEvents(i))
  30.         Next
  31.  
  32.         drpFormStartTime.Items.Clear()
  33.         For i As Integer = 0 To Index3
  34.             drpFormStartTime.Items.Add(strTime(i))
  35.         Next
  36.  
  37.         'Adult & Children Ticket Selection:
  38.  
  39.         nudAdult.Value = AdultNo
  40.         nudChildren.Value = ChildNo
  41.  
  42.     End Sub
  43.  
  44.  
  45.  
  46.     Private Sub btnLoad_Click(sender As Object, e As EventArgs) Handles btnCustomerLoad.Click
  47.         Read_All()
  48.     End Sub
  49.  
  50.     Private Sub Read_All()
  51.         Dim intFile As Integer = FreeFile()
  52.  
  53.         FileOpen(intFile, Filename, OpenMode.Input)
  54.  
  55.         Do While Not EOF(intFile)
  56.             Dim line As String = LineInput(intFile)
  57.             drpFormCustomer.Items.Add(line)
  58.         Loop
  59.         FileClose(intFile)
  60.     End Sub
  61.  
  62.     Private Sub btnAddCountry_Click(sender As Object, e As EventArgs) Handles btnAddCustomer.Click
  63.         If txtCustomerName.Text = "" Or txtCustomerSurname.Text = "" Then
  64.             MsgBox("Please enter a name and surname.")
  65.         Else
  66.             Index += 1
  67.             ReDim Preserve strCustomers(Index)
  68.             strCustomers(Index) = txtCustomerName.Text + " " + txtCustomerSurname.Text
  69.  
  70.             Dim intFile As Integer = FreeFile()
  71.             FileOpen(intFile, Filename, OpenMode.Output)
  72.             PrintLine(intFile, txtCustomerName.Text + " " + txtCustomerSurname.Text)
  73.             FileClose(intFile)
  74.         End If
  75.     End Sub
  76.  
  77.     Private Sub chkGroup_CheckedChanged(sender As Object, e As EventArgs) Handles chkGroup.CheckedChanged
  78.         If check = False Then
  79.             nudAdult.Visible = False
  80.             nudChildren.Visible = False
  81.             lblBookAdultCost.Visible = False
  82.             lblBookChildCost.Visible = False
  83.             lblBookTotalPriceDesc.Visible = False
  84.             lblBookTotalCost.Visible = False
  85.             check = True
  86.         Else
  87.             nudAdult.Visible = True
  88.             nudChildren.Visible = True
  89.             lblBookAdultCost.Visible = True
  90.             lblBookChildCost.Visible = True
  91.             lblBookTotalPriceDesc.Visible = True
  92.             lblBookTotalCost.Visible = True
  93.             check = False
  94.         End If
  95.     End Sub
  96.  
  97.     Sub booking_cost()
  98.         strEvent = drpFormEvent.Text
  99.  
  100.         If strEvent = strEvents(0) Then 'Hydro Pool
  101.            AdultPrice = 20.0
  102.             ChildPrice = 15.0
  103.             GroupPrice = 70.0
  104.         ElseIf strEvent = strEvents(1) Then 'Multi-sensory room
  105.            AdultPrice = 15.0
  106.             ChildPrice = 10.0
  107.             GroupPrice = 50.0
  108.         ElseIf strEvent = strEvents(2) Then 'Art room
  109.            AdultPrice = 10.0
  110.             ChildPrice = 5.0
  111.             GroupPrice = 30.0
  112.         ElseIf strEvent = strEvents(3) Then 'Music Room
  113.            AdultPrice = 10.0
  114.             ChildPrice = 5.0
  115.             GroupPrice = 30.0
  116.         ElseIf strEvent = strEvents(4) Then 'Sensory Garden
  117.            AdultPrice = 15.0
  118.             ChildPrice = 10.0
  119.             GroupPrice = 50.0
  120.         ElseIf strEvent = strEvents(5) Then 'Soft Play Area
  121.            AdultPrice = 20.0
  122.             ChildPrice = 15.0
  123.             GroupPrice = 70.0
  124.         End If
  125.  
  126.         total_booking_cost()
  127.     End Sub
  128.  
  129.     Sub total_booking_cost()
  130.         lblBookAdultCost.Text = "£" + (AdultPrice * AdultNo).ToString
  131.         lblBookChildCost.Text = "£" + (ChildPrice * ChildNo).ToString
  132.         lblBookGroupCost.Text = "£" + GroupPrice.ToString
  133.         TotalNo = (AdultPrice * AdultNo) + (ChildPrice * ChildNo)
  134.         lblBookTotalCost.Text = "£" + TotalNo.ToString
  135.     End Sub
  136.  
  137.     Private Sub drpFormEvent_SelectedIndexChanged(sender As Object, e As EventArgs) Handles drpFormEvent.SelectedIndexChanged
  138.         booking_cost()
  139.     End Sub
  140.  
  141.     Private Sub nudAdult_ValueChanged(sender As Object, e As EventArgs) Handles nudAdult.ValueChanged
  142.         AdultNo = nudAdult.Value
  143.         total_booking_cost()
  144.     End Sub
  145.  
  146.     Private Sub nudChildren_ValueChanged(sender As Object, e As EventArgs) Handles nudChildren.ValueChanged
  147.         ChildNo = nudChildren.Value
  148.         total_booking_cost()
  149.     End Sub
  150.  
  151.     Private Sub btnBookingConfirm_Click(sender As Object, e As EventArgs) Handles btnBookingConfirm.Click
  152.         If drpFormCustomer.Text = "" Or drpFormEvent.Text = "" Or drpFormStartTime.Text = "" Then
  153.             lblMessage.ForeColor = Color.Red
  154.             lblMessage.Text = "Please fill in all areas."
  155.  
  156.         Else
  157.             lblMessage.ForeColor = Color.Green
  158.             lblMessage.Text = "Booking Complete"
  159.             lblInvoiceNo.Text = 4
  160.             lblCustomerName.Text = drpFormCustomer.Text
  161.             lblEvent.Text = drpFormEvent.Text
  162.             lblDate.Text = dtpDateAndTime.Value.Date
  163.             lblTime.Text = drpFormStartTime.Text
  164.             If chkGroup.Checked = True Then
  165.                 lblAdultNo.Text = "2"
  166.                 lblChildNo.Text = "2"
  167.                 lblAdultCost.Text = "(Group Ticket)"
  168.                 lblChildCost.Text = "(Group Ticket)"
  169.                 lblOverallCost.Text = lblBookGroupCost.Text
  170.             Else
  171.                 lblAdultNo.Text = (nudAdult.Value).ToString
  172.                 lblChildNo.Text = (nudChildren.Value).ToString
  173.                 lblAdultCost.Text = lblBookAdultCost.Text
  174.                 lblChildCost.Text = lblBookChildCost.Text
  175.                 vat.Text = "£" + (lblBookTotalCost.Text * 0.2).ToString
  176.                 lblOverallCost.Text = "£" + (lblBookTotalCost.Text * 1.2).ToString
  177.             End If
  178.         End If
  179.     End Sub
  180.  
  181.     Private Sub HelpToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles HelpToolStripMenuItem.Click
  182.         frmHelp.Show()
  183.         frmHelp.WebBrowser1.Navigate("I:\Documents\Year 1\Assignments\Unit 14\Visual Studio\Snoezlen Booking Menu\Snoezlen Booking Menu\Snoezlen Booking Menu\bin\Debug\helpPage.html")
  184.     End Sub
  185. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement