'Program: EX0201 'Programmer: Theresa Berry and John Blyzka 'Date: August 2008 'Class: MainForm 'Description: Demonstrates MDI using multiple forms. ' The program uses these Visual Studio installed ' templates: Splash Screen, and About Box. ' The MainForm must be set as the startup form. 'Program: Ch. 12 Assignment 'Programmer: Joseph Schuman 'Date: October 2014 'Class: MainForm 'Description: A HTML Help file is connected to the form. Public Class ParentForm Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AboutToolStripMenuItem.Click ' Display the Help form with attribute information. AboutBox1.Show() End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click ' End the program. Me.Close() End Sub Private Sub SpecialsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SpecialsToolStripMenuItem.Click ' Display the Specials form. Dim ASpecialsForm As MainForm = MainForm.Instance() With ASpecialsForm .MdiParent = Me .Show() .Focus() End With End Sub Private Sub SummaryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SummaryToolStripMenuItem.Click ' Display the Summary form. Dim ASummaryForm As SummaryForm = SummaryForm.Instance() With ASummaryForm .MdiParent = Me .Show() .Focus() End With End Sub Private Sub ContentsToolStripMenuItem_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles ContentsToolStripMenuItem.Click 'Display the Help contents. Help.ShowHelp(Me, "TriciasTravelsHelp.chm") End Sub Private Sub IndexToolStripMenuItem_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles IndexToolStripMenuItem.Click 'Display the Index contents. Help.ShowHelpIndex(Me, "TriciasTravelsHelp.chm") End Sub Private Sub ParentForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class 'Program: EX0201 'Programmer: Theresa Berry and John Blyzka 'Date: August 2008 'Class: MainForm 'Description: Presentation tier for Travel Specials for Tricia's Travels. ' Validate that the user has made an entry for all fields. Public Class MainForm Private Shared AnInstance As MainForm Enum TravelDays Seven Fourteen End Enum Public Shared ReadOnly Property Instance() As MainForm Get If AnInstance Is Nothing Then AnInstance = New MainForm End If Return AnInstance End Get End Property Private Sub SpecialsForm_FormClosing(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing AnInstance = Nothing e.Cancel = False End Sub Private Sub CloseButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click ' Close the form. Me.Close() End Sub Private Sub CalculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CalculateButton.Click ' Calculate the amount for this trip. ' Create a Billing object to connect to the business tier. Dim TravelersInteger, DaysInteger, FirstInteger As Integer With Me ' Check for valid input data. .ErrorProvider1.Clear() ' Determine the user's selections. If .NameTextBox.Text <> "" Then If .PhoneTextBox.Text <> "" Then Integer.TryParse(.TravelersTextBox.Text, TravelersInteger) If TravelersInteger > 0 Then If .DepartureTextBox.Text <> "" Then If .CCTextBox.Text <> "" Then If .DestinationsListBox.SelectedIndex <> -1 Then If .Days7RadioButton.Checked Then DaysInteger = TravelDays.Seven ElseIf .Days14RadioButton.Checked Then DaysInteger = TravelDays.Fourteen Else .ErrorProvider1.SetError(.TravelDaysGroupBox, _ "Select the number of travel days.") End If If .FirstClassCheckBox.Checked Then FirstInteger = 1 End If 'Call the Billing class Try Dim billingObject As New Billing(TravelersInteger, DaysInteger, .DestinationsListBox.SelectedIndex, FirstInteger) .AmountDueTextBox.Text = billingObject.AmountDue.ToString("C") ' Catch exceptions from the Billing class. Catch Err As ApplicationException MessageBox.Show(Err.Message) End Try Else .ErrorProvider1.SetError(.DestinationsListBox, _ "Destination selection is required.") End If Else .ErrorProvider1.SetError(.CCTextBox, _ "Cred** car* number is required.") .CCTextBox.Focus() End If Else .ErrorProvider1.SetError(.DepartureTextBox, _ "Departure date is required.") .DepartureTextBox.Focus() End If Else .ErrorProvider1.SetError(.TravelersTextBox, _ "Number of travelers is required.") .TravelersTextBox.Focus() End If Else .ErrorProvider1.SetError(.PhoneTextBox, _ "Phone number is required.") .PhoneTextBox.Focus() End If Else .ErrorProvider1.SetError(.NameTextBox, _ "Name is required.") .NameTextBox.Focus() End If End With End Sub Private Sub NumberTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles TravelersTextBox.Validating ' Test hours for numeric. Dim NumberInteger As Integer Integer.TryParse(TravelersTextBox.Text, NumberInteger) If NumberInteger = 0 Then ErrorProvider1.SetError(TravelersTextBox, _ "The number of travelers must be numeric.") TravelersTextBox.SelectAll() e.Cancel = True Else ErrorProvider1.Clear() End If End Sub Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click ' Clear the screen fields. ErrorProvider1.Clear() With NameTextBox .Clear() .Focus() End With PhoneTextBox.Clear() TravelersTextBox.Clear() DepartureTextBox.Clear() CCTextBox.Clear() DestinationsListBox.SelectedIndex = -1 Days7RadioButton.Checked = False Days14RadioButton.Checked = False FirstClassCheckBox.Checked = False AmountDueTextBox.Clear() End Sub Private Sub MainForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub End Class 'Program: EX0201 'Programmer: Theresa Berry and John Blyzka 'Date: August 2008 'Class: SummaryForm 'Description: Displays summary information for multiple transactions. ' Uses the singleton design pattern to ensure that only one ' instance of the form can be created. Public Class SummaryForm Private Shared AnInstance As SummaryForm Public Shared ReadOnly Property Instance() As SummaryForm Get If AnInstance Is Nothing Then AnInstance = New SummaryForm End If Return AnInstance End Get End Property Private Sub SummaryForm_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated ' Retrieve and display the summary values. TotalBillingTextBox.Text = Billing.TotalBilling.ToString("C") TotalTravelersTextBox.Text = Billing.NumberTraveling.ToString() CaribbeanTravelersTextBox.Text = Billing.Caribbean.ToString() MediterraneanTravelersTextBox.Text = Billing.Mediterranean.ToString() AlaskaTravelersTextBox.Text = Billing.Alaska.ToString() TotalFirstClassTravelersTextBox.Text = Billing.FirstClassTravelers.ToString End Sub Private Sub SummaryForm_FormClosing(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing ' Release the form's instance. AnInstance = Nothing End Sub Private Sub CloseButton_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click ' Close the form. Me.Close() End Sub Private Sub GroupBox1_Enter(sender As Object, e As EventArgs) Handles GroupBox1.Enter End Sub End Class 'Program: EX0201 'Programmer: Theresa Berry and John Blyzka 'Date: August 2008 'Class: AboutBox1 'Description: Uses Visual Studio installed template: About Box ' The Assembly Attribute Information is displayed. Public NotInheritable Class AboutBox1 Private Sub AboutBox1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Set the title of the form. Dim ApplicationTitle As String If My.Application.Info.Title <> "" Then ApplicationTitle = My.Application.Info.Title Else ApplicationTitle = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) End If Text = String.Format("About {0}", ApplicationTitle) ' Initialize all of the text displayed on the About Box. ' TODO: Customize the application's assembly information in the "Application" pane of the project ' properties dialog (under the "Project" menu). LabelProductName.Text = My.Application.Info.ProductName LabelVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString) LabelCopyright.Text = My.Application.Info.Copyright LabelCompanyName.Text = My.Application.Info.CompanyName TextBoxDescription.Text = My.Application.Info.Description End Sub Private Sub OKButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OKButton.Click Me.Close() End Sub End Class 'Program: EX0201 'Programmer: Theresa Berry and John Blyzka 'Date: August 2008 'Class SplashScreen1 'Description: Uses Visual Studio installed template: Splash Screen Public NotInheritable Class SplashScreen1 ' TODO: This form can easily be set as the splash screen for the application by going to the "Application" tab ' of the Project Designer ("Properties" under the "Project" menu). Private Sub SplashScreen1_FormClosing(ByVal sender As Object, _ ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing ' Hold the form for about 5 seconds. System.Threading.Thread.Sleep(5000) End Sub Private Sub SplashScreen1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load ' Set up the dialog text at runtime according to the application's assembly information. ' TODO: Customize the application's assembly information in the "Application" pane of the project ' properties dialog (under the "Project" menu). ' Application title. If My.Application.Info.Title <> "" Then ApplicationTitle.Text = My.Application.Info.Title Else ' If the application title is missing, use the application name, without the extension. ApplicationTitle.Text = System.IO.Path.GetFileNameWithoutExtension(My.Application.Info.AssemblyName) End If ' Format the version information using the text set into the Version control at design time as the ' formatting string. This allows for effective localization if desired. ' Build and revision information could be included by using the following code and changing the ' Version control's designtime text to "Version {0}.{1:00}.{2}.{3}" or something similar. See ' String.Format() in Help for more information. ' Version.Text = System.String.Format(Version.Text, My.Application.Info.Version.Major, My.Application.Info.Version.Minor) ' Copyright info. Copyright.Text = My.Application.Info.Copyright End Sub Private Sub MainLayoutPanel_Paint(sender As Object, e As PaintEventArgs) Handles MainLayoutPanel.Paint End Sub End Class 'Program: EX0201 'Programmer: Theresa Berry and John Blyzka 'Date: August 2008 'Class: Billing 'Description: Business tier for Tricia's Travels Public Class Billing ' Instance variables. Private TravelersInteger As Integer 'Hold the travelers property. Private DaysInteger As Integer 'Hold the days property. Private DestinationInteger As Integer 'Hold the destination property. Private FirstClassInteger As Integer 'Hold the first class property. Private AmountDueDecimal As Decimal 'Amount due for this order ' Shared variables. ' Hold the TotalBilling shared property. Private Shared TotalBillingDecimal As Decimal ' Hold the NumberTraveling shared property. Private Shared NumberTravelingInteger As Integer 'Hold the Caribbean shared property. Private Shared CaribbeanInteger As Integer 'Hold the Mediterranean shared property. Private Shared MediterraneanInteger As Integer 'Hold the Alaska shared property. Private Shared AlaskaInteger As Integer 'Hold the FirstClassTravelers shared property. Private Shared FirstClassTravelersInteger As Integer ' Constants. Private Const SEVEN_DAYS_CARIBBEAN As Integer = 3250 Private Const FIRSTCLASS_SEVEN_DAYS_CARIBBEAN As Integer = 5000 Private Const FOURTEEN_DAYS_CARIBBEAN As Integer = 6000 Private Const FIRSTCLASS_FOURTEEN_DAYS_CARIBBEAN As Integer = 9000 Private Const SEVEN_DAYS_MEDITERRANEAN As Integer = 4250 Private Const FIRSTCLASS_SEVEN_DAYS_MEDITERRANEAN As Integer = 7999 Private Const FOURTEEN_DAYS_MEDITERRANEAN As Integer = 7999 Private Const FIRSTCLASS_FOURTEEN_DAYS_MEDITERRANEAN As Integer = 11999 Private Const SEVEN_DAYS_ALASKA As Integer = 3300 Private Const FIRSTCLASS_SEVEN_DAYS_ALASKA As Integer = 5250 Private Const FOURTEEN_DAYS_ALASKA As Integer = 7200 Private Const FIRSTCLASS_FOURTEEN_DAYS_ALASKA As Integer = 10500 ' Constructor. Sub New(ByVal TravelersInteger As Integer, ByVal DaysInteger As Integer, _ ByVal DestinationInteger As Integer, ByVal FirstInteger As Integer) ' Assign properties and calculate the amount due. Me.Travelers = TravelersInteger Me.Days = DaysInteger Me.Destination = DestinationInteger Me.FirstClass = FirstInteger FindAmountDue() End Sub Private Sub FindAmountDue() 'Calculate the amount due. Dim PriceDecimal As Decimal Select Case FirstClassInteger Case 0 'Standard Price Select Case DaysInteger Case 0 '7 days Select Case DestinationInteger 'Select Destination Case 0 PriceDecimal = SEVEN_DAYS_CARIBBEAN CaribbeanInteger += TravelersInteger Case 1 PriceDecimal = SEVEN_DAYS_MEDITERRANEAN MediterraneanInteger += TravelersInteger Case 2 PriceDecimal = SEVEN_DAYS_ALASKA AlaskaInteger += TravelersInteger End Select Case 1 '14 days Select Case DestinationInteger 'Select Destination Case 0 PriceDecimal = FOURTEEN_DAYS_CARIBBEAN CaribbeanInteger += TravelersInteger Case 1 PriceDecimal = FOURTEEN_DAYS_MEDITERRANEAN MediterraneanInteger += TravelersInteger Case 2 PriceDecimal = FOURTEEN_DAYS_ALASKA AlaskaInteger += TravelersInteger End Select End Select Case 1 'First Class Price FirstClassTravelersInteger += TravelersInteger 'Total of first class travelers Select Case DaysInteger Case 0 '7 days Select Case DestinationInteger 'Select Destination Case 0 PriceDecimal = FIRSTCLASS_SEVEN_DAYS_CARIBBEAN CaribbeanInteger += TravelersInteger Case 1 PriceDecimal = FIRSTCLASS_SEVEN_DAYS_MEDITERRANEAN MediterraneanInteger += TravelersInteger Case 2 PriceDecimal = FIRSTCLASS_SEVEN_DAYS_ALASKA AlaskaInteger += TravelersInteger End Select Case 1 '14 days Select Case DestinationInteger 'Select Destination Case 0 PriceDecimal = FIRSTCLASS_FOURTEEN_DAYS_CARIBBEAN CaribbeanInteger += TravelersInteger Case 1 PriceDecimal = FIRSTCLASS_FOURTEEN_DAYS_MEDITERRANEAN MediterraneanInteger += TravelersInteger Case 2 PriceDecimal = FIRSTCLASS_FOURTEEN_DAYS_ALASKA AlaskaInteger += TravelersInteger End Select End Select End Select ' Calculation price and totals. AmountDueDecimal = TravelersInteger * PriceDecimal TotalBillingDecimal += AmountDueDecimal 'Total billing amount NumberTravelingInteger += TravelersInteger 'Total number traveling End Sub ' Property procedures. Public Property Travelers() As Integer Get Return TravelersInteger End Get Set(ByVal Value As Integer) TravelersInteger = Value End Set End Property Public Property Days() As Integer Get Return DaysInteger End Get Set(ByVal Value As Integer) DaysInteger = Value End Set End Property Public Property Destination() As Integer Get Return DestinationInteger End Get Set(ByVal Value As Integer) DestinationInteger = Value End Set End Property Public Property FirstClass() As Integer Get Return FirstClassInteger End Get Set(ByVal Value As Integer) FirstClassInteger = Value End Set End Property Public ReadOnly Property AmountDue() As Decimal Get Return AmountDueDecimal End Get End Property Public Shared ReadOnly Property TotalBilling() As Decimal Get Return TotalBillingDecimal End Get End Property Public Shared ReadOnly Property NumberTraveling() As Decimal Get Return NumberTravelingInteger End Get End Property Public Shared ReadOnly Property Caribbean() As Integer Get Return CaribbeanInteger End Get End Property Public Shared ReadOnly Property Mediterranean() As Integer Get Return MediterraneanInteger End Get End Property Public Shared ReadOnly Property Alaska() As Integer Get Return AlaskaInteger End Get End Property Public Shared ReadOnly Property FirstClassTravelers() As Integer Get Return FirstClassTravelersInteger End Get End Property End Class 'Program: Table of Contents for the Help page '