Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Strict On
- Public Class Form1
- 'Roshelle Cunningham
- Dim strName, strPhone, strDate, strNights, strMembership As String 'info for the combobox
- Dim dblAdults, dblKids, dblResortFee, dblMealAmt As Double
- Dim bytMeal As Byte
- Dim strFoodType, strMembershipType As String
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'clears the information
- lstInvoice.Items.Clear()
- 'program reads and opens the txt file
- Dim sr As IO.StreamReader
- sr = IO.File.OpenText("C:\Temp\Resort.txt")
- 'variables
- Dim cboName, cboPhone As String
- 'txt values added to the input boxes
- Do While sr.Peek <> -1
- cboName = sr.ReadLine
- cboPhone = sr.ReadLine
- sr.ReadLine() 'dummy check-in date
- sr.ReadLine() 'dummy nights
- sr.ReadLine() 'dummy adults
- sr.ReadLine() 'dummy kids
- sr.ReadLine() 'dummy meal
- sr.ReadLine() 'dummy membership
- 'sorts and lists the txt information
- cboGuestSearch.Sorted = True
- cboGuestSearch.Items.Add(cboName & " " & cboPhone)
- Loop
- 'close the txt file
- sr.Close()
- End Sub
- Private Sub RetrieveData() Handles cboGuestSearch.SelectedIndexChanged
- 'program reads and opens the txt file
- Dim sr As IO.StreamReader
- sr = IO.File.OpenText("C:\Temp\Resort.txt")
- Dim strSearchID As String 'id
- Dim dblMealAmt As Double
- strSearchID = GetPhone() 'return
- 'loop to search the information to go into the textboxes
- Do While sr.Peek <> -1
- If strSearchID <> strPhone Then
- strName = sr.ReadLine
- strPhone = sr.ReadLine
- strDate = sr.ReadLine
- strNights = sr.ReadLine
- dblAdults = CDbl(sr.ReadLine)
- dblKids = CDbl(sr.ReadLine)
- bytMeal = CByte(sr.ReadLine)
- strMembership = sr.ReadLine
- Else
- Exit Do
- End If
- Loop
- 'textbox information
- lstInvoice.Items.Clear()
- txtGuestName.Text = strName
- txtGuestPhone.Text = strPhone
- txtCheckInDate.Text = strDate
- txtNightsToStay.Text = strNights
- txtAdults.Text = CStr(dblAdults)
- txtKids.Text = CStr(dblKids)
- 'calls produce invoice
- ProduceInvoice(dblResortFee, dblAdults, dblKids)
- End Sub
- 'a function to extract the phone number
- Private Function GetPhone() As String
- Dim strPhoneNumber As String = cboGuestSearch.SelectedItem.ToString
- Dim bytePhone As Byte
- bytePhone = CByte(strPhoneNumber.IndexOf(" ")) + CByte(1) 'gets rid of the first name
- strPhoneNumber = strPhoneNumber.Substring(bytePhone) 'gets rid of the last name
- bytePhone = CByte(strPhoneNumber.IndexOf(" ")) + CByte(1)
- strPhoneNumber = strPhoneNumber.Substring(bytePhone)
- Return strPhoneNumber 'returns the phone number as a string
- End Function
- Private Sub ProduceInvoice(ByRef dblResortFee As Double, ByRef dblAdults As Double, ByRef dblKids As Double)
- 'calculation information and variables for the resort fee: adults & kids
- Dim dblAdultFee, dblKidFee As Double
- Dim dblAdultDailyRate, dblKidsDailyRate As Double
- Dim dblDiscount As Double
- dblAdultDailyRate = 40
- dblKidsDailyRate = 25
- dblAdultFee = (dblAdults * dblAdultDailyRate * CDbl(strNights))
- dblKidFee = (dblKids * dblKidsDailyRate * CDbl(strNights))
- dblResortFee = dblAdultFee + dblKidFee
- MealPlan(bytMeal, dblMealAmt, strNights) 'used to checkbox the mealplans
- Membership(strMembership, dblResortFee, dblDiscount)
- lstInvoice.Items.Add(strName)
- lstInvoice.Items.Add(strPhone)
- lstInvoice.Items.Add(strDate)
- lstInvoice.Items.Add(strNights)
- lstInvoice.Items.Add(dblAdults)
- lstInvoice.Items.Add(dblKids)
- lstInvoice.Items.Add(bytMeal)
- lstInvoice.Items.Add(strMembership)
- lstInvoice.Items.Add(FormatDateTime(Today, DateFormat.GeneralDate))
- lstInvoice.Items.Add(bytMeal)
- lstInvoice.Items.Add(dblMealAmt)
- lstInvoice.Items.Add(" ")
- lstInvoice.Items.Add(dblResortFee)
- lstInvoice.Items.Add("aa")
- lstInvoice.Items.Add(CDbl(strNights))
- lstInvoice.Items.Add("bb")
- lstInvoice.Items.Add(dblDiscount)
- End Sub
- Private Sub MealPlan(ByVal bytMeal As Byte, ByRef dblMealAmt As Double, ByVal strNightsStay As String)
- Dim dblRate As Double
- Dim intNights As Integer = CInt(strNightsStay)
- Dim dblTotalPeople As Double = (dblAdults + dblKids)
- 'mealplan if-statement
- If bytMeal = 1 Then 'if the meal is option 1, breakfast is selected
- chkBreakfast.Checked = True
- chkDinner.Checked = False
- strFoodType = "Breakfast"
- If intNights <= 3 Then
- dblRate = 15
- Else
- dblRate = 10
- End If
- End If
- If bytMeal = 2 Then 'if option 2, dinner selected
- chkDinner.Checked = True
- chkBreakfast.Checked = False
- strFoodType = "Dinner"
- If intNights <= 3 Then
- dblRate = 30
- Else
- dblRate = 25
- End If
- End If
- If bytMeal = 3 Then 'if option 3, both are selected
- chkBreakfast.Checked = True
- chkDinner.Checked = True
- strFoodType = "Breakfast & Dinner"
- If intNights <= 3 Then
- dblRate = 40
- Else
- dblRate = 30
- End If
- End If
- If bytMeal = 4 Then 'if option 4, none are selected
- chkBreakfast.Checked = False
- chkDinner.Checked = False
- If strFoodType = "None" Then
- dblRate = 0
- End If
- End If
- dblMealAmt = dblTotalPeople * dblRate
- End Sub
- Private Sub Membership(ByVal strMembership As String, ByRef dblResortFee As Double, ByRef dblDiscount As Double)
- Dim dblMemRate As Double
- 'membership if-statement
- If strMembership = "B" Then
- optBCAA.Checked = True
- strMembershipType = "BCAA"
- dblMemRate = 0.1
- End If
- If strMembership = "D" Then
- optDouglas.Checked = True
- strMembershipType = "Douglas"
- dblMemRate = 0.15
- End If
- If strMembership = "N" Then
- optNA.Checked = True
- strMembershipType = "None"
- dblMemRate = 0
- End If
- dblDiscount = dblResortFee * dblMemRate
- End Sub
- Private Sub btnPrepareInvoice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrepareInvoice.Click
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement