I'm creating a simple bill calculator. When the bill button is clicked, a label will display the total. For some reason the button does not do anything. I'm not getting any errors in my code. Any help is appreciated.

    protected void btnCalc_Click(object sender, EventArgs e)
{
    Validate();
    if (IsValid)
    {
    }

    decimal tips = Convert.ToDecimal(txtTips.Text);
    decimal meals = Convert.ToDecimal(txtMeals.Text);
    decimal buffets = Convert.ToDecimal(txtBuffets.Text);
    string fname = txtFirstName.Text;
    string tnumber = txtTableNumber.Text;
    decimal mealsvalue = meals * 16.99M;
    decimal buffetsvalue = buffets * 11.5M;
    decimal tax = 0;
    decimal walkR = 0;
    decimal phoneR = 0;

    if (rblTax.SelectedValue == "Tax")
    {
       tax = .06M;
    }
    else
    {
    }


    if (rblReservation.SelectedValue == "Walk-in")
    {
        decimal subtotal = walkR + mealsvalue + buffetsvalue;
        decimal taxvalue = subtotal * tax;
        decimal total = walkR + mealsvalue + buffetsvalue + taxvalue + tips;
        lblSummary.Text = "First name is " + fname + " Table number is " + tnumber + " Walk in cost is " + walkR + " Cost of meals is " + mealsvalue +
        " Cost of buffets is " + buffetsvalue + " Tax is " + taxvalue + " Tip is " + tips + " Total is " + total;
    }
    else if (rblReservation.SelectedValue == "Phone")
    {
        phoneR = 3;
        decimal subtotal = phoneR + mealsvalue + buffetsvalue;
        decimal taxvalue = subtotal * tax;
        decimal total = phoneR + mealsvalue + buffetsvalue + tax + tips;
        lblSummary.Text = "First name is " + fname + " Table number is " + tnumber + " Phone reservation cost is " + phoneR + " Cost of meals is " + mealsvalue +
        " Cost of buffets is " + buffetsvalue + " Tax is " + tax + " Tip is " + tips + " Total is " + total;
    }
    else
    {
        lblSummary.Text = "Please fill out the information";
    }
}

button declaration

<asp:Button ID="btnCalc" runat="server" Text="Bill" />
    <br />
    <asp:Label ID="lblSummary" runat="server"></asp:Label>

Related posts

Recent Viewed