Ejemplo n.º 1
0
    protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        GridViewRow gRow   = (GridViewRow)((Control)e.CommandSource).Parent.Parent;
        string      userId = GridView1.DataKeys[gRow.RowIndex].Value.ToString();

        if (e.CommandName == "Edit")
        {
            Response.Redirect("UserEdit.aspx?UserId=" + userId + "&Type=1");
        }
        if (e.CommandName == "Del")
        {
            if (UserManage.DeleteUser(int.Parse(userId)))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "DeleteSucess", "alert('删除成功!');", true);
                LoadData(1);
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "DeleteError", "alert('删除失败!');", true);
            }
        }
        if (e.CommandName == "ResumePassword")
        {
            UserInfo userInfo      = new UserInfo();
            string   beginPassword = GridView1.Rows[gRow.RowIndex].Cells[1].Text;
            userInfo.JobNo    = GridView1.Rows[gRow.RowIndex].Cells[1].Text;
            userInfo.Password = SHA1.GetSHA1Password(beginPassword);
            if (UserManage.ChangePassword(userInfo))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ResumeSucess", "alert('恢复密码成功!');", true);
                LoadData(1);
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ResumeError", "alert('恢复密码失败!');", true);
            }
        }
    }