Beispiel #1
0
        /// <summary>
        /// 根据ID查询返回单条数据
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>

        #region
        public string Getmode(string ID)
        {
            ReturnObject Rejson = new ReturnObject();

            try
            {
                int Rid = Convert.ToInt32(ID);
                Rejson.Code      = "0";
                Rejson.Errmsg    = "Success";
                Rejson.GetModel  = MenuService.GetModel(s => s.ID == Rid);
                Rejson.GetInList = BtnRoleService.FindByParam(s => s.PageID == Rid);
            }
            catch (Exception ex)
            {
                Rejson.Code   = "1";
                Rejson.Errmsg = ex.Message;
            }
            return(ToJson(Rejson));
        }
Beispiel #2
0
        /// <summary>
        /// 递归方法
        /// </summary>
        /// <param name="ParenId"></param>
        /// <returns></returns>
        public string GetDGHtml(int ParenId)
        {
            string html = "";
            //通过传入的上级ID获取下级列表数据,如果存在则开始递归,如果不存在则跳出递归
            List <Mpr_Admin_Menu> ListMenu = MenuService.FindByParam(s => s.RightParent == ParenId);
            //获取全部按钮信息列表
            List <Mpr_Admin_ButtonRole> ButtonList = ButtonRoleService.FindAll();

            if (ListMenu.Count > 0)
            {
                //开始返回数据
                html += "<ul style=\"list-style:none;    margin-left: 5%;\">";
                //获取下级数据信息
                foreach (var item in ListMenu)
                {
                    html += "<li><input type=\"checkbox\" name=\"menuinfo\" id=\"menuinfo_" + ParenId + "_" + item.ID + "\" value=\"" + item.ID + "\" />";
                    html += item.RightName;
                    Mpr_Admin_Menu Exmod = MenuService.GetModel(s => s.RightParent == item.ID);
                    if (Exmod != null)
                    {
                        //继续尝试递归
                        html += GetDGHtml(item.ID);
                    }
                    html += "</li>";
                    if (item.IsButton == 1)
                    {
                        //判断当前是否存在对应按钮数据信息
                        List <Mpr_Admin_ButtonRole> NowButtonList = ButtonList.Where(s => s.PageID == item.ID).ToList();
                        if (NowButtonList.Count > 0)
                        {
                            //标示当前页面存在可操作按钮,开始拼接一个LI内的UL
                            html += "<li>";
                            html += "<ul style=\"list-style:none;margin-left:5px;\">";
                            foreach (var Buttonitem in NowButtonList)
                            {
                                html += "<li><input type=\"checkbox\" name=\"IsButton\" id=\"IsButton_" + Buttonitem.PageID + "_" + Buttonitem.ID + "\" value=\"" + Buttonitem.ID + "\" />" + Buttonitem.Operation + "</li>";
                            }
                            html += "</ul>";
                            html += "</li>";
                        }
                    }
                }
                html += "</ul>";
            }
            return(html);
        }