Thursday, 15 August 2013

Flight booking system

Flight booking system

Please can you assist. I have created a simply flight booking system. When
the user selects the calculate button, it will calculate the price for the
number of adults and children selected from the combobox option. The
calculations are created inside the try catch and the if statements
depending on the selection in combo box 1 and combo box 2. I need to
create a module and put the calculate function inside the module, call the
function in the calculate button. The price of the flight is dependent on
the destination selected.
This is the source code for the program Your assistance will be highly
appreciated.
Public Class Form1
Private Sub btncalculateprice_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btncalculateprice.Click
Dim PricechildrenLocal As Integer = 1200
Dim PriceadultsLocal As Integer = 12000
Dim totalAdults As Integer
Dim totalChildren As Integer
Dim totalPrice As Integer
Dim totalPrice1 As Integer
Dim totalPrice2 As Integer
Try
If cmbadults.Text = 0 Then
totalAdults += 0
End If
If cmbadults.Text = 1 Then
totalAdults += 1
End If
If cmbadults.Text = 2 Then
totalAdults += 2
End If
If cmbadults.Text = 3 Then
totalAdults += 3
End If
If cmbadults.Text = 4 Then
totalAdults += 4
End If
If cmbadults.Text = 5 Then
totalAdults += 5
End If
If cmbadults.Text = 6 Then
totalAdults += 6
End If
If cmbadults.Text = 7 Then
totalAdults += 7
End If
If cmbadults.Text = 8 Then
totalAdults += 8
End If
If cmbadults.Text = 9 Then
totalAdults += 9
End If
If cmbadults.Text = 10 Then
totalAdults += 10
End If
Catch ex As Exception
End Try
Try
If cmbchildren.Text = 0 Then
totalChildren += 0
End If
If cmbchildren.Text = 1 Then
totalChildren += 1
End If
If cmbchildren.Text = 2 Then
totalChildren += 2
End If
If cmbchildren.Text = 3 Then
totalChildren += 3
End If
If cmbchildren.Text = 4 Then
totalChildren += 4
End If
If cmbchildren.Text = 5 Then
totalChildren += 5
End If
If cmbchildren.Text = 6 Then
totalChildren += 6
End If
If cmbchildren.Text = 7 Then
totalChildren += 7
End If
If cmbchildren.Text = 8 Then
totalChildren += 8
End If
If cmbchildren.Text = 9 Then
totalChildren += 9
End If
If cmbchildren.Text = 10 Then
totalChildren += 10
End If
Catch ex As Exception
End Try
Try
If ComboBox1.Text = "Bloemfontien Airport (BFN)" And
ComboBox2.Text = "Cape Town International (CPT)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Bloemfontien Airport (BFN)" And
ComboBox2.Text = "King Shaka International Airport (DBN)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 100
totalPrice2 = totalAdults * PriceadultsLocal + 150
ElseIf ComboBox1.Text = "Bloemfontien Airport (BFN)" And
ComboBox2.Text = "O.R Tambo International Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 100
totalPrice2 = totalAdults * PriceadultsLocal + 150
ElseIf ComboBox1.Text = "Bloemfontien Airport (BFN)" And
ComboBox2.Text = "Lanseria Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 1000
totalPrice2 = totalAdults * PriceadultsLocal - 2000
ElseIf ComboBox1.Text = "Bloemfontien Airport (BFN)" And
ComboBox2.Text = "Polokwane International Airport (PLK)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Bloemfontien Airport (BFN)" And
ComboBox2.Text = "Port Elizabeth Airport (PE)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "Bloemfontien Airport (BFN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "King Shaka International Airport (DBN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "O.R Tambo International Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 100
totalPrice2 = totalAdults * PriceadultsLocal + 150
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "Lanseria Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "Polokwane International Airport (PLK)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "Port Elizabeth Airport (PE)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "King Shaka International Airport (DBN)"
And ComboBox2.Text = "Bloemfontien Airport (BFN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "King Shaka International Airport (DBN)"
And ComboBox2.Text = "Cape Town International (CPT)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "King Shaka International Airport (DBN)"
And ComboBox2.Text = "O.R Tambo International Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 100
totalPrice2 = totalAdults * PriceadultsLocal + 150
ElseIf ComboBox1.Text = "King Shaka International Airport (DBN)"
And ComboBox2.Text = "Lanseria Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "King Shaka International Airport (DBN)"
And ComboBox2.Text = "Polokwane International Airport (PLK)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "King Shaka International Airport (DBN)"
And ComboBox2.Text = "Port Elizabeth Airport (PE)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "O.R Tambo International Airport (JHB)"
And ComboBox2.Text = "Bloemfontien Airport (BFN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "O.R Tambo International Airport (JHB)"
And ComboBox2.Text = "Cape Town International (CPT)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "O.R Tambo International Airport (JHB)"
And ComboBox2.Text = "Lanseria Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 100
totalPrice2 = totalAdults * PriceadultsLocal + 150
ElseIf ComboBox1.Text = "O.R Tambo International Airport (JHB)"
And ComboBox2.Text = "Polokwane International Airport (PLK)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Cape Town International (CPT)" And
ComboBox2.Text = "Port Elizabeth Airport (PE)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Lanseria Airport (JHB)" And
ComboBox2.Text = "Bloemfontien Airport (BFN)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Lanseria Airport (JHB)" And
ComboBox2.Text = "Cape Town International (CPT)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Lanseria Airport (JHB)" And
ComboBox2.Text = "King Shaka International Airport (DBN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Lanseria Airport (JHB) (CPT)" And
ComboBox2.Text = "O.R Tambo International Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Lanseria Airport (JHB)" And
ComboBox2.Text = "Polokwane International Airport (PLK)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Lanseria Airport (JHB)" And
ComboBox2.Text = "Port Elizabeth Airport (PE)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Polokwane International Airport (PLK)"
And ComboBox2.Text = "Bloemfontien Airport (BFN)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Polokwane International Airport (PLK)"
And ComboBox2.Text = "Cape Town International (CPT)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Polokwane International Airport (PLK)"
And ComboBox2.Text = "King Shaka International Airport (DBN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Polokwane International Airport (PLK)"
And ComboBox2.Text = "O.R Tambo International Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Polokwane International Airport (PLK)"
And ComboBox2.Text = "Port Elizabeth Airport (PE)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
ElseIf ComboBox1.Text = "Port Elizabeth Airport (PE)" And
ComboBox2.Text = "Bloemfontien Airport (BFN)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Port Elizabeth Airport (PE)" And
ComboBox2.Text = "Cape Town International (CPT)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Port Elizabeth Airport (PE)" And
ComboBox2.Text = "King Shaka International Airport (DBN)" Then
totalPrice1 = totalChildren * PricechildrenLocal
totalPrice2 = totalAdults * PriceadultsLocal
ElseIf ComboBox1.Text = "Port Elizabeth Airport (PE)" And
ComboBox2.Text = "O.R Tambo International Airport (JHB)" Then
totalPrice1 = totalChildren * PricechildrenLocal - 500
totalPrice2 = totalAdults * PriceadultsLocal - 1000
ElseIf ComboBox1.Text = "Port Elizabeth Airport (PE)" And
ComboBox2.Text = "Polokwane International Airport (PLK)" Then
totalPrice1 = totalChildren * PricechildrenLocal + 150
totalPrice2 = totalAdults * PriceadultsLocal + 200
End If
Catch ex As Exception
End Try
totalPrice = totalPrice1 + totalPrice2
Price.Text = Format(totalPrice, "currency")
Adults.Text = totalAdults
Children.Text = totalChildren
End Sub
Private Sub btnbookflight_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnbookflight.Click
Dim form As New Confirm
If cmbadults.SelectedItem = "" Then
MessageBox.Show("Please select the number of adults")
Else
If cmbchildren.SelectedItem = "" Then
MessageBox.Show("Please select the number of children")
Else
If ComboBox1.SelectedItem = "" Then
MessageBox.Show("Please select the depature destination")
Else
If ComboBox2.SelectedItem = "" Then
MessageBox.Show("Please select the going to destination")
Else
Confirm.Show()
End If
End If
End If
End If
End Sub
Private Sub cmbadults_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cmbadults.SelectedIndexChanged
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub rbnoneway_CheckedChanged(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles rbnoneway.CheckedChanged
If rbnoneway.Checked Then
lblreturndate.Hide()
Else
lblreturndate.Show()
End If
If rbnoneway.Checked Then
dtereturn.Hide()
Else
dtereturn.Show()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
cmbtitle.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
cmbadults.Text = ""
cmbchildren.Text = ""
ComboBox1.Text = ""
ComboBox2.Text = ""
dtedepature.Text = ""
dtereturn.Text = ""
rbnoneway.Checked = False
rbnroundtrip.Checked = False
End Sub
End Class

No comments:

Post a Comment