/* Opens Add Admin Modal on Add Button click * Opens Edit Admin Modal on Edit Button click * Deletes Admin on Delete Button click */ protected void AdminGridView_RowCommand(object sender, GridViewCommandEventArgs e) { // Int32 userTuid = Int32.Parse((string)Session["AuthorizedUserTUID"]); int index = Convert.ToInt32(e.CommandArgument); if (e.CommandName == "AddAdmin") { AddAdminModalError.Visible = false; AddAdminModalHeader.InnerText = "Add Administrator"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "addAdmin", "$('#addAdmin').modal();", true); AddAdminFirstNameTextBox.Text = String.Empty; AddAdminLastNameTextBox.Text = String.Empty; AddAdminTuidTextBox.Text = String.Empty; //AddCandidatePositionDropDownList.SelectedIndex = 0; //AddCandidatePartyDropDownList.SelectedIndex = 0; } else if (e.CommandName == "RemoveAdmin") { StoredProcedures sp = new StoredProcedures(); int id = Int32.Parse(AdministratorsGridView.Rows[index].Cells[0].Text); sp.DeleteAdmin(id); DisplayAdmins(); //sp.CreateLog(userTuid, "Deleted admin. (" + id + " )"); } else { //AddCandidateModalError.Visible = false; //CandidateInfoError.Visible = false; StoredProcedures sp = new StoredProcedures(); // AdminObject admin = new AdminObject(); int id = Int32.Parse(AdministratorsGridView.Rows[index].Cells[0].Text); DataSet ds = sp.GetAdminById(id); AddAdminTuidLabel.Visible = false; AddAdminTuidTextBox.Visible = false; EditAdminTuidLabel.Visible = true; EditAdminTuidHeaderLabel.Visible = true; EditAdminTuidLabel.Text = ds.Tables[0].Rows[0][0].ToString(); AddAdminFirstNameTextBox.Text = ds.Tables[0].Rows[0][1].ToString(); AddAdminLastNameTextBox.Text = ds.Tables[0].Rows[0][2].ToString(); AddAdminDeptDropDownList.SelectedValue = ds.Tables[0].Rows[0][4].ToString(); AddAdminAccessLevelDropDownList.SelectedValue = ds.Tables[0].Rows[0][3].ToString(); AddAdminModalHeader.InnerText = "Edit Administrator"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "addAdmin", "$('#addAdmin').modal();", true); } }
protected void LoginButton_Click(object sender, EventArgs e) { LoginErrorMessage.Visible = true; StoredProcedures sp = new StoredProcedures(); string category = (string)ViewState["Category"]; if (IsValid) { string anUser = AccessNetTextBox.Text; string RetVal = AuthenticateUser(anUser.ToUpper()); if (RetVal.Length > 0) { string TUID = (string)ViewState["TUID"]; if (TUID != null) { DataSet ds = sp.GetAdminById(Int64.Parse(TUID)); if (ds.Tables[0].Rows.Count > 0) { Session["isUserAuthenticated"] = true; bool incorrectUNPW = false; Session["incorrectUNPW"] = incorrectUNPW; LoginErrorMessage.Visible = false; string userType = ds.Tables[0].Rows[0][3].ToString(); Session["UserType"] = userType; if (category == "Admin" && userType == "Admin" ) { Response.Redirect("Admin.aspx", true); } if (category == "Admin" && userType != "Admin") { LoginErrorMessage.InnerText = "You don't have Administrator permissions."; LoginErrorMessage.Visible = true; } if (category == "User") { Response.Redirect("Home.aspx", true); } } else { LoginErrorMessage.InnerText = "You are not permitted to use the application."; LoginErrorMessage.Visible = true; } } } else { LoginErrorMessage.InnerText = "Invalid username or password."; LoginErrorMessage.Visible = true; } } else { bool incorrectUNPW = true; Session["incorrectUNPW"] = incorrectUNPW; LoginErrorMessage.Visible = false; } }