We are building a transportation services website that allows potential users to make transportation services requests online.
We provide the following services:
ONE WAY trip TO the airport
ONE WAY trip FROM the airport
Round Trip services
Also, users have options of what type of vehicles to use.
The vehicles include Sedan and SUV
The way it is supposed to work is this:
If trip is ONE WAY, user is charged a certain fare.
If Round Trip, the user is charged double the ONE WAY fare.
Each fare includes a 10%, a 7% tax and a 20% tip.
If preferred vehicle is SUV, there is an additional $12.00 added to the overall cost.
The code I have below captures the initial fare correctly.
It captures the discount amount, the tax amount, the tip amount, $12.00 for SUV(if that's user's preferred vehicle) and it captures the overall total cost.
The problem we are having is that it does not capture the round trip total cost.
or instance, if overall cost for one way trip from Calhum to airport is $75.00, we expect the round trip be twice that amount for the same route.
Any ideas what to fix on my code to make it work correctly?
We provide the following services:
ONE WAY trip TO the airport
ONE WAY trip FROM the airport
Round Trip services
Also, users have options of what type of vehicles to use.
The vehicles include Sedan and SUV
The way it is supposed to work is this:
If trip is ONE WAY, user is charged a certain fare.
If Round Trip, the user is charged double the ONE WAY fare.
Each fare includes a 10%, a 7% tax and a 20% tip.
If preferred vehicle is SUV, there is an additional $12.00 added to the overall cost.
The code I have below captures the initial fare correctly.
It captures the discount amount, the tax amount, the tip amount, $12.00 for SUV(if that's user's preferred vehicle) and it captures the overall total cost.
The problem we are having is that it does not capture the round trip total cost.
or instance, if overall cost for one way trip from Calhum to airport is $75.00, we expect the round trip be twice that amount for the same route.
Any ideas what to fix on my code to make it work correctly?
Dim StrSQL As String = ""
Dim strWHERE As String = ""
Dim rs As SqlDataReader
Dim val As String = tripType.SelectedItem.Value
Dim suv As String = vpreferred.SelectedItem.Value
'Response.Write(val)
'Response.End()
If val = "hourly" Then
StrSQL = "select DISTINCT s.carTypes, s.Newfare as Fares, s.tip, (s.total+^SUV^) as total from vwhourly s "
strWHERE = " WHERE s.Hourly = @hourly"
If Len(suv) <> 0 Then
strWHERE += " AND s.carTypes = '"& suv & "'"
End If
Else
' StrSQL = "SELECT city, fare, (fare*(10/100)) AS Discount, (fare-Discount) * ^RT^ AS NewFare, (Newfare*(7/100)) AS tax, (newFare*(20/100)) AS tip, (Newfare + (Newfare*(7/100)) + (newFare*(20/100)) + ^SUV^) AS total FROM Rates "
StrSQL = "with CTE_Rates as " & _
"( " & _
" Select DISTINCT " & _
"City, " & _
" Fare " & _
" FROM Rates " & _
") " & _
"SELECT " & _
"City, " & _
"Fare, " & _
"Fare * 0.1 AS Discount, " & _
"(Fare * 0.9) * ^RT^ AS NewFare, " & _
"Fare * 0.063 AS Tax, " & _
"Fare * 0.18 AS Tip, " & _
"Fare * 1.143 + ^SUV^ AS Total " & _
"FROM CTE_Rates "
strWHERE = " Where city In('"& lblPreviewfromCityState.Text & "' , '"& lblPreviewDropOff.Text & "')"
End If
If suv = "SportUtilityVehicle" Then
StrSQL = Replace(StrSQL, "^SUV^", "12")
Else
StrSQL = Replace(StrSQL, "^SUV^", "0")
End If
If val Like "round_trip_*airport" Then
StrSQL = Replace(StrSQL, "^RT^", "2")
Else
StrSQL = Replace(StrSQL, "^RT^", "1")
End If
Dim conn As New SqlConnection(connStr)
Dim cmd As New SqlCommand(StrSQL & strWHERE, conn)
If val = "hourly" Then
cmd.Parameters.AddWithValue("@hourly", HourlyCharter.SelectedValue)
End If
Response.Write(StrSQL)
Response.End()
'Now open connection to the db
conn.Open()
'open recordset to receive db values
rs = cmd.ExecuteReader()
While rs.Read()
Dim tipValue As Decimal = rs("tip")
Dim totValue = rs("total")
Dim tp As String = [String].Format("{0:C}", tipValue)
Dim tot As String = [String].Format("{0:C}", totValue)
lblTip.Text = tp
lblTotal.Text = tot
End While