protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var idstr = Request.QueryString["shopid"]; int id; if (idstr == null || !int.TryParse(idstr, out id)) { Response.Redirect("ShopList.aspx"); return; } VisitingShop = ShopBll.GetShopById(id); if (VisitingShop == null) { Response.Redirect("ShopList.aspx"); return; } YeShopCoupon = ShopCouponBll.GetShopCouponsByShopId(VisitingShop.ShopID).FirstOrDefault(c => c.BeginDate <DateTime.Now && c.EndDate> DateTime.Now); var sb = new StringBuilder(); for (int i = 0; i < VisitingShop.Rank; i++) { sb.Append("<i class='fa fa-star' style='color:#F07202'></i>"); } ltlRank.Text = sb.ToString(); rptProducts.DataSource = ProductBll.GetProductsByShopId(VisitingShop.ShopID).OrderBy(p => p.RecommendLevel).Take(10).ToList(); rptProducts.DataBind(); rptProductTypes.DataSource = ProductBll.GetProductTypesByShopId(VisitingShop.ShopID).Take(2).ToList(); rptProductTypes.DataBind(); } }
/// <summary> /// 添加优惠券 /// </summary> /// <param name="shopCoupon"></param> /// <returns></returns> public static bool AddShopCoupon(Ye_ShopCoupon shopCoupon) { _entities.Ye_ShopCoupon.Add(shopCoupon); return(_entities.SaveChanges() > 0); }