Beispiel #1
0
        /// <summary>
        /// 获取用户有权限的菜单
        /// </summary>
        /// <param name="yhsession"></param>
        /// <returns></returns>
        public static List <Model.cd> getAuthCd(YhSession yhsession)
        {
            DAL.gn gndal = new DAL.gn();
            //获取用户有权限的功能
            int[] gnids = gndal.getGnidsByYhmc(yhsession.yh.yhmc);
            //string gnidsStr = String.Join(",", gnids);
            List <int> gnidList = gnids.ToList();

            //通过用户有权限的功能得到用户有权限的菜单
            DAL.cd cddal = new DAL.cd();
            //List<Model.cd> cds = cddal.getModelList(" gnid in(" + gnidsStr + ")");
            List <Model.cd> cds = cddal.getModelList("");

            List <Model.cd> yhcds = cds.FindAll(delegate(Model.cd cd)
            {
                if (cd.gnid.HasValue)
                {
                    return(gnidList.Contains(cd.gnid.Value));
                }
                else
                {
                    return(false);
                }
            });
            //获取上级菜单并添加菜单记录
            List <Model.cd> x1 = cds.FindAll(delegate(Model.cd cd)
            {
                return(yhcds.FindAll(b => b.sjcdid == cd.cdid).Count > 0);
            });

            yhcds.AddRange(x1);


            return(yhcds);
        }
Beispiel #2
0
        public ActionResult List(int cdjb = 0)
        {
            DAL.cd          cddal = new DAL.cd();
            List <Model.cd> cds   = cddal.getModelList("");

            if (cdjb > 0)
            {
                ViewBag.cdjb = cdjb;
                cds          = cds.Where(b => b.cdjb == cdjb).ToList();
            }
            return(View(cds));
        }