public ActionResult Add(ViewModels.CdAddDTO model) { ViewModels.Message rsp = new ViewModels.Message(); DAL.cd cddal = new DAL.cd(); Model.cd cdmodel = new Model.cd(); //cdmodel.gnid = gnmodel.gnid; cdmodel.cdjb = model.cdjb; cdmodel.xtid = model.xtid; cdmodel.sjcdid = model.sjcdid; cdmodel.cdmc = model.cdmc; cdmodel.xsjb = model.xsjb; cdmodel.bhcdgn = model.bhcdgn; cdmodel.icon = model.icon; cdmodel.dkfs = model.dkfs; if (model.cdjb == 3) { BLL.Gnbll gnbll = new BLL.Gnbll(); Model.gn gnmodel = gnbll.getGnModelByName(model.controller, model.action); cdmodel.gnid = gnmodel.gnid; } if (cddal.Add(cdmodel) > 0) { rsp.sno = 1; } else { rsp.sno = 2; rsp.msg = "数据操作失败"; } return(Json(rsp, JsonRequestBehavior.DenyGet)); }
/// <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); }
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)); }
public ActionResult GetCdByXtid(int xtid) { DAL.cd cddal = new DAL.cd(); List <Model.cd> cds = cddal.getCdByParentid(xtid); List <ViewModels.KeyValueDTO> kvs = new List <ViewModels.KeyValueDTO>(); foreach (var item in cds) { kvs.Add(new ViewModels.KeyValueDTO { key = item.cdid.ToString(), value = item.cdmc }); } return(Json(kvs, JsonRequestBehavior.AllowGet)); }