All pastes #899488 Raw Edit

Something

public text v1 · immutable
·published 2008-02-11 04:16 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void closeButton_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void calcButton_Click(object sender, EventArgs e)
        {
            string pizzaSize;
            decimal pizzaCost;
            string delivery;
            int addToppings;
            const int toppings = .99M;
                      
            pizzaSize = sizeTextBox.Text;
            delivery = deliveryTextBox.Text;
            addToppings = Convert.ToInt32(addtoppingsTextBox.Text);
                     
            if (pizzaSize == "small")
            {
                pizzaCost = 4.99M;
            }
            else if (pizzaSize == "medium")
            {
                pizzaCost = 7.99M;
            }
            else
            {
                pizzaCost = 11.99M;
            }
            
            if (delivery == "yes")
            {
                pizzaCost += 3;
            }

            if (pizzaSize == "")
            {
                MessageBox.Show("The pizza size field is required.",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                sizeTextBox.Focus();
                return;
            }

            if (delivery == "")
            {
                MessageBox.Show("The delivery field is required.",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                deliveryTextBox.Focus();
                return;
            }

            if (addtoppingsTextBox.Text.Length < 1)
            {
                MessageBox.Show("The additional toppings field is required.",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                addtoppingsTextBox.Focus();
                return;
            }

            if (pizzaSize != "small" &&
                pizzaSize != "medium" &&
                pizzaSize != "large")
            {
                MessageBox.Show("Pizza size must be small, medium, or large.",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                sizeTextBox.Clear();
                sizeTextBox.Focus();
                return;
            }

            if (delivery != "yes" &&
                delivery != "no")
            {
                MessageBox.Show("Delivery must be yes or no.",
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                deliveryTextBox.Clear();
                deliveryTextBox.Focus();
                return;
            }         

            sizeTextBox.Text.ToUpper();
            deliveryTextBox.Text.ToUpper();

            pizzaCost += (decimal) (addToppings * toppings);

            pizzaCostTextBox.Text = pizzaCost.ToString("C");
               
        }

        private void clearButton_Click(object sender, EventArgs e)
        {
            sizeTextBox.Text = "";
            deliveryTextBox.Text = "";
            addtoppingsTextBox.Text = "";
            sizeTextBox.Focus();
        }
    }
}