예제 #1
0
        /// <summary>
        /// 删除模块
        /// </summary>
        /// <param name="id">模块ID</param>
        /// <returns>删除结果</returns>
        public ActionResult Delete(int?id)
        {
            string result = "accesss";

            if (string.IsNullOrEmpty(id.ToString()))
            {
                result = "请选择一个模块";
            }
            else
            {
                ModuleBll bll      = new ModuleBll();
                int       parentId = int.Parse(id.ToString());
                int       sonCount = bll.GetSonModule(parentId).Count;
                if (sonCount != 0)
                {
                    result = "有子模块不能删除";
                }
                else
                {
                    try
                    {
                        bll.DeleteMain(int.Parse(id.ToString()));
                    }
                    catch (Exception e)
                    {
                        result = "删除出错!";
                    }
                }
            }
            return(Json(result));
        }
예제 #2
0
        /// <summary>
        /// 递归拼出模块树
        /// </summary>
        /// <param name="modules">模块列表</param>
        /// <param name="ids">模块id列表</param>
        /// <returns>模块列表</returns>
        public List <JsTreeCheck> JsTreeAllModule(List <Module> modules, List <int> ids)
        {
            ModuleBll          bll        = new ModuleBll();
            List <JsTreeCheck> jsTreeList = new List <JsTreeCheck>();

            foreach (var module in modules)
            {
                State childState = new State();
                if (ids != null)
                {
                    if (ids.Contains(module.Id))
                    {
                        childState.selected = true;
                    }
                }
                JsTreeCheck jsTree = new JsTreeCheck
                {
                    id    = module.Id,
                    text  = module.ChineseName,
                    state = childState
                };
                var childrenModel = bll.GetSonModule(module.Id);
                if (childrenModel.Count != 0)
                {
                    jsTree.children = JsTreeAllModule(childrenModel, ids);
                }
                jsTreeList.Add(jsTree);
            }
            return(jsTreeList);
        }
예제 #3
0
        /// <summary>
        /// 模块树数据绑定
        /// </summary>
        /// <paramref name="ids">模块id列表</paramref>
        /// <returns>用户树数据</returns>
        public JsTreeCheck JsTreeAllModulewhithHead(List <int> ids)
        {
            ModuleBll   bll = new ModuleBll();
            JsTreeCheck jst = new JsTreeCheck();

            jst.id   = 0;
            jst.text = "所有模块";
            var childrenModule = bll.GetSonModule(0);

            jst.children = JsTreeAllModule(childrenModule, ids);
            return(jst);
        }