protected void gvReaderInfo_RowDeleting(object sender, GridViewDeleteEventArgs e) { usermanage.ID = gvReaderInfo.DataKeys[e.RowIndex].Value.ToString(); usermanage.DeleteUser(usermanage); Response.Write("<script>alert('用户信息删除成功')</script>"); gvBind(); }
//private void LBtnNavigation_Click(object sender, System.EventArgs e) //{ // LinkButton btn = (LinkButton)sender; // switch (btn.CommandName) // { // case "First": // PageIndex = 0; // break; // case "Prev"://if( PageIndex > 0 ) // PageIndex = PageIndex - 1; // break; // case "Next"://if( PageIndex < PageCount -1) // PageIndex = PageIndex + 1; // break; // case "Last": // PageIndex = PageCount - 1; // break; // } // DgBind(); //} /// <summary> /// 控制导航按钮或数字的状态 /// </summary> //private void NavigationStateChange() //{ // if (PageCount <= 1) //小于或等于一页 // { // //this.LBtnFirst.Enabled = false; // //this.LBtnLast.Enabled = false; // this.LBtnNext.Enabled = false; // this.LBtnPrev.Enabled = false; // } // else //有多页 // { // if (PageCount == 0) // { // //this.LBtnFirst.Enabled = false; // //this.LBtnPrev.Enabled = false; // this.LBtnLast.Enabled = true; // this.LBtnNext.Enabled = true; // } // else // { // if (PageIndex == PageCount - 1) //最后一页 // { // //this.LBtnLast.Enabled = false; // this.LBtnNext.Enabled = false; // this.LBtnPrev.Enabled = true; // //this.LBtnFirst.Enabled = true; // } // else if (PageIndex == 0) // { // //this.LBtnFirst.Enabled = true; // this.LBtnPrev.Enabled = false; // this.LBtnNext.Enabled = true; // //this.LBtnLast.Enabled = true; // } // else //中间页 // { // //this.LBtnFirst.Enabled = true; // this.LBtnPrev.Enabled = true; // this.LBtnNext.Enabled = true; // //this.LBtnLast.Enabled = true; // } // } // } // if (RecordCount == 0) //如果没有记录会显示第一页 // { // this.LtlPageCount.Text = "0"; // } // else // { // this.LtlPageCount.Text = PageCount.ToString(); // } // if (RecordCount == 0) // { // this.LtlPageIndex.Text = "0"; // } // else // { // this.LtlPageIndex.Text = Convert.ToString(PageIndex + 1);//在有页数的情况下前台显示页数加1 // this.LtlPageSize.Text = PageSize.ToString(); // this.LtlRecordCount.Text = RecordCount.ToString(); // } //} //public int PageCount //页数 //{ // get { return this.dg.PageCount; } //} //public int PageSize //页大小 //{ // get { return this.dg.PageSize; } //} //public int PageIndex //页索引 //{ // set { this.dg.CurrentPageIndex = value; } // get { return this.dg.CurrentPageIndex; } //} //public int RecordCount //记录总数 //{ // set { recordCount = value; } // get { return recordCount; } //} protected void dg_DeleteCommand(object source, DataGridCommandEventArgs e) { int userid = Convert.ToInt32(e.Item.Cells[0].Text); if (UserManage.DeleteUser(userid)) { Common.WebTools.Alert(this, "删除成功!"); DgBind(); } else { Common.WebTools.Alert(this, "删除失败!"); } }
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); } } }
public bool DeleteUser(int userId) { return(_userManage.DeleteUser(userId)); }