M
Mike
Hey guys I am pulling my hair out on this problem!!!!! Any help or ideas or
comments on how to make this work I would be grateful! I have been working
on this for the past 4 days and nothing I do seems to get me any closer to
the solution. Below is a program that I am working on for a class project.
The original code was provided for us which is what I have below. What we
have to do is make the app run so that it allows the user to add additional
pizzas to the order form. I have tried making this go through a loop, add an
entry button for each pizza order but every time it calculates the order it
clears out what I have or won't display anything. Please can anyone give me
some help here????
Thank you!
Mike
'OBJECT DESCRIPTION SETTING
'ddlPizzaSize (default properties)
'chkPeperoni Text "Pepperoni"
'chkSausage Text "Sausage"
'chkGreenPeppers Text "Green Peppers"
'chkBlackOlives Text "Black Olives"
'chkHam Text "Ham"
'chkOnions Text "Onions"
'txtNewReleases Text (Empty)
'txtStandard Text (Empty)
'btnCalculate Text "Calculate Total
and Generate Coupon"
'lblInstructions Visable False
' Boarderstyle Double
' Text "Print
and cut out your coupon to save!"
' (The pnlCoupon below is a grid layout panel from the Toolbox's HTML
Section)
'lblOrderDesc Font X-small
'lblPizzaTotal Text "<p align="right">$0.00"
'lblMovieTotal Text "<p align="right">$0.00"
'lblSubTotal Text "<p align="right">$0.00"
'lblTax Text "<p align="right">$0.00"
'lblDelivery Text "<p align="right">$0.00"
'lblTotal Text "<p align="right">$0.00"
'
'lblDiscount Text "<p align="right">$0.00"
' ForeColor Red
'
'lblYourPrice Text "<p align="right">$0.00"
' ForeColor Red
' Font Larger
'
'lblExpDate Text "<p align="right"> Offer valid
through 04/01/9999
' Font Smaller
'
Public Class WebForm1
Inherits System.Web.UI.Page
'Business logic constants
Const MEDIUM_BASE_PRICE As Double = 8.99
Const LARGE_BASE_PRICE As Double = 10.99
Const GIGANTIC_BASE_PRICE As Double = 12.99
Const TOPPING_PRICE As Double = 0.99
Const STANDARD_VIDEO_PRICE As Double = 1.95
Const NEW_RELEASE_VIDEO_PRICE As Double = 2.95
Const DELIVERY_FEE As Double = 2.0
Const TAX_RATE As Double = 0.065
Const COUPON_DISCOUNT As Double = 0.1 '(10 Percent)
Const FREE_DELIVERY_AMOUNT As Double = 20
'HTML constants
Const HTML_LEFT_ALIGN As String = "<p align=""left""> "
Const HTML_RIGHT_ALIGN As String = "<p align=""right""> "
Const HTML_INDENT As String = "        "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim liNone, liMedium, liLarge, liGigantic As ListItem
'On first showing, fill ListBox, setExpDate and set Discount description
If Not IsPostBack Then
ddlPizzaSize.Items.Clear()
liNone = New ListItem
liNone.Text = "None"
liNone.Value = "None"
liMedium = New ListItem
liMedium.Text = "Medium (8"") -- " & FormatCurrency(MEDIUM_BASE_PRICE)
liMedium.Value = "Medium"
liLarge = New ListItem
liLarge.Text = "Large (10"")-- " & FormatCurrency(LARGE_BASE_PRICE)
liLarge.Value = "Large"
liGigantic = New ListItem
liGigantic.Text = "Gigantic (12"") -- " &
FormatCurrency(GIGANTIC_BASE_PRICE)
liGigantic.Value = "Gigantic"
ddlPizzaSize.Items.Add(liNone)
ddlPizzaSize.Items.Add(liMedium)
ddlPizzaSize.Items.Add(liLarge)
ddlPizzaSize.Items.Add(liGigantic)
ddlPizzaSize.SelectedIndex = 0
lblExpDate.Text = HTML_RIGHT_ALIGN & "Offer valid through " & _
FormatDateTime(Today().AddDays(7))
lblDiscountDesc.Text = FormatPercent(COUPON_DISCOUNT, 0) & " discount:"
End If
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click
Dim Desc As String
Dim ToppingDesc As String
Dim HasToppingFlag As Boolean
Dim NewReleaseCount As Integer
Dim StandardCount As Integer
Dim Pizzas As Double
Dim Movies As Double
Dim SubTotal As Double
Dim DeliveryFee As Double
Dim Total As Double
Dim Discount As Double
Dim YourPrice As Double
'Build a string with HTML formatted text describing the order
Desc = ""
If ddlPizzaSize.SelectedItem.Value <> "None" Then
ToppingDesc = ""
HasToppingFlag = False
If chkPepperoni.Checked Then
ToppingDesc &= HTML_INDENT & "pepperoni <br>"
HasToppingFlag = True
End If
If chkSausage.Checked Then
ToppingDesc &= HTML_INDENT & "sausage <br>"
HasToppingFlag = True
End If
If chkHam.Checked Then
ToppingDesc &= HTML_INDENT & "ham <br>"
HasToppingFlag = True
End If
If chkBlackOlives.Checked Then
ToppingDesc &= HTML_INDENT & "black olives <br>"
HasToppingFlag = True
End If
If chkGreenPeppers.Checked Then
ToppingDesc &= HTML_INDENT & "green peppers <br>"
HasToppingFlag = True
End If
If chkOnions.Checked Then
ToppingDesc &= HTML_INDENT & "onions <br>"
HasToppingFlag = True
End If
If HasToppingFlag = False Then
Desc = HTML_LEFT_ALIGN & "A " & ddlPizzaSize.SelectedItem.Value & _
" cheese pizza. <br>"
Else
Desc = HTML_LEFT_ALIGN & "A " & ddlPizzaSize.SelectedItem.Value & _
" pizza with the following toppings: <br>" & ToppingDesc & "<br>"
End If
End If
NewReleaseCount = Val(txtNewReleases.Text)
If NewReleaseCount <> 0 Then
Desc &= NewReleaseCount.ToString & " new release video"
If NewReleaseCount > 1 Then Desc &= "s"
Desc &= "<br>"
End If
StandardCount = Val(txtStandard.Text)
If StandardCount <> 0 Then
Desc &= StandardCount.ToString & " standard video"
If StandardCount > 1 Then Desc &= "s"
Desc &= "<br>"
End If
'Assign the built string to the label
lblOrderDesc.Text = Desc
'Determine the Pizza SubTotal using business logic values
Select Case ddlPizzaSize.SelectedItem.Value
Case "None" : Pizzas = 0.0
Case "Medium" : Pizzas = MEDIUM_BASE_PRICE
Case "Large" : Pizzas = LARGE_BASE_PRICE
Case "Gigantic" : Pizzas = GIGANTIC_BASE_PRICE
End Select
If chkPepperoni.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkSausage.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkHam.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkBlackOlives.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkGreenPeppers.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkOnions.Checked Then Pizzas = Pizzas + TOPPING_PRICE
lblPizzaTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(Pizzas)
'Determine the movie subtotal using business logic values
Movies = NewReleaseCount * NEW_RELEASE_VIDEO_PRICE
Movies = Movies + StandardCount * STANDARD_VIDEO_PRICE
lblMovieTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(Movies)
'Determine the order subtotal, tax, delivery, and total
SubTotal = Pizzas + Movies
lblSubTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(SubTotal)
lblTax.Text = HTML_RIGHT_ALIGN & FormatCurrency(SubTotal * TAX_RATE)
If SubTotal > FREE_DELIVERY_AMOUNT Then
DeliveryFee = 0
Else
DeliveryFee = DELIVERY_FEE
End If
lblDelivery.Text = HTML_RIGHT_ALIGN & FormatCurrency(DeliveryFee)
Total = SubTotal + (SubTotal * TAX_RATE) + DeliveryFee
lblTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(Total)
'Determine the discount and the coupon price
Discount = Total * COUPON_DISCOUNT
lblDiscount.Text = HTML_RIGHT_ALIGN & FormatCurrency(Discount)
YourPrice = Total - Discount
lblYourPrice.Text = HTML_RIGHT_ALIGN & FormatCurrency(YourPrice)
'Make the coupon and instructions visible
pnlCoupon.Visible = True
lblInstructions.Visible = True
End Sub
End Class
comments on how to make this work I would be grateful! I have been working
on this for the past 4 days and nothing I do seems to get me any closer to
the solution. Below is a program that I am working on for a class project.
The original code was provided for us which is what I have below. What we
have to do is make the app run so that it allows the user to add additional
pizzas to the order form. I have tried making this go through a loop, add an
entry button for each pizza order but every time it calculates the order it
clears out what I have or won't display anything. Please can anyone give me
some help here????
Thank you!
Mike
'OBJECT DESCRIPTION SETTING
'ddlPizzaSize (default properties)
'chkPeperoni Text "Pepperoni"
'chkSausage Text "Sausage"
'chkGreenPeppers Text "Green Peppers"
'chkBlackOlives Text "Black Olives"
'chkHam Text "Ham"
'chkOnions Text "Onions"
'txtNewReleases Text (Empty)
'txtStandard Text (Empty)
'btnCalculate Text "Calculate Total
and Generate Coupon"
'lblInstructions Visable False
' Boarderstyle Double
' Text "Print
and cut out your coupon to save!"
' (The pnlCoupon below is a grid layout panel from the Toolbox's HTML
Section)
'lblOrderDesc Font X-small
'lblPizzaTotal Text "<p align="right">$0.00"
'lblMovieTotal Text "<p align="right">$0.00"
'lblSubTotal Text "<p align="right">$0.00"
'lblTax Text "<p align="right">$0.00"
'lblDelivery Text "<p align="right">$0.00"
'lblTotal Text "<p align="right">$0.00"
'
'lblDiscount Text "<p align="right">$0.00"
' ForeColor Red
'
'lblYourPrice Text "<p align="right">$0.00"
' ForeColor Red
' Font Larger
'
'lblExpDate Text "<p align="right"> Offer valid
through 04/01/9999
' Font Smaller
'
Public Class WebForm1
Inherits System.Web.UI.Page
'Business logic constants
Const MEDIUM_BASE_PRICE As Double = 8.99
Const LARGE_BASE_PRICE As Double = 10.99
Const GIGANTIC_BASE_PRICE As Double = 12.99
Const TOPPING_PRICE As Double = 0.99
Const STANDARD_VIDEO_PRICE As Double = 1.95
Const NEW_RELEASE_VIDEO_PRICE As Double = 2.95
Const DELIVERY_FEE As Double = 2.0
Const TAX_RATE As Double = 0.065
Const COUPON_DISCOUNT As Double = 0.1 '(10 Percent)
Const FREE_DELIVERY_AMOUNT As Double = 20
'HTML constants
Const HTML_LEFT_ALIGN As String = "<p align=""left""> "
Const HTML_RIGHT_ALIGN As String = "<p align=""right""> "
Const HTML_INDENT As String = "        "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim liNone, liMedium, liLarge, liGigantic As ListItem
'On first showing, fill ListBox, setExpDate and set Discount description
If Not IsPostBack Then
ddlPizzaSize.Items.Clear()
liNone = New ListItem
liNone.Text = "None"
liNone.Value = "None"
liMedium = New ListItem
liMedium.Text = "Medium (8"") -- " & FormatCurrency(MEDIUM_BASE_PRICE)
liMedium.Value = "Medium"
liLarge = New ListItem
liLarge.Text = "Large (10"")-- " & FormatCurrency(LARGE_BASE_PRICE)
liLarge.Value = "Large"
liGigantic = New ListItem
liGigantic.Text = "Gigantic (12"") -- " &
FormatCurrency(GIGANTIC_BASE_PRICE)
liGigantic.Value = "Gigantic"
ddlPizzaSize.Items.Add(liNone)
ddlPizzaSize.Items.Add(liMedium)
ddlPizzaSize.Items.Add(liLarge)
ddlPizzaSize.Items.Add(liGigantic)
ddlPizzaSize.SelectedIndex = 0
lblExpDate.Text = HTML_RIGHT_ALIGN & "Offer valid through " & _
FormatDateTime(Today().AddDays(7))
lblDiscountDesc.Text = FormatPercent(COUPON_DISCOUNT, 0) & " discount:"
End If
End Sub
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnCalculate.Click
Dim Desc As String
Dim ToppingDesc As String
Dim HasToppingFlag As Boolean
Dim NewReleaseCount As Integer
Dim StandardCount As Integer
Dim Pizzas As Double
Dim Movies As Double
Dim SubTotal As Double
Dim DeliveryFee As Double
Dim Total As Double
Dim Discount As Double
Dim YourPrice As Double
'Build a string with HTML formatted text describing the order
Desc = ""
If ddlPizzaSize.SelectedItem.Value <> "None" Then
ToppingDesc = ""
HasToppingFlag = False
If chkPepperoni.Checked Then
ToppingDesc &= HTML_INDENT & "pepperoni <br>"
HasToppingFlag = True
End If
If chkSausage.Checked Then
ToppingDesc &= HTML_INDENT & "sausage <br>"
HasToppingFlag = True
End If
If chkHam.Checked Then
ToppingDesc &= HTML_INDENT & "ham <br>"
HasToppingFlag = True
End If
If chkBlackOlives.Checked Then
ToppingDesc &= HTML_INDENT & "black olives <br>"
HasToppingFlag = True
End If
If chkGreenPeppers.Checked Then
ToppingDesc &= HTML_INDENT & "green peppers <br>"
HasToppingFlag = True
End If
If chkOnions.Checked Then
ToppingDesc &= HTML_INDENT & "onions <br>"
HasToppingFlag = True
End If
If HasToppingFlag = False Then
Desc = HTML_LEFT_ALIGN & "A " & ddlPizzaSize.SelectedItem.Value & _
" cheese pizza. <br>"
Else
Desc = HTML_LEFT_ALIGN & "A " & ddlPizzaSize.SelectedItem.Value & _
" pizza with the following toppings: <br>" & ToppingDesc & "<br>"
End If
End If
NewReleaseCount = Val(txtNewReleases.Text)
If NewReleaseCount <> 0 Then
Desc &= NewReleaseCount.ToString & " new release video"
If NewReleaseCount > 1 Then Desc &= "s"
Desc &= "<br>"
End If
StandardCount = Val(txtStandard.Text)
If StandardCount <> 0 Then
Desc &= StandardCount.ToString & " standard video"
If StandardCount > 1 Then Desc &= "s"
Desc &= "<br>"
End If
'Assign the built string to the label
lblOrderDesc.Text = Desc
'Determine the Pizza SubTotal using business logic values
Select Case ddlPizzaSize.SelectedItem.Value
Case "None" : Pizzas = 0.0
Case "Medium" : Pizzas = MEDIUM_BASE_PRICE
Case "Large" : Pizzas = LARGE_BASE_PRICE
Case "Gigantic" : Pizzas = GIGANTIC_BASE_PRICE
End Select
If chkPepperoni.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkSausage.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkHam.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkBlackOlives.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkGreenPeppers.Checked Then Pizzas = Pizzas + TOPPING_PRICE
If chkOnions.Checked Then Pizzas = Pizzas + TOPPING_PRICE
lblPizzaTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(Pizzas)
'Determine the movie subtotal using business logic values
Movies = NewReleaseCount * NEW_RELEASE_VIDEO_PRICE
Movies = Movies + StandardCount * STANDARD_VIDEO_PRICE
lblMovieTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(Movies)
'Determine the order subtotal, tax, delivery, and total
SubTotal = Pizzas + Movies
lblSubTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(SubTotal)
lblTax.Text = HTML_RIGHT_ALIGN & FormatCurrency(SubTotal * TAX_RATE)
If SubTotal > FREE_DELIVERY_AMOUNT Then
DeliveryFee = 0
Else
DeliveryFee = DELIVERY_FEE
End If
lblDelivery.Text = HTML_RIGHT_ALIGN & FormatCurrency(DeliveryFee)
Total = SubTotal + (SubTotal * TAX_RATE) + DeliveryFee
lblTotal.Text = HTML_RIGHT_ALIGN & FormatCurrency(Total)
'Determine the discount and the coupon price
Discount = Total * COUPON_DISCOUNT
lblDiscount.Text = HTML_RIGHT_ALIGN & FormatCurrency(Discount)
YourPrice = Total - Discount
lblYourPrice.Text = HTML_RIGHT_ALIGN & FormatCurrency(YourPrice)
'Make the coupon and instructions visible
pnlCoupon.Visible = True
lblInstructions.Visible = True
End Sub
End Class