Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void btnStart_Click(object sender, EventArgs e)
- {
- List<string> passwords = new List<string>
- {
- "KIPNUGGET",
- "BIGMAC",
- "MCHANS",
- "MCKROKET",
- "BIGTASTY"
- };
- string inputPassword = txtPassword.Text.ToUpper();
- string username = txtName.Text;
- if (inputPassword.Length > 10)
- {
- lblError.Text = "Wachtwoord is te lang!";
- }
- else
- {
- for (int i = 0; i < passwords.Count; i++)
- {
- if (inputPassword == passwords[i])
- {
- pnlLogin.Visible = false;
- pnlConvert.Visible = true;
- lblGreet.Text = "<h2>Welkom " + username + "!</h2>";
- }
- else
- {
- lblError.Text = "Wachtwoord is onjuist!";
- }
- }
- }
- }
- protected void ddlValue_SelectedIndexChanged(object sender, EventArgs e)
- {
- uint inputMeters = Convert.ToUInt32(txtMeter.Text);
- string inputValue = ddlValue.SelectedValue;
- lblResult.Text = convertValue(inputMeters, inputValue);
- }
- string convertValue(uint meter, string value)
- {
- const float feet = 3.28084f;
- const float yard = 1.09361f;
- const float mile = 0.00062f;
- float result = 0f;
- switch (value)
- {
- case "feet":
- result = meter * feet;
- break;
- case "yard":
- result = meter * yard;
- break;
- case "mile":
- result = meter * mile;
- break;
- }
- result = Convert.ToSingle(Math.Round(result, 2));
- return Convert.ToString(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement