Example #1
0
 private void btnAddTopLevel_Click(object sender, EventArgs e)
 {
     if (!Save(false))
     {
         return;
     }
     try
     {
         MenuInfoBLL   bll   = new MenuInfoBLL();
         MenuInfoModel model = new MenuInfoModel();
         model.MenuId = -1;
         if (this.treeList1.Nodes.LastNode == null)
         {
             model.MenuSort = 10;
         }
         else
         {
             model.MenuSort = ((MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.Nodes.LastNode)).MenuSort + 10;
         }
         model.MenuParentId = 0;
         listMenuInfo.Add(model);
         this.treeList1.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        protected string GetMenuHtml()
        {
            UserInfo        currentUser = new UserInfoService().GetCurrentUser();
            List <MenuInfo> list        = new List <MenuInfo>();

            if (currentUser.LoginName.Equals("admin")) //Todo 正式上线时需屏蔽
            {
                list = new MenuInfoBLL().GetList();
            }
            else
            {
                list = new MenuInfoBLL().GetList(currentUser.UserId);
            }
            StringBuilder sb = new StringBuilder("<ul class=\"nav navbar-nav side-nav\">");

            if (list != null && list.Count > 0)
            {
                foreach (MenuInfo menu in list)
                {
                    AppendHtml(ref sb, menu);
                }
            }
            sb.Append("</ul>");
            return(sb.ToString());
        }
Example #3
0
 private void btnMoveDown_Click(object sender, EventArgs e)
 {
     if (!Save(false))
     {
         return;
     }
     if (this.treeList1.FocusedNode != null)
     {
         if (this.treeList1.FocusedNode.NextNode != null)
         {
             try
             {
                 MenuInfoModel nextModel = (MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode.NextNode);
                 MenuInfoModel curModel  = (MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode);
                 int           nextSort  = nextModel.MenuSort;
                 nextModel.MenuSort = curModel.MenuSort;
                 curModel.MenuSort  = nextSort;
                 MenuInfoBLL bll = new MenuInfoBLL();
                 bll.Update(nextModel);
                 bll.Update(curModel);
                 this.treeList1.RefreshDataSource();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             MessageBox.Show("已是最后节点,无法下移!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             return;
         }
     }
 }
        public IHttpActionResult Delete(string ID)
        {
            if (string.IsNullOrEmpty(ID))
            {
                return(BadRequest("非法请求!"));
            }

            try
            {
                MenuInfo model = new MenuInfoBLL().GetOne(ID);
                if (model == null)
                {
                    return(Ok("ok"));
                }

                model.IsDeleted = true;
                new MenuInfoBLL().Edit(model);

                return(Ok("ok"));
            }
            catch (Exception ex)
            {
                LogService.WriteErrorLog("SysFunctionController[Delete]", ex.ToString());
                return(BadRequest("异常!"));
            }
        }
        public IHttpActionResult Get(string ID, string Act)
        {
            MenuInfo model = new MenuInfoBLL().GetOne(ID);

            if (model != null)
            {
                MenuInfo parent = new MenuInfoBLL().GetOne(model.ParentID);
                model.ParentID = (parent == null?"": string.Format("{0}#{1}", parent.ID, parent.Name));
            }

            return(Ok(model));
        }
Example #6
0
 /// <summary>
 /// 获取左边的折叠菜单列表
 /// </summary>
 /// <returns></returns>
 public ActionResult LoadAccordionMenu()
 {
     if (CurrentUser.LoginUser != null)
     {
         List <MenuInfo> list = MenuInfoBLL.GetCurrentUserMenu(CurrentUser.LoginUser.AccountID, CurrentUser.LoginUser.UserCode);
         return(Content(list.ToJson().Replace("&nbsp;", "")));
     }
     else
     {
         return(RedirectToAction("Index", "Login"));
     }
 }
        public IHttpActionResult Get(string Name = "")
        {
            Expression <Func <CTMS_SYS_FUNCTION, bool> > predicate = p => p.ISDELETED == false;

            if (!string.IsNullOrEmpty(Name))
            {
                predicate = p => p.ISDELETED == false && p.MENUNAME.Contains(Name);
            }

            List <MenuInfo> list = new MenuInfoBLL().GetList(predicate);

            return(Ok(list));
        }
Example #8
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (!Save(false))
            {
                return;
            }
            try
            {
                MenuInfoBLL   bll   = new MenuInfoBLL();
                MenuInfoModel model = new MenuInfoModel();
                //model.MenuId = bll.GetMaxId();
                model.MenuId = -1;
                if (this.treeList1.FocusedNode == null)
                {
                    model.MenuSort     = 10;
                    model.MenuParentId = 0;
                    listMenuInfo.Add(model);
                }
                else
                {
                    if (this.treeList1.FocusedNode.ParentNode == null)
                    {
                        model.MenuParentId = 0;
                    }
                    else
                    {
                        model.MenuParentId = ((MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode.ParentNode)).MenuId;
                    }

                    if (this.treeList1.FocusedNode.PrevNode != null)
                    {
                        int prevSort = ((MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode.PrevNode)).MenuSort;
                        int curSort  = ((MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode)).MenuSort;
                        model.MenuSort = (prevSort + curSort) / 2;
                    }
                    else
                    {
                        int curSort = ((MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode)).MenuSort;
                        model.MenuSort = curSort / 2;
                    }
                    listMenuInfo.Add(model);
                }
                this.treeList1.RefreshDataSource();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #9
0
 private void updateChildNodeSort(TreeListNode node)
 {
     if (node.Nodes.Count > 0)
     {
         int         iSort = 10;
         MenuInfoBLL bll   = new MenuInfoBLL();
         for (int i = 0; i < node.Nodes.Count; i++)
         {
             MenuInfoModel model = (MenuInfoModel)treeList1.GetDataRecordByNode(node.Nodes[i]);
             model.MenuSort = iSort;
             bll.Update(model);
             iSort += 10;
             updateChildNodeSort(node.Nodes[i]);
         }
     }
 }
 /// <summary>
 /// 删除命令
 /// </summary>
 /// <returns></returns>
 public override void ExecuteDelete()
 {
     if (SelectedMenu != null)
     {
         if (SelectedMenu.SystemID == -1)
         {
             MessageBoxEx.Show("系统设置菜单不可删除", "提示", MessageBoxButtonType.OK);
             return;
         }
         MenuInfoBLL bll = new MenuInfoBLL();
         if (bll.DeleteMenuInfo(SelectedMenu))
         {
             MenuList.Remove(SelectedMenu);
             SelectedMenu = null;
             GlobalVariable.RefleshMenuInfo();
         }
     }
 }
Example #11
0
 private void btnRefreshSort_Click(object sender, EventArgs e)
 {
     if (!Save(false))
     {
         return;
     }
     if (this.treeList1.Nodes.Count > 0)
     {
         int         iSort = 10;
         MenuInfoBLL bll   = new MenuInfoBLL();
         for (int i = 0; i < treeList1.Nodes.Count; i++)
         {
             MenuInfoModel model = (MenuInfoModel)treeList1.GetDataRecordByNode(this.treeList1.Nodes[i]);
             model.MenuSort = iSort;
             bll.Update(model);
             iSort += 10;
             updateChildNodeSort(this.treeList1.Nodes[i]);
         }
         this.treeList1.RefreshDataSource();
     }
 }
Example #12
0
        private bool Save(bool bShowSuccess)
        {
            bool bSave = true;

            try
            {
                if (this.treeList1.FocusedNode != null)
                {
                    MenuInfoModel model = (MenuInfoModel)this.treeList1.GetDataRecordByNode(this.treeList1.FocusedNode);
                    if (string.IsNullOrEmpty(model.MenuName))
                    {
                        MessageBox.Show("菜单名称不允许为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(false);
                    }
                    if (model.MenuId <= 0)
                    {
                        int menuID = new MenuInfoBLL().Add(model);
                        model.MenuId = menuID;
                    }
                    else
                    {
                        new MenuInfoBLL().Update(model);
                    }
                    bSave = true;
                    if (bShowSuccess)
                    {
                        MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                //MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                bSave = false;
            }
            return(bSave);
        }