예제 #1
0
 /// <summary>
 /// 创建导航栏
 /// </summary>
 public static void CreateNav(NavInfo navInfo)
 {
     if (navInfo.Pid > 0)
     {
         List<NavInfo> navList = BrnMall.Data.Navs.GetNavList();
         NavInfo parentNavInfo = navList.Find(x => x.Id == navInfo.Pid);//父导航
         navInfo.Layer = parentNavInfo.Layer + 1;
     }
     else
     {
         navInfo.Layer = 1;
     }
     BrnMall.Data.Navs.CreateNav(navInfo);
     BrnMall.Core.BMACache.Remove(CacheKeys.MALL_NAV_LIST);
     BrnMall.Core.BMACache.Remove(CacheKeys.MALL_NAV_MAINLIST);
 }
예제 #2
0
파일: Navs.cs 프로젝트: qq550723504/zone
 /// <summary>
 /// 获得导航栏列表
 /// </summary>
 /// <returns></returns>
 public static List<NavInfo> GetNavList()
 {
     List<NavInfo> navList = new List<NavInfo>();
     IDataReader reader = BrnMall.Core.BMAData.RDBS.GetNavList();
     while (reader.Read())
     {
         NavInfo navInfo = new NavInfo();
         navInfo.Id = TypeHelper.ObjectToInt(reader["id"]);
         navInfo.Pid = TypeHelper.ObjectToInt(reader["pid"]);
         navInfo.Layer = TypeHelper.ObjectToInt(reader["layer"]);
         navInfo.Name = reader["name"].ToString();
         navInfo.Title = reader["title"].ToString();
         navInfo.Url = reader["url"].ToString();
         navInfo.Target = TypeHelper.ObjectToInt(reader["target"]);
         navInfo.DisplayOrder = TypeHelper.ObjectToInt(reader["displayorder"]);
         navList.Add(navInfo);
     }
     reader.Close();
     return navList;
 }
예제 #3
0
        /// <summary>
        /// 更新导航栏
        /// </summary>
        public static void UpdateNav(NavInfo navInfo, int oldPid)
        {
            if (navInfo.Pid != oldPid)
            {
                int changeLayer = 0;
                List<NavInfo> navList = BrnMall.Data.Navs.GetNavList();
                NavInfo oldParentNavInfo = navList.Find(x => x.Id == oldPid);
                if (navInfo.Pid > 0)
                {
                    NavInfo newParentNavInfo = navList.Find(x => x.Id == navInfo.Pid);//新的父导航
                    if (oldParentNavInfo == null)
                    {
                        changeLayer = newParentNavInfo.Layer - 1;
                    }
                    else
                    {
                        changeLayer = newParentNavInfo.Layer - oldParentNavInfo.Layer;
                    }
                    navInfo.Layer = newParentNavInfo.Layer + 1;
                }
                else
                {
                    changeLayer = 1 - oldParentNavInfo.Layer;
                    navInfo.Layer = 1;
                }

                foreach (NavInfo info in navList.FindAll(x => x.Pid == navInfo.Id))
                {
                    UpdateChildNavLayer(navList, info, changeLayer);
                }
            }

            BrnMall.Data.Navs.UpdateNav(navInfo);

            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_NAV_LIST);
            BrnMall.Core.BMACache.Remove(CacheKeys.MALL_NAV_MAINLIST);
        }
예제 #4
0
        public ActionResult Add(NavModel model)
        {
            if (model.Pid != 0 && AdminNavs.GetNavById(model.Pid) == null)
                ModelState.AddModelError("Pid", "父导航不存在");

            if (ModelState.IsValid)
            {
                NavInfo navInfo = new NavInfo()
                {
                    Pid = model.Pid,
                    Name = model.NavName,
                    Title = model.NavTitle == null ? "" : model.NavTitle,
                    Url = model.NavUrl,
                    Target = model.Target,
                    DisplayOrder = model.DisplayOrder
                };

                AdminNavs.CreateNav(navInfo);
                AddMallAdminLog("添加导航", "添加导航,导航为:" + model.NavName);
                return PromptView("导航添加成功");
            }
            Load();
            return View(model);
        }
예제 #5
0
파일: Navs.cs 프로젝트: qq550723504/zone
 /// <summary>
 /// 更新导航栏
 /// </summary>
 public static void UpdateNav(NavInfo navInfo)
 {
     BrnMall.Core.BMAData.RDBS.UpdateNav(navInfo);
 }
예제 #6
0
 /// <summary>
 /// 更新导航栏
 /// </summary>
 public void UpdateNav(NavInfo navInfo)
 {
     DbParameter[] param = {
                                  GenerateInParam("@pid",SqlDbType.Int, 4, navInfo.Pid),
                                  GenerateInParam("@layer",SqlDbType.Int, 4, navInfo.Layer),
                                  GenerateInParam("@name",SqlDbType.NChar, 50, navInfo.Name),
                                  GenerateInParam("@title",SqlDbType.NChar, 250, navInfo.Title),
                                  GenerateInParam("@url",SqlDbType.NChar, 250, navInfo.Url),
                                  GenerateInParam("@target",SqlDbType.Int, 4, navInfo.Target),
                                  GenerateInParam("@displayorder",SqlDbType.Int,4,navInfo.DisplayOrder),
                                  GenerateInParam("@id",SqlDbType.Int, 4, navInfo.Id)
                                };
     string commandText = String.Format("UPDATE [{0}navs] SET [pid]=@pid,[layer]=@layer,[name]=@name,[title]=@title,[url]=@url,[target]=@target,[displayorder]=@displayorder WHERE [id]=@id",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }
예제 #7
0
 /// <summary>
 /// 创建导航栏
 /// </summary>
 public void CreateNav(NavInfo navInfo)
 {
     DbParameter[] param = {
                                  GenerateInParam("@pid",SqlDbType.Int, 4, navInfo.Pid),
                                  GenerateInParam("@layer",SqlDbType.Int, 4, navInfo.Layer),
                                  GenerateInParam("@name",SqlDbType.NChar, 50, navInfo.Name),
                                  GenerateInParam("@title",SqlDbType.NChar, 250, navInfo.Title),
                                  GenerateInParam("@url",SqlDbType.NChar, 250, navInfo.Url),
                                  GenerateInParam("@target",SqlDbType.Int, 4, navInfo.Target),
                                  GenerateInParam("@displayorder",SqlDbType.Int,4,navInfo.DisplayOrder)
                                };
     string commandText = String.Format("INSERT INTO [{0}navs]([pid],[layer],[name],[title],[url],[target],[displayorder]) VALUES(@pid,@layer,@name,@title,@url,@target,@displayorder)",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }
예제 #8
0
 /// <summary>
 /// 递归更新导航及其子导航的级别
 /// </summary>
 /// <param name="navList">导航列表</param>
 /// <param name="navInfo">导航信息</param>
 /// <param name="changeLayer">变化的级别</param>
 private static void UpdateChildNavLayer(List<NavInfo> navList, NavInfo navInfo, int changeLayer)
 {
     navInfo.Layer = navInfo.Layer + changeLayer;
     BrnMall.Data.Navs.UpdateNav(navInfo);
     foreach (NavInfo info in navList.FindAll(x => x.Pid == navInfo.Id))
     {
         UpdateChildNavLayer(navList, info, changeLayer);
     }
 }