protected void btnSave_Click(object sender, EventArgs e) { List<RoleMenuInfo> roleMenuList = GetRoleMenuModel(); RoleMenuBll roleMenuBll = new RoleMenuBll(); roleMenuBll.DeleteRoleMenuByRoleId(RoleId); roleMenuBll.AddRoleMenu(roleMenuList); Response.Redirect("RoleList.aspx?token=" + Session["token"]); }
private void InitMenuList() { MenuBll menuBll = new MenuBll(); List<MenuInfo> menuList = menuBll.GetMenuListByParentId(0); RoleMenuBll roleMenuBll = new RoleMenuBll(); List<RoleMenuInfo> roleMenuList = roleMenuBll.GetRoleMenuListByRoleId(RoleId); if (menuList != null) { RoleBll roleBll = new RoleBll(); RoleInfo roleInfo = roleBll.GetRoleById(RoleId); if (roleInfo == null) { return; } foreach (MenuInfo menuInfo in menuList) { Label lbl = new Label(); lbl.Text = menuInfo.MenuName; trMenuList.Controls.Add(lbl); List<MenuInfo> subMenuList = menuBll.GetMenuListByParentId(menuInfo.MenuId); CheckBoxList cbList = new CheckBoxList(); cbList.ID = "menuInfo_" + menuInfo.MenuId; cbList.RepeatDirection = RepeatDirection.Horizontal; cbList.RepeatColumns = 4; cbList.DataSource = subMenuList; cbList.DataTextField = "MenuName"; cbList.DataValueField = "MenuId"; cbList.DataBind(); foreach (ListItem li in cbList.Items) { if (roleMenuList != null) { foreach (RoleMenuInfo roleMenu in roleMenuList) { if (li.Value == roleMenu.MenuId.ToString()) { li.Selected = true; } } } } trMenuList.Controls.Add(cbList); } } }