Exemplo n.º 1
0
        public bool AddMenu(MenuEntity menuEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();

            sqlCommandText.Append("@JournalID");
            sqlCommandText.Append(", @PMenuID");
            sqlCommandText.Append(", @MenuName");
            sqlCommandText.Append(", @MenuUrl");
            sqlCommandText.Append(", @IconUrl");
            sqlCommandText.Append(", @SortID");
            sqlCommandText.Append(", @MenuType");
            sqlCommandText.Append(", @GroupID");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.Menu ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString()));

            db.AddInParameter(cmd,"@JournalID",DbType.Int64,menuEntity.JournalID);
            db.AddInParameter(cmd,"@PMenuID",DbType.Int32,menuEntity.PMenuID);
            db.AddInParameter(cmd,"@MenuName",DbType.AnsiString,menuEntity.MenuName);
            db.AddInParameter(cmd,"@MenuUrl",DbType.AnsiString,menuEntity.MenuUrl);
            db.AddInParameter(cmd,"@IconUrl",DbType.AnsiString,menuEntity.IconUrl);
            db.AddInParameter(cmd,"@SortID",DbType.Int32,menuEntity.SortID);
            db.AddInParameter(cmd,"@MenuType",DbType.Byte,menuEntity.MenuType);
            db.AddInParameter(cmd,"@GroupID",DbType.Byte,menuEntity.GroupID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Exemplo n.º 2
0
        public bool UpdateMenu(MenuEntity menuEntity)
        {
            bool flag = false;
            StringBuilder whereCommandText = new StringBuilder();
            whereCommandText.Append("  MenuID=@MenuID");
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append(" JournalID=@JournalID");
            sqlCommandText.Append(", PMenuID=@PMenuID");
            sqlCommandText.Append(", MenuName=@MenuName");
            sqlCommandText.Append(", MenuUrl=@MenuUrl");
            sqlCommandText.Append(", IconUrl=@IconUrl");
            sqlCommandText.Append(", SortID=@SortID");
            sqlCommandText.Append(", MenuType=@MenuType");
            sqlCommandText.Append(", GroupID=@GroupID");
            sqlCommandText.Append(", IsContentMenu=@IsContentMenu");
            sqlCommandText.Append(", Status=@Status");
            sqlCommandText.Append(", AddDate=@AddDate");

            DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.Menu SET {0} WHERE  {1}",sqlCommandText.ToString(),whereCommandText.ToString()));

            db.AddInParameter(cmd,"@MenuID",DbType.Int64,menuEntity.MenuID);
            db.AddInParameter(cmd,"@JournalID",DbType.Int64,menuEntity.JournalID);
            db.AddInParameter(cmd,"@PMenuID",DbType.Int32,menuEntity.PMenuID);
            db.AddInParameter(cmd,"@MenuName",DbType.AnsiString,menuEntity.MenuName);
            db.AddInParameter(cmd,"@MenuUrl",DbType.AnsiString,menuEntity.MenuUrl);
            db.AddInParameter(cmd,"@IconUrl",DbType.AnsiString,menuEntity.IconUrl);
            db.AddInParameter(cmd,"@SortID",DbType.Int32,menuEntity.SortID);
            db.AddInParameter(cmd,"@MenuType",DbType.Byte,menuEntity.MenuType);
            db.AddInParameter(cmd,"@GroupID",DbType.Byte,menuEntity.GroupID);
            db.AddInParameter(cmd,"@Status",DbType.Byte,menuEntity.Status);
            db.AddInParameter(cmd, "@IsContentMenu", DbType.Boolean, menuEntity.IsContentMenu);
            db.AddInParameter(cmd,"@AddDate",DbType.DateTime,menuEntity.AddDate);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Exemplo n.º 3
0
 public MenuEntity MakeMenu(DataRow dr)
 {
     MenuEntity menuEntity=null;
     if(dr!=null)
     {
          menuEntity=new MenuEntity();
          menuEntity.MenuID = (Int64)dr["MenuID"];
          menuEntity.JournalID = (Int64)dr["JournalID"];
          menuEntity.PMenuID = (Int32)dr["PMenuID"];
          menuEntity.MenuName = (String)dr["MenuName"];
          menuEntity.MenuUrl = (String)dr["MenuUrl"];
          menuEntity.IconUrl = (String)dr["IconUrl"];
          menuEntity.SortID = (Int32)dr["SortID"];
          menuEntity.MenuType = (Byte)dr["MenuType"];
          menuEntity.GroupID = (Byte)dr["GroupID"];
          menuEntity.Status = (Byte)dr["Status"];
          menuEntity.IsContentMenu = (Boolean)dr["IsContentMenu"];
          menuEntity.AddDate = (DateTime)dr["AddDate"];
     }
     return menuEntity;
 }
Exemplo n.º 4
0
 public List<MenuEntity> MakeMenuList(IDataReader dr)
 {
     List<MenuEntity> list=new List<MenuEntity>();
     while (dr.Read())
     {
         MenuEntity menuEntity = new MenuEntity();
         menuEntity.MenuID = (Int64)dr["MenuID"];
         menuEntity.JournalID = (Int64)dr["JournalID"];
         menuEntity.PMenuID = (Int32)dr["PMenuID"];
         menuEntity.MenuName = (String)dr["MenuName"];
         menuEntity.MenuUrl = (String)dr["MenuUrl"];
         menuEntity.IconUrl = (String)dr["IconUrl"];
         menuEntity.SortID = (Int32)dr["SortID"];
         menuEntity.MenuType = (Byte)dr["MenuType"];
         menuEntity.GroupID = (Byte)dr["GroupID"];
         menuEntity.Status = (Byte)dr["Status"];
         menuEntity.IsContentMenu = (Boolean)dr["IsContentMenu"];
         menuEntity.AddDate = (DateTime)dr["AddDate"];
         list.Add(menuEntity);
     }
     dr.Close();
     return list;
 }
Exemplo n.º 5
0
        /// <summary>
        /// 获取指定角色拥有的菜单
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public IList<MenuEntity> GetHaveRightMenuList(RoleMenuQuery query)
        {
            string sql = "SELECT DISTINCT m.MenuID,m.MenuName,m.MenuUrl,m.PMenuID,m.IconUrl,m.SortID,m.IsContentMenu FROM dbo.RoleMenu r WITH(NOLOCK),dbo.Menu m WITH(NOLOCK) WHERE m.JournalID=@JournalID AND m.GroupID=@GroupID AND m.JournalID=r.JournalID AND r.RoleID {0} AND r.MenuID=m.MenuID AND m.Status=1 ORDER BY m.SortID ASC,m.MenuID ASC";
            StringBuilder sqlCommandText = new StringBuilder();
            if (query.GroupID == (Byte)EnumMemberGroup.Editor)
            {
                if (query.RoleID != null)
                {
                    sqlCommandText.AppendFormat(sql, "= " + query.RoleID);
                }
                else if (query.RoleIDList != null && query.RoleIDList.Count > 0)
                {
                    if (query.RoleIDList.Count == 1)
                    {
                        sqlCommandText.AppendFormat(sql, "= " + query.RoleIDList[0]);
                    }
                    else
                    {
                        sqlCommandText.AppendFormat(sql, " IN (" + string.Join(",", query.RoleIDList) + ")");
                    }
                }
                else
                {
                    sqlCommandText.AppendFormat(sql, " = 0");
                }
            }
            else
            {
                sqlCommandText = new StringBuilder("SELECT m.MenuID,m.MenuName,m.MenuUrl,m.PMenuID,m.IconUrl,m.SortID,m.IsContentMenu FROM dbo.Menu m WITH(NOLOCK) WHERE m.JournalID=@JournalID AND m.GroupID=@GroupID AND m.Status=1 ORDER BY m.SortID ASC,m.MenuID ASC");
            }
            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());
            db.AddInParameter(cmd,"@JournalID",DbType.Int64,query.JournalID);
            db.AddInParameter(cmd, "@GroupID", DbType.Byte, query.GroupID);

            IList<MenuEntity> menuList = new List<MenuEntity>();
            using (IDataReader dr = db.ExecuteReader(cmd))
            {
                MenuEntity entity = null;
                while (dr.Read())
                {
                    entity = new MenuEntity();
                    entity.MenuID = WKT.Common.Utils.TypeParse.ToLong(dr["MenuID"], 0);
                    entity.PMenuID = WKT.Common.Utils.TypeParse.ToInt(dr["PMenuID"], 0);
                    entity.MenuName = dr["MenuName"].ToString();
                    entity.MenuUrl = dr["MenuUrl"].ToString();
                    entity.IconUrl = dr["IconUrl"].ToString();
                    entity.IsContentMenu = WKT.Common.Utils.TypeParse.ToBool(dr["IsContentMenu"], false);
                    menuList.Add(entity);
                }
                dr.Close();
            }
            return menuList;
        }
Exemplo n.º 6
0
        public bool DeleteMenu(MenuEntity menuEntity)
        {
            bool flag = false;
            StringBuilder sqlCommandText = new StringBuilder();
            sqlCommandText.Append("DELETE FROM dbo.Menu");
            sqlCommandText.Append(" WHERE  MenuID=@MenuID");

            DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString());

            db.AddInParameter(cmd,"@MenuID",DbType.Int64,menuEntity.MenuID);

            try
            {
                db.ExecuteNonQuery(cmd);
                flag = true;
            }
            catch(SqlException sqlEx)
            {
                throw sqlEx;
            }
            return flag;
        }
Exemplo n.º 7
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="menu">MenuEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddMenu(MenuEntity menu)
 {
     return MenuBusProvider.AddMenu(menu);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="menu">MenuEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteMenu(MenuEntity menu)
 {
     return MenuBusProvider.DeleteMenu(menu);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="menu">MenuEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateMenu(MenuEntity menu)
 {
     return MenuBusProvider.UpdateMenu(menu);
 }
Exemplo n.º 10
0
 /// <summary>
 /// 从存储媒介删除实体数据
 /// </summary>
 /// <param name="menu">MenuEntity实体对象</param>
 /// <returns>true:删除成功 false:删除失败</returns>
 public bool DeleteMenu(MenuEntity menu)
 {
     return MenuDataAccess.Instance.DeleteMenu(menu);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 将实体数据存入存储媒介(持久化一个对象)
 /// </summary>
 /// <param name="menu">MenuEntity实体对象</param>
 /// <returns>true:存储成功 false:存储失败</returns>
 public bool AddMenu(MenuEntity menu)
 {
     return MenuDataAccess.Instance.AddMenu(menu);
 }
Exemplo n.º 12
0
 /// <summary>
 /// 更新存储媒介中的实体数据
 /// </summary>
 /// <param name="menuEntity">MenuEntity实体对象</param>
 /// <returns>true:更新成功 false:更新失败</returns>
 public bool UpdateMenu(MenuEntity menuEntity)
 {
     return MenuDataAccess.Instance.UpdateMenu(menuEntity);
 }
Exemplo n.º 13
0
        /// <summary>
        /// 查看
        /// </summary>
        /// <param name="MenuID"></param>
        /// <returns></returns>
        public ActionResult View(long? MenuID)
        {
            MenuEntity menuEntity = new MenuEntity();
            if (MenuID != null)
            {
                MenuQuery query = new MenuQuery();
                query.JournalID = JournalID;
                query.MenuID = MenuID.Value;

                ISiteSystemFacadeService siteSystemService = ServiceContainer.Instance.Container.Resolve<ISiteSystemFacadeService>();
                menuEntity = siteSystemService.GetMenu(query);
            }
            return View(menuEntity);
        }