/// <summary> /// 获取单个菜单信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public string OneFunction(string id) { ResultInfo <List <object> > result = new ResultInfo <List <object> >(); var bll = new MultiColorPen.BLL.sys_menuinfo(); var dt = bll.GetList("menucode='" + id + "'").Tables[0]; result.IsSucceed = true; result.Message = "获取成功!"; result.Entity = JsonHelper.DataTableToList(dt); DataTable mb_dt = bll.GetMenyButton(id); List <object> mb_list = new List <object>(); for (int i = 0; i < mb_dt.Rows.Count; i++) { mb_list.Add(mb_dt.Rows[i]["btncode"].ToString()); } result.Extend = mb_list; return(JsonConvert.SerializeObject(result)); }
/// <summary> /// 菜单添加/修改保存 /// </summary> /// <param name="json"></param> /// <returns></returns> public string FunctionSave(string json) { ResultInfo result = new ResultInfo(false); JObject jo = JObject.Parse(json); LoginInfo userInfo = SessionHelper.ReadSession <LoginInfo>(SessionKeys.LoginInfoKey); var bll = new MultiColorPen.BLL.sys_menuinfo(); //新增 if (jo["did"].ToString() == "-1") { string code = bll.GetMaxNo(); var model = new MultiColorPen.Model.sys_menuinfo { pmenucode = jo["pmenucode"].ToString(), menucode = code, menuname = jo["menuname"].ToString(), menuicon = jo["menuicon"].ToString(), linkaddress = jo["linkaddress"].ToString(), isenable = 1, createtime = DateTime.Now, createman = userInfo.UserName }; if (!string.IsNullOrEmpty(jo["menusort"].ToString())) { model.menusort = int.Parse(jo["menusort"].ToString()); } else { model.menusort = 99; } var list = jo["btncode"]; List <string> btncode = new List <string>(); if (list != null && list.Count() > 0) { for (int i = 0; i < list.Count(); i++) { btncode.Add(list[i].ToString()); } } if (bll.Add(model, btncode) > 0) { result.IsSucceed = true; result.Message = "Operation Successful!"; PublicClass.AddLog("Operating", "Add System Function" + model.menuname + "!"); } else { result.IsSucceed = false; result.Message = "Save Failed!"; } } //修改 else { int id = int.Parse(jo["did"].ToString()); var umodel = bll.GetModel(id); umodel.pmenucode = jo["pmenucode"].ToString(); umodel.menuname = jo["menuname"].ToString(); umodel.menuicon = jo["menuicon"].ToString(); if (!string.IsNullOrEmpty(jo["menusort"].ToString())) { umodel.menusort = int.Parse(jo["menusort"].ToString()); } else { umodel.menusort = 99; } umodel.linkaddress = jo["linkaddress"].ToString(); umodel.updateman = userInfo.UserName; umodel.updatetime = DateTime.Now; var list = jo["btncode"]; List <string> btncode = new List <string>(); if (list != null && list.Count() > 0) { for (int i = 0; i < list.Count(); i++) { btncode.Add(list[i].ToString()); } } if (bll.Update(umodel, btncode)) { result.IsSucceed = true; result.Message = "Operating Successful!"; PublicClass.AddLog("Operating", "Edit System Function" + umodel.menuname + "!"); } else { result.IsSucceed = false; result.Message = "Save Failed!"; } } return(JsonConvert.SerializeObject(result)); }