예제 #1
0
        /// <summary>
        /// 从DataRow创建BannerInfo
        /// </summary>
        public static BannerInfo BuildBannerFromRow(DataRow row)
        {
            BannerInfo bannerInfo = new BannerInfo();

            bannerInfo.Id = TypeHelper.ObjectToInt(row["id"]);
            bannerInfo.Type = TypeHelper.ObjectToInt(row["type"]);
            bannerInfo.StartTime = TypeHelper.ObjectToDateTime(row["starttime"]);
            bannerInfo.EndTime = TypeHelper.ObjectToDateTime(row["endtime"]);
            bannerInfo.IsShow = TypeHelper.ObjectToInt(row["isshow"]);
            bannerInfo.Title = row["title"].ToString();
            bannerInfo.Img = row["img"].ToString();
            bannerInfo.Url = row["url"].ToString();
            bannerInfo.DisplayOrder = TypeHelper.ObjectToInt(row["displayorder"]);

            return bannerInfo;
        }
예제 #2
0
        public ActionResult Add(BannerModel model)
        {
            if (ModelState.IsValid)
            {
                BannerInfo bannerInfo = new BannerInfo()
                {
                    Type = model.BannerType,
                    StartTime = model.StartTime,
                    EndTime = model.EndTime,
                    IsShow = model.IsShow,
                    Title = model.BannerTitle == null ? "" : model.BannerTitle,
                    Img = model.Img,
                    Url = model.Url,
                    DisplayOrder = model.DisplayOrder
                };

                AdminBanners.CreateBanner(bannerInfo);
                AddAdminOperateLog("添加banner", "添加banner,banner为:" + model.BannerTitle);
                return PromptView("banner添加成功");
            }
            Load();
            return View(model);
        }
예제 #3
0
 /// <summary>
 /// 更新banner
 /// </summary>
 public static void UpdateBanner(BannerInfo bannerInfo)
 {
     BrnShop.Data.Banners.UpdateBanner(bannerInfo);
     BrnShop.Core.BSPCache.Remove(CacheKeys.SHOP_BANNER_HOMELIST + bannerInfo.Type);
 }
예제 #4
0
 /// <summary>
 /// 更新banner
 /// </summary>
 public static void UpdateBanner(BannerInfo bannerInfo)
 {
     BrnShop.Core.BSPData.RDBS.UpdateBanner(bannerInfo);
 }
예제 #5
0
        /// <summary>
        /// 获得首页banner列表
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="nowTime">当前时间</param>
        /// <returns></returns>
        public static BannerInfo[] GetHomeBannerList(int type, DateTime nowTime)
        {
            DataTable dt = BrnShop.Core.BSPData.RDBS.GetHomeBannerList(type, nowTime);
            BannerInfo[] bannerList = new BannerInfo[dt.Rows.Count];

            int index = 0;
            foreach (DataRow row in dt.Rows)
            {
                BannerInfo bannerInfo = BuildBannerFromRow(row);
                bannerList[index] = bannerInfo;
                index++;
            }
            return bannerList;
        }
예제 #6
0
 /// <summary>
 /// 创建banner
 /// </summary>
 public void CreateBanner(BannerInfo bannerInfo)
 {
     DbParameter[] param = {
                             GenerateInParam("@type",SqlDbType.TinyInt,1,bannerInfo.Type),
                             GenerateInParam("@starttime",SqlDbType.DateTime, 8, bannerInfo.StartTime),
                             GenerateInParam("@endtime",SqlDbType.DateTime, 8, bannerInfo.EndTime),
                             GenerateInParam("@isshow",SqlDbType.TinyInt, 1, bannerInfo.IsShow),
                             GenerateInParam("@title",SqlDbType.NVarChar, 100, bannerInfo.Title),
                             GenerateInParam("@img",SqlDbType.NVarChar, 250, bannerInfo.Img),
                             GenerateInParam("@url",SqlDbType.NVarChar, 250, bannerInfo.Url),
                             GenerateInParam("@displayorder",SqlDbType.Int,4,bannerInfo.DisplayOrder)
                            };
     string commandText = String.Format("INSERT INTO [{0}banners]([type],[starttime],[endtime],[isshow],[title],[img],[url],[displayorder]) VALUES(@type,@starttime,@endtime,@isshow,@title,@img,@url,@displayorder)",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }
예제 #7
0
 /// <summary>
 /// 更新banner
 /// </summary>
 public void UpdateBanner(BannerInfo bannerInfo)
 {
     DbParameter[] param = {
                             GenerateInParam("@type",SqlDbType.TinyInt,1,bannerInfo.Type),
                             GenerateInParam("@starttime",SqlDbType.DateTime, 8, bannerInfo.StartTime),
                             GenerateInParam("@endtime",SqlDbType.DateTime, 8, bannerInfo.EndTime),
                             GenerateInParam("@isshow",SqlDbType.TinyInt, 1, bannerInfo.IsShow),
                             GenerateInParam("@title",SqlDbType.NVarChar, 100, bannerInfo.Title),
                             GenerateInParam("@img",SqlDbType.NVarChar, 250, bannerInfo.Img),
                             GenerateInParam("@url",SqlDbType.NVarChar, 250, bannerInfo.Url),
                             GenerateInParam("@displayorder",SqlDbType.Int,4,bannerInfo.DisplayOrder),
                             GenerateInParam("@id",SqlDbType.Int, 4, bannerInfo.Id)
                           };
     string commandText = String.Format("UPDATE [{0}banners] SET [type]=@type,[starttime]=@starttime,[endtime]=@endtime,[isshow]=@isshow,[title]=@title,[img]=@img,[url]=@url,[displayorder]=@displayorder WHERE [id]=@id",
                                         RDBSHelper.RDBSTablePre);
     RDBSHelper.ExecuteNonQuery(CommandType.Text, commandText, param);
 }