protected void Page_Load(object sender, EventArgs e) { allusers = (ArrayList)Application["users"]; user = Session["currentUser"]; userlvl = Session["currentLevel"]; Label_login.Text = "Logged in as: " + user; if (userlvl.ToString() == "Magician") { Magician currentm = (Magician)user; TextBoxSal.Visible = false; Userinfo.Text = "<li> Name: " + currentm.Name + "</li>" + "<li> Level: " + userlvl.ToString() + "</li>" + "<li> Password: "******"</li>" + "<li> Favorite tricks: " + currentm.displayTricks() + " </ li > "; for (int i = 0; i < allusers.Count; i++) { if (allusers[i].GetType().Name == "Magician") { ListBoxUsers.Items.Add(allusers[i].ToString()); } } } else { Staff currents = (Staff)user; TextBoxFavTricks.Visible = false; Userinfo.Text = "<li> Name: " + currents.Name + "</li>" + "<li> Level: " + userlvl.ToString() + "</li>" + "<li> Password: "******"</li>" + "<li> Salary: " + currents.Salary + "</li>"; foreach (var user in allusers) { ListBoxUsers.Items.Add(user.ToString()); } } }
protected void ButtonUpdate_Click(object sender, EventArgs e) { for (int i = 0; i < allusers.Count; i++) { if (allusers[i].ToString() == user.ToString()) { if (userlvl.ToString() == "Magician") { Magician m = (Magician)allusers[i]; m.Name = TextBoxName.Text; m.Password = TextBoxPass.Text; m.AddFavoriteTrick(TextBoxFavTricks.Text); user = m; Session["currentUser"] = user; Response.Redirect("Admin.aspx"); } else { Staff s = (Staff)allusers[i]; s.Name = TextBoxName.Text; s.Password = TextBoxPass.Text; s.Salary = Convert.ToInt32(TextBoxSal.Text); user = s; Session["currentUser"] = user; Response.Redirect("Admin.aspx"); } } } }
protected void Button_sp_signup_Click(object sender, EventArgs e) { if (RadioButtonList_usertype.SelectedValue == "Magician") { Magician m = new Magician(Convert.ToInt32(userarray.Count + 1), TextBox_sp_username.Text, TextBox_sp_password.Text, 1); userarray.Add(m); Response.Redirect("Index.aspx"); } else { Staff s = new Staff(Convert.ToInt32(userarray.Count + 1), TextBox_sp_username.Text, TextBox_sp_password.Text, 2); userarray.Add(s); Response.Redirect("Index.aspx"); } }