我无法在应用程序中为小计返回正确的值。用户选择他们想要的旅游类型,并输入要购买的票数。按“计算成本”按钮后,将显示小计,税额和最终总计。
我的小计方法代码和btnCost_Click如下:
Private Sub btnCost_Click(sender As Object, e As EventArgs) Handles btnCost.Click
Dim intTicketQuantity As Integer
Dim blnNumberOfTicketsIsValid As Boolean = False
Dim blnCheckForRad As Boolean = False
Dim decSubTotal As Decimal
Dim decTotalTax As Decimal
Dim intTourType As Integer
blnNumberOfTicketsIsValid = ValidateNumberOfTickets()
If (blnNumberOfTicketsIsValid) Then
intTicketQuantity = Convert.ToInt32(txtTickets.Text)
intTicketQuantity = cboTourType.SelectedIndex
If (intTicketQuantity > 0) Then
intTourType = cboTourType.SelectedIndex
End If
Select Case intTourType
Case 0
decSubTotal = Story(intTourType, intTicketQuantity)
decTotalTax = Tax(decSubTotal)
Case 1
decSubTotal = Battleground(intTourType, intTicketQuantity)
decTotalTax = Tax(decSubTotal)
Case 2
decSubTotal = Mission(intTourType, intTicketQuantity)
decTotalTax = Tax(decSubTotal)
End Select
ShowAll(decSubTotal, decTotalTax)
End If
End Sub
Private Function Story(ByVal intTourType As Integer, intTicketQuantity As Integer) As Decimal
Dim decSubTotal As Decimal = 0D
If (radWeekday.Checked = True) Then
decSubTotal = 19D * intTicketQuantity * (1 - _decDiscount)
ElseIf (radWeekend.Checked = True) Then
decSubTotal = 19D * intTicketQuantity
End If
Return decSubTotal
End Function
Private Function Battleground(ByVal intTourType As Integer, intTicketQuantity As Integer) As Decimal
Dim decSubTotal As Decimal = 0D
If (radWeekday.Checked = True) Then
decSubTotal = 29D * intTicketQuantity * (1 - _decDiscount)
ElseIf (radWeekend.Checked = True) Then
decSubTotal = 29D * intTicketQuantity
End If
Return decSubTotal
End Function
Private Function Mission(ByVal intTourType As Integer, intTicketQuantity As Integer) As Decimal
Dim decSubTotal As Decimal = 0D
If (radWeekday.Checked = True) Then
decSubTotal = 49D * intTicketQuantity * (1 - _decDiscount)
ElseIf (radWeekend.Checked = True) Then
decSubTotal = 49D * intTicketQuantity
End If
Return decSubTotal
End Function