Exemplo n.º 1
0
 /// <summary>
 /// 初始化菜单递归
 /// </summary>
 /// <param name="xml"></param>
 private void init_list(XElement xml)
 {
     foreach (var item in xml.Elements())
     {
         if (item.Attribute("Code") != null && item.Attribute("Code").Value != "")
         {
             string     code  = item.Attribute("Code").Value;
             SystemMenu _menu = _SystemMenuService.GetWhere(m => m.Code.ToLower() == code.ToLower()).FirstOrDefault();
             if (_menu != null)
             {
                 //修改
                 init(item, _menu);
                 _SystemMenuService.Edit(_menu);
             }
             else
             {
                 //添加
                 _menu = new SystemMenu();
                 init(item, _menu);
                 _SystemMenuService.Add(_menu);
             }
             _SystemMenuService.Save();
             init_list(item);
         }
     }
 }
Exemplo n.º 2
0
        public ActionResult AddMenu(SystemMenu entity)
        {
            var result = ResModelFactory.ResDefault();

            try
            {
                entity.ID           = Guid.NewGuid().ToString();
                entity.CreateDate   = DateTime.Now;
                entity.CreateUserId = CurrentUser.Id;
                entity.IsShow       = true;
                SystemMenuService service = new SystemMenuService();
                service.Add(entity);
            }
            catch (Exception ex)
            {
                result = ResModelFactory.ResError(ex.Message);
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var  choose = this.ddlFirst.SelectedValue;
            Guid id     = Guid.Empty;

            if (choose == "2")
            {
                id = Guid.Parse(this.ddlSecond.SelectedValue);
            }
            else if (choose == "3")
            {
                id = Guid.Parse(this.ddlThird.SelectedValue);
            }
            var model = new Model.SystemMenus
            {
                SystemMenus_Title    = this.txtName.Text,
                SystemMenus_Link     = this.txtLink.Text,
                SystemMenus_Icon     = this.txtIcon.Text,
                SystemMenus_ParentId = id
            };


            var       res = smSvc.Add(model);
            ReturnMsg rm  = res > 0 ? new ReturnMsg()
            {
                Code    = StatusCode.Ok,
                Message = "新增权限成功",
                Data    = null
            } : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "新增权限失败",
                Data    = null
            };

            Session["Msg"] = rm;
            Response.Redirect("SystemMenus_List.aspx");
        }
Exemplo n.º 4
0
        /// <summary>
        /// 保存按钮的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSumbit_Click(object sender, EventArgs e)
        {
            //父级菜单id在存值之前,我们需要对它进行判断
            int pid;

            if (this.ddlLevel.SelectedValue == "0")
            {
                pid = 0;
            }
            else if (this.ddlLevel.SelectedValue == "1")
            {
                pid = int.Parse(this.ddlParentTitle.SelectedValue);
            }
            else
            {
                pid = int.Parse(this.ddlSonTitle.SelectedValue);
            }

            Model.SystemMenu model = new Model.SystemMenu
            {
                Title    = this.MenuTitle.Text,
                Link     = this.MenuLink.Text,
                ParentId = pid
            };

            int rs = menuSvc.Add(model);

            if (rs > 0)
            {
                Response.Write("<script>alert('添加成功');location.href='SystemMenuList.aspx'</script>");
            }
            else
            {
                Response.Write("<script>alert('添加失败');location.href='SystemMenuList.aspx'</script>");
            }
        }