protected void SelectionChanged(object source, System.EventArgs e) { // Get a reference to the DropDownList; DropDownList ddl = (DropDownList)source; DataGridItem dgi = (DataGridItem)ddl.Parent.Parent; UserAccounts.UserInfo user = new UserAccounts.UserInfo(); user.Username = ((HyperLink)dgi.Cells[0].FindControl("UserLink")).Text; user.Role = (UserRole)(Convert.ToInt32(ddl.SelectedValue)); UsersControl.updateUserRole(user); bindGrid(); }
/// <summary> /// Handles the 'Yes' button click event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void YesButton_Click(object sender, System.EventArgs e) { // If the user clicked Yes, update their user account to "Canceled" // and redirect them to the default page. UserAccounts.UserInfo user = UserAccounts.getUserInfo(User.Identity.Name); user.Role = UserRole.Canceled; // Updates the user's role and sends them an email telling them // about the change. UsersControl.updateUserRole(user); UsersControl.logoutUser(); Response.Redirect("default.aspx", true); }
/// <summary> /// Handles Login button-click events. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoginBtn_Click(object sender, System.EventArgs e) { bool passwordVerified = false; try { // Verify password and set authorization cookie, if valid. passwordVerified = UserAccounts.VerifyPassword(txtUserName.Text, txtPassword.Text); UserAccounts.UserInfo user = UserAccounts.getUserInfo(txtUserName.Text); if (!passwordVerified) { // First, see if the username exists and if the password // is correct. If the username doesn't exist, or if // the password is incorrect, reset the fields and notify // user of the problem. lblMessage.Text = "Invalid username or password."; txtUserName.Text = ""; txtPassword.Text = ""; } else if (user.Role == UserRole.Disabled) { // If the username exists and the password was correct, // check to see if the account has been disabled. If so, // notify the user and reset the fields. lblMessage.Text = "That account has been disabled."; txtUserName.Text = ""; txtPassword.Text = ""; } else { // Keep track of redirection information string url = Request.QueryString["ReturnUrl"] == null ? "MyAccount.aspx" : FormsAuthentication.GetRedirectUrl(txtUserName.Text, false); if (user.Role == UserRole.Canceled) { // If this account had been Canceled, reset them to User status, // and redirect them to a page with the appropriate information. user.Role = UserRole.User; UsersControl.updateUserRole(user); Session["CancelType"] = "Reactivate"; url = "AccountCanceled.aspx?ReturnUrl=" + url; } Response.Redirect(url); } } catch (Exception ex) { lblMessage.Text = ex.Message; } }