Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. namespace Stationary2
  2. {
  3. public partial class Stationary : System.Web.UI.Page
  4. {
  5. protected void Page_Load(object sender, EventArgs e)
  6. {
  7.  
  8. }
  9.  
  10. protected void TextBox1_TextChanged(object sender, EventArgs e)
  11. {
  12.  
  13. }
  14. class Prices
  15. {
  16. public const double blackink = 0.45;
  17. public const double redink = 0.50;
  18. public const double bluewb = 1.20;
  19. public const double blackwb = 1.10;
  20. public const double a4 = 2.50;
  21.  
  22. }
  23. protected void btnPurchase_Click(object sender, EventArgs e)
  24. {
  25. // Variables
  26. double blackink, redink, bluewb, blackwb, a4, total1, total2, total3, total4, total5, overallTotal;
  27.  
  28. string name, address1, address2, postCode;
  29.  
  30. // Assigning Variables
  31. name = txtName.Text;
  32.  
  33. address1 = txtAddress1.Text;
  34.  
  35. address2 = txtAddress2.Text;
  36.  
  37. postCode = txtpostCode.Text;
  38.  
  39. // Conversion
  40. blackink = Convert.ToDouble(txtBlackInk.Text);
  41.  
  42. redink = Convert.ToDouble(txtRedInk.Text);
  43.  
  44. bluewb = Convert.ToDouble(txtBlueWB.Text);
  45.  
  46. blackwb = Convert.ToDouble(txtBlackWB.Text);
  47.  
  48. a4 = Convert.ToDouble(txtA4.Text);
  49.  
  50. // If Statement - Black Ink pen
  51. if (blackink == 0)
  52. {
  53. total1 = 0;
  54. }
  55. else
  56. {
  57. total1 = blackink * Prices.blackink;
  58. }//end
  59.  
  60. // If Statement - Red Ink pen
  61. if (redink == 0)
  62. {
  63. total2 = 0;
  64. }
  65. else
  66. {
  67. total2 = redink * Prices.redink;
  68. }//end
  69.  
  70. // If Statement - Blue Whiteboard marker
  71. if (bluewb == 0)
  72. {
  73. total3 = 0;
  74. }
  75. else
  76. {
  77. total3 = bluewb * Prices.bluewb;
  78. }//end
  79.  
  80. // If Statement - Black Whiteboard marker
  81. if (blackwb == 0)
  82. {
  83. total4 = 0;
  84. }
  85. else
  86. {
  87. total4 = blackwb * Prices.blackwb;
  88. }//end
  89.  
  90. // If Statement - A4
  91. if (a4 == 0)
  92. {
  93. total5 = 0;
  94. }
  95. else
  96. {
  97. total5 = a4 * Prices.a4;
  98. }//end
  99.  
  100. overallTotal = total1 + total2 + total3 + total4 + total5;
  101.  
  102. if (overallTotal > 50.00)
  103. {
  104. lblPrice.Text = "You recieved a 5% discount, your overall total is £" + overallTotal * 0.95;
  105. }
  106. else
  107. {
  108. lblPrice.Text = "Your overall total is £" + overallTotal;
  109. };
  110.  
  111.  
  112.  
  113. lblCusName.Text = "Thank you, " + name;
  114. lblDelivery.Text = "Your stationery items will be sent to " + address1 + ", " + address2 + ". " + postCode;
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement