Advertisement
Guest User

Untitled

a guest
Apr 9th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7.  
  8. public partial class _Default : System.Web.UI.Page
  9. {
  10. protected void Page_Load(object sender, EventArgs e)
  11. {
  12.  
  13. }
  14.  
  15. protected void btnStart_Click(object sender, EventArgs e)
  16. {
  17. List<string> passwords = new List<string>
  18. {
  19. "KIPNUGGET",
  20. "BIGMAC",
  21. "MCHANS",
  22. "MCKROKET",
  23. "BIGTASTY"
  24. };
  25. string inputPassword = txtPassword.Text.ToUpper();
  26. string username = txtName.Text;
  27.  
  28. if (inputPassword.Length > 10)
  29. {
  30. lblError.Text = "Wachtwoord is te lang!";
  31. }
  32. else
  33. {
  34. for (int i = 0; i < passwords.Count; i++)
  35. {
  36. if (inputPassword == passwords[i])
  37. {
  38. pnlLogin.Visible = false;
  39. pnlConvert.Visible = true;
  40. lblGreet.Text = "<h2>Welkom " + username + "!</h2>";
  41. }
  42. else
  43. {
  44. lblError.Text = "Wachtwoord is onjuist!";
  45. }
  46. }
  47. }
  48. }
  49.  
  50. protected void ddlValue_SelectedIndexChanged(object sender, EventArgs e)
  51. {
  52. uint inputMeters = Convert.ToUInt32(txtMeter.Text);
  53. string inputValue = ddlValue.SelectedValue;
  54.  
  55. lblResult.Text = convertValue(inputMeters, inputValue);
  56. }
  57. string convertValue(uint meter, string value)
  58. {
  59. const float feet = 3.28084f;
  60. const float yard = 1.09361f;
  61. const float mile = 0.00062f;
  62.  
  63. float result = 0f;
  64. switch (value)
  65. {
  66. case "feet":
  67. result = meter * feet;
  68. break;
  69. case "yard":
  70. result = meter * yard;
  71. break;
  72. case "mile":
  73. result = meter * mile;
  74. break;
  75. }
  76. result = Convert.ToSingle(Math.Round(result, 2));
  77.  
  78. return Convert.ToString(result);
  79. }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement