Beispiel #1
0
        /* 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);

            }
        }