public ActionResult Create(SystemMenuInfo model) { bool issuc = false; string _funs = Request["Functions"]; model.Functions = _funs; int id = menuMgr.Create(model); if (id > 0) { issuc = true; } MsgInfo msgInfo = new MsgInfo(); if (issuc) { msgInfo.IsError = false; msgInfo.Msg = "操作成功!"; msgInfo.MsgNo = (int)ErrorEnum.成功; } else { msgInfo.IsError = true; msgInfo.Msg = "操作失败!"; msgInfo.MsgNo = (int)ErrorEnum.失败; } return(Content(JsonConvert.SerializeObject(msgInfo))); }
public bool Delete(SystemMenuInfo model) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("delete from SystemMenu"); sb.Append(" where Id=@Id"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@Id", DbType.Int32, model.Id); return(db.ExecuteNonQuery(dbCommand) < 1 ? false : true); }
private SystemMenuInfo FillList(IDataReader dataReader) { SystemMenuInfo model = new SystemMenuInfo(); object ojb; ojb = dataReader["Id"]; if (ojb != null && ojb != DBNull.Value) { model.Id = ( int)(ojb); } ojb = dataReader["MenuName"]; if (ojb != null && ojb != DBNull.Value) { model.MenuName = ( string)(ojb); } ojb = dataReader["MenuAddr"]; if (ojb != null && ojb != DBNull.Value) { model.MenuAddr = ( string)(ojb); } ojb = dataReader["ParentId"]; if (ojb != null && ojb != DBNull.Value) { model.ParentId = ( int)(ojb); } ojb = dataReader["IsLeft"]; if (ojb != null && ojb != DBNull.Value) { model.IsLeft = ( bool)(ojb); } ojb = dataReader["IsTop"]; if (ojb != null && ojb != DBNull.Value) { model.IsTop = ( bool)(ojb); } ojb = dataReader["Functions"]; if (ojb != null && ojb != DBNull.Value) { model.Functions = ( string)(ojb); } ojb = dataReader["IsMenu"]; if (ojb != null && ojb != DBNull.Value) { model.IsMenu = ( bool)(ojb); } ojb = dataReader["MenuLevel"]; if (ojb != null && ojb != DBNull.Value) { model.MenuLevel = ( int)(ojb); } return(model); }
public SystemMenuInfo GetByMenuAddr(string MenuAddr) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("select * from SystemMenu where MenuAddr=@MenuAddr"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@MenuAddr", DbType.String, MenuAddr); SystemMenuInfo model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = FillList(dataReader); } } return(model); }
public bool Update(SystemMenuInfo model) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("update SystemMenu set "); sb.Append("MenuName=@MenuName,MenuAddr=@MenuAddr,ParentId=@ParentId,IsLeft=@IsLeft,IsTop=@IsTop,Functions=@Functions,IsMenu=@IsMenu,MenuLevel=@MenuLevel"); sb.Append(" where Id=@Id"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@Id", DbType.Int32, model.Id); db.AddInParameter(dbCommand, "@MenuName", DbType.String, model.MenuName); db.AddInParameter(dbCommand, "@MenuAddr", DbType.String, model.MenuAddr); db.AddInParameter(dbCommand, "@ParentId", DbType.Int32, model.ParentId); db.AddInParameter(dbCommand, "@IsLeft", DbType.Boolean, model.IsLeft); db.AddInParameter(dbCommand, "@IsTop", DbType.Boolean, model.IsTop); db.AddInParameter(dbCommand, "@Functions", DbType.String, model.Functions); db.AddInParameter(dbCommand, "@IsMenu", DbType.Boolean, model.IsMenu); db.AddInParameter(dbCommand, "@MenuLevel", DbType.Int32, model.MenuLevel); return(db.ExecuteNonQuery(dbCommand) < 1 ? false : true); }
public int Create(SystemMenuInfo model) { Database db = DBHelper.CreateDataBase(); StringBuilder sb = new StringBuilder(); sb.Append("insert into SystemMenu("); sb.Append("MenuName,MenuAddr,ParentId,IsLeft,IsTop,Functions,IsMenu,MenuLevel"); sb.Append(") values("); sb.Append("@MenuName,@MenuAddr,@ParentId,@IsLeft,@IsTop,@Functions,@IsMenu,@MenuLevel);SELECT @@IDENTITY;"); DbCommand dbCommand = db.GetSqlStringCommand(sb.ToString()); db.AddInParameter(dbCommand, "@MenuName", DbType.String, model.MenuName); db.AddInParameter(dbCommand, "@MenuAddr", DbType.String, model.MenuAddr); db.AddInParameter(dbCommand, "@ParentId", DbType.Int32, model.ParentId); db.AddInParameter(dbCommand, "@IsLeft", DbType.Boolean, model.IsLeft); db.AddInParameter(dbCommand, "@IsTop", DbType.Boolean, model.IsTop); db.AddInParameter(dbCommand, "@Functions", DbType.String, model.Functions); db.AddInParameter(dbCommand, "@IsMenu", DbType.Boolean, model.IsMenu); db.AddInParameter(dbCommand, "@MenuLevel", DbType.Int32, model.MenuLevel); int id = Convert.ToInt32(db.ExecuteScalar(dbCommand)); return(id); }
/// <summary> /// 获得系统菜单列表 /// </summary> /// <param name="htmlHelper"></param> /// <returns></returns> public static IList <SystemMenuInfo> GetSystemMenuList(this HtmlHelper htmlHelper) { //获取角色用户下所有菜单 IList <SystemMenuInfo> curMenuList = new List <SystemMenuInfo>(); List <MenuEntity> moduleMenus = new List <MenuEntity>(); try { var CurrentUser = CacheManager.Instance.CurrentUser; if (CurrentUser == null) { return(curMenuList); } AuthBC bc = new AuthBC(); IList <MenuEntity> moduleList = bc.GetMenusByLoginName(CurrentUser.Account); //抓取父菜单Id List <MenuEntity> fatherIds = new List <MenuEntity>(); foreach (var item in moduleList) { MenuEntity entity = new AuthBC().GetMenuByMenuId(item.Menu_FatherId); fatherIds.Add(entity); } var ml = fatherIds.Distinct().ToList(); if (ml != null && ml.Count() > 0) { moduleMenus = ml.OrderBy(p => p.Menu_Order).ToList(); for (int i = 0; i < moduleMenus.Count; i++) { var curModule = moduleMenus[i]; SystemMenuInfo tempMenu = new SystemMenuInfo { MenuId = curModule.Menu_Id.ToString(), MenuName = curModule.Menu_Title, Url = curModule.Menu_Url, SubMenus = new List <SystemMenuInfo>() }; var subl = moduleList.Where(p => p.Menu_FatherId == curModule.Menu_Id.ToString()); if (subl == null) { tempMenu.SubMenus.Add(new SystemMenuInfo()); } var subMenus = subl.OrderBy(a => a.Menu_Order).ToList(); foreach (var item in subMenus) { SystemMenuInfo tempSubMenu = new SystemMenuInfo { MenuId = item.Menu_Id.ToString(), MenuName = item.Menu_Title, Url = item.Menu_Url }; tempMenu.SubMenus.Add(tempSubMenu); } if (!curMenuList.Any(p => p.MenuName == tempMenu.MenuName)) { curMenuList.Add(tempMenu); } } return(curMenuList); } else { return(curMenuList); } } catch (Exception ex) { return(curMenuList); } }
public bool Delete(SystemMenuInfo model) { return(dal.Delete(model)); }
public bool Update(SystemMenuInfo model) { return(dal.Update(model)); }
public int Create(SystemMenuInfo model) { int id = dal.Create(model); return(id); }