protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.UrlReferrer != null) { ViewState["url"] = Request.UrlReferrer.ToString(); } else { ViewState["url"] = "MenuList1.aspx"; } //删除一三级菜单 if (Request.QueryString["sid"] != null && Request.QueryString["sid"] != "") { int sid = int.Parse(Request.QueryString["sid"].ToString()); Tz888.BLL.Sys.SysMenuTab bll = new Tz888.BLL.Sys.SysMenuTab(); if (bll.Delete(sid)) { Response.Redirect(ViewState["url"].ToString()); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Msg", "<script>alert('删除失败!');location.href='" + ViewState["url"].ToString() + "';</script>", false); //Response.Write("<script>alert('删除失败');location.href='" + ViewState["url"].ToString() + "';</script>"); } } //删除二级菜单 if (Request.QueryString["sid2"] != null && Request.QueryString["sid2"] != "") { int sid = int.Parse(Request.QueryString["sid2"].ToString()); Tz888.BLL.Sys.SysMenuTab bll = new Tz888.BLL.Sys.SysMenuTab(); if (bll.Delete1(sid)) { Response.Redirect(ViewState["url"].ToString()); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "Msg", "<script>alert('删除失败!');location.href='" + ViewState["url"].ToString() + "';</script>", false); } } } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int sid = int.Parse(e.CommandArgument.ToString()); int check = 0; switch (e.CommandName) //壮态 { case "check": model = bll.GetModel(sid); if (model.SCheck == 0) { check = 1; } else { check = 0; } model.SCheck = check; bll.Update(model); databind(ViewState["order"].ToString()); break; case "xiaji": //添加一下级菜单 Response.Redirect("MenuList2.aspx?sid=" + sid); break; case "modefiy": //修改 Response.Redirect("ModefiyMenu.aspx?sid=" + sid + "&ji=1"); break; case "Del": //删除 bll.Delete(sid); databind(ViewState["order"].ToString()); break; default: break; } }