Advertisement
DevUModerator

Untitled

Jul 4th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3.  
  4. }
  5.  
  6. protected void widthTextBox_TextChanged(object sender, EventArgs e)
  7. {
  8. if (!EntryError()) return;
  9.  
  10. }
  11.  
  12. double width = 0;
  13. double length = 0;
  14. double height = 0;
  15.  
  16.  
  17. private bool EntryError()
  18.  
  19. {
  20. if (!double.TryParse(widthTextBox.Text.Trim(), out width)) return false;
  21. if (!double.TryParse(heightTextBox.Text.Trim(), out height)) return false;
  22. if (!double.TryParse(lengthTextBox.Text.Trim(), out length)) length = 1;
  23.  
  24. double volume = width * height * length;
  25. calculateTheCost(volume);
  26.  
  27. return true;
  28.  
  29.  
  30. }
  31.  
  32. private void calculateTheCost(double volume)
  33.  
  34.  
  35. {
  36. double postageMultipler = getPostageMultiplier() * volume;
  37.  
  38. displayResult(postageMultipler);
  39.  
  40. }
  41.  
  42. private double getPostageMultiplier()
  43. {
  44. if (groundRadioButton.Checked) return .15;
  45. if (airRadioButton.Checked) return .25;
  46. if (nextDayRadioButton.Checked) return .45;
  47. else return 0;
  48. }
  49.  
  50. private void displayResult(double postageMultipler)
  51. {
  52. resultLabel.Text = string.Format("Your parcel will cost {0:C} to ship", postageMultipler.ToString());
  53.  
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement