Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Strict On
  2. Public Class Form1
  3.     'Roshelle Cunningham
  4.  
  5.     Dim strName, strPhone, strDate, strNights, strMembership As String 'info for the combobox
  6.    Dim dblAdults, dblKids, dblResortFee, dblMealAmt As Double
  7.     Dim bytMeal As Byte
  8.     Dim strFoodType, strMembershipType As String
  9.  
  10.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  11.         'clears the information
  12.        lstInvoice.Items.Clear()
  13.         'program reads and opens the txt file
  14.        Dim sr As IO.StreamReader
  15.         sr = IO.File.OpenText("C:\Temp\Resort.txt")
  16.         'variables
  17.        Dim cboName, cboPhone As String
  18.         'txt values added to the input boxes
  19.        Do While sr.Peek <> -1
  20.             cboName = sr.ReadLine
  21.             cboPhone = sr.ReadLine
  22.             sr.ReadLine() 'dummy check-in date
  23.            sr.ReadLine() 'dummy nights
  24.            sr.ReadLine() 'dummy adults
  25.            sr.ReadLine() 'dummy kids
  26.            sr.ReadLine() 'dummy meal
  27.            sr.ReadLine() 'dummy membership
  28.            'sorts and lists the txt information
  29.            cboGuestSearch.Sorted = True
  30.             cboGuestSearch.Items.Add(cboName & " " & cboPhone)
  31.         Loop
  32.         'close the txt file
  33.        sr.Close()
  34.     End Sub
  35.     Private Sub RetrieveData() Handles cboGuestSearch.SelectedIndexChanged
  36.         'program reads and opens the txt file
  37.        Dim sr As IO.StreamReader
  38.         sr = IO.File.OpenText("C:\Temp\Resort.txt")
  39.         Dim strSearchID As String 'id
  40.        Dim dblMealAmt As Double
  41.  
  42.         strSearchID = GetPhone() 'return
  43.  
  44.         'loop to search the information to go into the textboxes
  45.        Do While sr.Peek <> -1
  46.             If strSearchID <> strPhone Then
  47.                 strName = sr.ReadLine
  48.                 strPhone = sr.ReadLine
  49.                 strDate = sr.ReadLine
  50.                 strNights = sr.ReadLine
  51.                 dblAdults = CDbl(sr.ReadLine)
  52.                 dblKids = CDbl(sr.ReadLine)
  53.                 bytMeal = CByte(sr.ReadLine)
  54.                 strMembership = sr.ReadLine
  55.             Else
  56.                 Exit Do
  57.             End If
  58.         Loop
  59.  
  60.         'textbox information
  61.        lstInvoice.Items.Clear()
  62.         txtGuestName.Text = strName
  63.         txtGuestPhone.Text = strPhone
  64.         txtCheckInDate.Text = strDate
  65.         txtNightsToStay.Text = strNights
  66.         txtAdults.Text = CStr(dblAdults)
  67.         txtKids.Text = CStr(dblKids)
  68.  
  69.         'calls produce invoice
  70.        ProduceInvoice(dblResortFee, dblAdults, dblKids)
  71.  
  72.        
  73.  
  74.     End Sub
  75.     'a function to extract the phone number
  76.    Private Function GetPhone() As String
  77.         Dim strPhoneNumber As String = cboGuestSearch.SelectedItem.ToString
  78.         Dim bytePhone As Byte
  79.         bytePhone = CByte(strPhoneNumber.IndexOf(" ")) + CByte(1) 'gets rid of the first name
  80.        strPhoneNumber = strPhoneNumber.Substring(bytePhone) 'gets rid of the last name
  81.        bytePhone = CByte(strPhoneNumber.IndexOf(" ")) + CByte(1)
  82.         strPhoneNumber = strPhoneNumber.Substring(bytePhone)
  83.         Return strPhoneNumber 'returns the phone number as a string
  84.    End Function
  85.  
  86.     Private Sub ProduceInvoice(ByRef dblResortFee As Double, ByRef dblAdults As Double, ByRef dblKids As Double)
  87.         'calculation information and variables for the resort fee: adults & kids
  88.        Dim dblAdultFee, dblKidFee As Double
  89.         Dim dblAdultDailyRate, dblKidsDailyRate As Double
  90.         Dim dblDiscount As Double
  91.  
  92.         dblAdultDailyRate = 40
  93.         dblKidsDailyRate = 25
  94.  
  95.         dblAdultFee = (dblAdults * dblAdultDailyRate * CDbl(strNights))
  96.         dblKidFee = (dblKids * dblKidsDailyRate * CDbl(strNights))
  97.  
  98.         dblResortFee = dblAdultFee + dblKidFee
  99.  
  100.         MealPlan(bytMeal, dblMealAmt, strNights) 'used to checkbox the mealplans
  101.  
  102.         Membership(strMembership, dblResortFee, dblDiscount)
  103.  
  104.  
  105.  
  106.         lstInvoice.Items.Add(strName)
  107.         lstInvoice.Items.Add(strPhone)
  108.         lstInvoice.Items.Add(strDate)
  109.         lstInvoice.Items.Add(strNights)
  110.         lstInvoice.Items.Add(dblAdults)
  111.         lstInvoice.Items.Add(dblKids)
  112.         lstInvoice.Items.Add(bytMeal)
  113.         lstInvoice.Items.Add(strMembership)
  114.  
  115.         lstInvoice.Items.Add(FormatDateTime(Today, DateFormat.GeneralDate))
  116.  
  117.         lstInvoice.Items.Add(bytMeal)
  118.         lstInvoice.Items.Add(dblMealAmt)
  119.         lstInvoice.Items.Add(" ")
  120.         lstInvoice.Items.Add(dblResortFee)
  121.         lstInvoice.Items.Add("aa")
  122.         lstInvoice.Items.Add(CDbl(strNights))
  123.         lstInvoice.Items.Add("bb")
  124.         lstInvoice.Items.Add(dblDiscount)
  125.  
  126.  
  127.     End Sub
  128.  
  129.     Private Sub MealPlan(ByVal bytMeal As Byte, ByRef dblMealAmt As Double, ByVal strNightsStay As String)
  130.         Dim dblRate As Double
  131.         Dim intNights As Integer = CInt(strNightsStay)
  132.         Dim dblTotalPeople As Double = (dblAdults + dblKids)
  133.  
  134.  
  135.         'mealplan if-statement
  136.        If bytMeal = 1 Then 'if the meal is option 1, breakfast is selected
  137.            chkBreakfast.Checked = True
  138.             chkDinner.Checked = False
  139.             strFoodType = "Breakfast"
  140.             If intNights <= 3 Then
  141.                 dblRate = 15
  142.             Else
  143.                 dblRate = 10
  144.             End If
  145.         End If
  146.  
  147.  
  148.         If bytMeal = 2 Then 'if option 2, dinner selected
  149.            chkDinner.Checked = True
  150.             chkBreakfast.Checked = False
  151.             strFoodType = "Dinner"
  152.             If intNights <= 3 Then
  153.                 dblRate = 30
  154.             Else
  155.                 dblRate = 25
  156.             End If
  157.         End If
  158.  
  159.  
  160.         If bytMeal = 3 Then 'if option 3, both are selected
  161.            chkBreakfast.Checked = True
  162.             chkDinner.Checked = True
  163.             strFoodType = "Breakfast & Dinner"
  164.             If intNights <= 3 Then
  165.                 dblRate = 40
  166.             Else
  167.                 dblRate = 30
  168.             End If
  169.         End If
  170.  
  171.         If bytMeal = 4 Then 'if option 4, none are selected
  172.            chkBreakfast.Checked = False
  173.             chkDinner.Checked = False
  174.             If strFoodType = "None" Then
  175.                 dblRate = 0
  176.             End If
  177.         End If
  178.  
  179.  
  180.         dblMealAmt = dblTotalPeople * dblRate
  181.  
  182.  
  183.     End Sub
  184.     Private Sub Membership(ByVal strMembership As String, ByRef dblResortFee As Double, ByRef dblDiscount As Double)
  185.         Dim dblMemRate As Double
  186.         'membership if-statement
  187.        If strMembership = "B" Then
  188.             optBCAA.Checked = True
  189.             strMembershipType = "BCAA"
  190.             dblMemRate = 0.1
  191.         End If
  192.  
  193.         If strMembership = "D" Then
  194.             optDouglas.Checked = True
  195.             strMembershipType = "Douglas"
  196.             dblMemRate = 0.15
  197.         End If
  198.  
  199.         If strMembership = "N" Then
  200.             optNA.Checked = True
  201.             strMembershipType = "None"
  202.             dblMemRate = 0
  203.         End If
  204.  
  205.         dblDiscount = dblResortFee * dblMemRate
  206.  
  207.     End Sub
  208.    
  209.  
  210.     Private Sub btnPrepareInvoice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrepareInvoice.Click
  211.  
  212.     End Sub
  213. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement