protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int menu_bid = Common.TypeHelper.ObjectToInt(Request["menubid"], 0); int menu_sid = Common.TypeHelper.ObjectToInt(Request["menusid"], 0); if (menu_bid > 0 && Request.Cookies["iGroupId"] != null && Request.Cookies["iGroupId"].Value != "") { int gid = Common.TypeHelper.ObjectToInt(Request.Cookies["iGroupId"].Value, 0); DataTable dt = menudal.GetMenuListForSid(gid, menu_bid); StringBuilder menu_str = new StringBuilder(); string url = ""; string sel = ""; for (int i = 0; i < dt.Rows.Count; i++) { sel = menu_sid == Common.TypeHelper.ObjectToInt(dt.Rows[i]["MenuId"], 0) ? "2" : ""; url = dt.Rows[i]["MenuUrl"].ToString(); url = url.IndexOf('?') > -1 ? url + "&menubid=" + menu_bid + "&menusid=" + dt.Rows[i]["MenuId"] + "":url + "?menubid=" + menu_bid + "&menusid=" + dt.Rows[i]["MenuId"] + ""; menu_str.AppendLine("<div class='leftmenu" + sel + "'><a href='" + url + "'>" + dt.Rows[i]["MenuName"].ToString() + "</a></div>"); } this.menu.InnerHtml = menu_str.ToString(); Db.MenuDal m = new Db.MenuDal(); this.bname.Text = m.GetModel(menu_bid).MenuName; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.menuList.DataSource = dal.GetList(" and bid =0 order by orderid desc"); this.menuList.DataBind(); this.ddlBid.DataSource = dal.GetList(" and bid =0 order by orderid desc"); this.ddlBid.DataTextField = "MenuName"; this.ddlBid.DataValueField = "MenuId"; this.ddlBid.DataBind(); this.ddlBid.Items.Add(new ListItem("一级菜单", "0")); this.ddlBid.SelectedValue = "0"; //删除 if (Request["action"] == "del") { int id = Common.TypeHelper.ObjectToInt(Request["id"], 0); if (dal.IsHave(id) > 0) { JScript.alert("p", "该菜单下有子菜单,不能删除", "admin_Menu.aspx?" + menuUrl, this.Page); } else { if (dal.Del(id) > 0) { JScript.Loction("p", "admin_Menu.aspx?" + menuUrl, this.Page); } } } ///添加 if (Request["action"] == "add") { int bid = Common.TypeHelper.ObjectToInt(Request["bid"], 0); this.ddlBid.SelectedValue = bid.ToString(); } //修改 if (Request["action"] == "update") { int id = Common.TypeHelper.ObjectToInt(Request["id"], 0); Model.MenuInfoModel model = dal.GetModel(id); this.txtMenuName.Text = model.MenuName; this.txtMenuUrl.Text = model.MenuUrl; this.txtOrderId.Text = model.OrderId.ToString(); this.ddlBid.SelectedValue = model.Bid.ToString(); this.radStatusId.SelectedValue = model.StatusId.ToString(); this.hidId.Value = id.ToString(); } } }
protected void Button1_Click(object sender, EventArgs e) { string menu_list_id = Request["menu_select_id"]; int id = Common.TypeHelper.ObjectToInt(this.hidId.Value, 0); if (id > 0) { Model.UserInfoGroupModel model = new Model.UserInfoGroupModel(); model.GroupName = this.txtgroupName.Text; model.GroupId = id; if (string.IsNullOrEmpty(menu_list_id) == false) { string[] menu_arr_list = menu_list_id.Split(','); Model.PermissionModel m = null; foreach (var item in menu_arr_list) { int mid = Common.TypeHelper.ObjectToInt(item, 0); int mbid = dal.GetModel(mid).Bid; m = new Model.PermissionModel(); m.MenuId = mid; m.MenuBid = mbid; model.PerList.Add(m); } } int j = group.Update(model); if (j > 0) { JScript.alert("ok", "操作成功", "Admin_Group.aspx?id=" + id + "&action=update", this.Page); } else { JScript.alert("ok", "出现异常", this.Page); } } else { if (menu_list_id == "") { JScript.alertBack("ok", "请选择菜单", this.Page); } else { Model.UserInfoGroupModel model = new Model.UserInfoGroupModel(); model.GroupName = this.txtgroupName.Text; string[] menu_arr_list = menu_list_id.Split(','); Model.PermissionModel m = null; foreach (var item in menu_arr_list) { int mid = Common.TypeHelper.ObjectToInt(item, 0); int mbid = dal.GetModel(mid).Bid; m = new Model.PermissionModel(); m.MenuId = mid; m.MenuBid = mbid; model.PerList.Add(m); } int j = group.Add(model); if (j > 0) { JScript.alert("ok", "操作成功", "Admin_Group.aspx?", this.Page); } else { JScript.alert("ok", "出现异常", this.Page); } } } }