Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Stationary2
- {
- public partial class Stationary : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void TextBox1_TextChanged(object sender, EventArgs e)
- {
- }
- class Prices
- {
- public const double blackink = 0.45;
- public const double redink = 0.50;
- public const double bluewb = 1.20;
- public const double blackwb = 1.10;
- public const double a4 = 2.50;
- }
- protected void btnPurchase_Click(object sender, EventArgs e)
- {
- // Variables
- double blackink, redink, bluewb, blackwb, a4, total1, total2, total3, total4, total5, overallTotal;
- string name, address1, address2, postCode;
- // Assigning Variables
- name = txtName.Text;
- address1 = txtAddress1.Text;
- address2 = txtAddress2.Text;
- postCode = txtpostCode.Text;
- // Conversion
- blackink = Convert.ToDouble(txtBlackInk.Text);
- redink = Convert.ToDouble(txtRedInk.Text);
- bluewb = Convert.ToDouble(txtBlueWB.Text);
- blackwb = Convert.ToDouble(txtBlackWB.Text);
- a4 = Convert.ToDouble(txtA4.Text);
- // If Statement - Black Ink pen
- if (blackink == 0)
- {
- total1 = 0;
- }
- else
- {
- total1 = blackink * Prices.blackink;
- }//end
- // If Statement - Red Ink pen
- if (redink == 0)
- {
- total2 = 0;
- }
- else
- {
- total2 = redink * Prices.redink;
- }//end
- // If Statement - Blue Whiteboard marker
- if (bluewb == 0)
- {
- total3 = 0;
- }
- else
- {
- total3 = bluewb * Prices.bluewb;
- }//end
- // If Statement - Black Whiteboard marker
- if (blackwb == 0)
- {
- total4 = 0;
- }
- else
- {
- total4 = blackwb * Prices.blackwb;
- }//end
- // If Statement - A4
- if (a4 == 0)
- {
- total5 = 0;
- }
- else
- {
- total5 = a4 * Prices.a4;
- }//end
- overallTotal = total1 + total2 + total3 + total4 + total5;
- if (overallTotal > 50.00)
- {
- lblPrice.Text = "You recieved a 5% discount, your overall total is £" + overallTotal * 0.95;
- }
- else
- {
- lblPrice.Text = "Your overall total is £" + overallTotal;
- };
- lblCusName.Text = "Thank you, " + name;
- lblDelivery.Text = "Your stationery items will be sent to " + address1 + ", " + address2 + ". " + postCode;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement