protected void Page_Load(object sender, EventArgs e) { this.btnAddCoupons.Click += this.btnAddCoupons_Click; if (!base.IsPostBack) { if (!int.TryParse(this.Page.Request.QueryString["combinationId"], out this.combinationId) || string.IsNullOrEmpty(this.Page.Request.QueryString["editType"])) { base.GotoResourceNotFound(); } else { CombinationBuyInfo combinationBuyById = CombinationBuyHelper.GetCombinationBuyById(this.combinationId); if (combinationBuyById != null) { HiddenField hiddenField = this.hidMainProductId; int mainProductId = combinationBuyById.MainProductId; hiddenField.Value = mainProductId.ToString(); this.hidOtherProductIds.Value = combinationBuyById.OtherProductIds; HiddenField hiddenField2 = this.hidCombinationId; mainProductId = combinationBuyById.CombinationId; hiddenField2.Value = mainProductId.ToString(); this.calendarStartDate.SelectedDate = combinationBuyById.StartDate; this.calendarEndDate.SelectedDate = combinationBuyById.EndDate; this.hidEditType.Value = this.Page.Request.QueryString["editType"]; } else { base.GotoResourceNotFound(); } } } }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["combinaid"], out this.combinaid)) { base.GotoResourceNotFound(""); } else { CombinationBuyInfo combinationBuyById = CombinationBuyHelper.GetCombinationBuyById(this.combinaid); if (combinationBuyById == null) { base.GotoResourceNotFound(""); } else { DateTime now = DateTime.Now; int num; if (!(now.Date > combinationBuyById.EndDate)) { now = DateTime.Now; num = ((now.Date < combinationBuyById.StartDate) ? 1 : 0); } else { num = 1; } if (num != 0) { this.ShowWapMessage("活动未开始或者已结束", "ProductDetails.aspx?productId=" + combinationBuyById.MainProductId); } else { this.HasActivitiesToJumpUrl(combinationBuyById.MainProductId); if (base.ClientType.Equals(ClientType.VShop)) { FightGroupActivitiyModel fightGroupActivitiyModel = VShopHelper.GetFightGroupActivities(new FightGroupActivitiyQuery { PageIndex = 1, PageSize = 1, ProductId = combinationBuyById.MainProductId, Status = EnumFightGroupActivitiyStatus.BeingCarried }).Models.FirstOrDefault(); if (fightGroupActivitiyModel != null) { this.Page.Response.Redirect("FightGroupActivityDetails.aspx?fightGroupActivityId=" + fightGroupActivitiyModel.FightGroupActivityId); } } this.FindControls(); this.SetControlsValue(combinationBuyById.MainProductId); PageTitle.AddSiteNameTitle("组合购详情页"); } } } }
public CombinationBuyInfo GetCombinationBuyByMainProductId(int productId) { CombinationBuyInfo result = null; DbCommand sqlStringCommand = base.database.GetSqlStringCommand("SELECT top 1 * FROM Hishop_CombinationBuy WHERE MainProductId=@MainProductId AND StartDate <= @StartDate AND EndDate >= GETDATE(); "); base.database.AddInParameter(sqlStringCommand, "MainProductId", DbType.Int32, productId); Database database = base.database; DbCommand command = sqlStringCommand; DateTime dateTime = DateTime.Now; dateTime = dateTime.Date; database.AddInParameter(command, "StartDate", DbType.DateTime, dateTime.ToString()); using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand)) { result = DataHelper.ReaderToModel <CombinationBuyInfo>(objReader); } return(result); }
public static bool UpdateCombinationBuy(CombinationBuyInfo combinationInfo, List <CombinationBuySKUInfo> items) { Database database = DatabaseFactory.CreateDatabase(); using (DbConnection dbConnection = database.CreateConnection()) { CombinationBuyDao combinationDao = new CombinationBuyDao(); dbConnection.Open(); DbTransaction dbTransaction = dbConnection.BeginTransaction(); try { if (!combinationDao.Update(combinationInfo, null)) { dbTransaction.Rollback(); return(false); } if (!combinationDao.DeleteCombinationBuySku(combinationInfo.CombinationId)) { dbTransaction.Rollback(); return(false); } items.ForEach(delegate(CombinationBuySKUInfo i) { i.CombinationId = combinationInfo.CombinationId; long num = combinationDao.Add(i, null); }); dbTransaction.Commit(); return(true); } catch { dbTransaction.Rollback(); return(false); } finally { dbConnection.Close(); } } }
private void btnAddCoupons_Click(object sender, EventArgs e) { int num = 0; int.TryParse(this.hidMainProductId.Value, out num); if (num <= 0) { this.ShowMsg("请选择主商品!", false); } else if (string.IsNullOrEmpty(this.hidOtherProductIds.Value)) { this.ShowMsg("请至少选择一个组合商品!", false); } else if (!this.calendarStartDate.SelectedDate.HasValue) { this.ShowMsg("请选择开始日期!", false); } else if (!this.calendarEndDate.SelectedDate.HasValue) { this.ShowMsg("请选择结束日期!", false); } else { DateTime dateTime = this.calendarStartDate.SelectedDate.Value; if (dateTime.CompareTo(this.calendarEndDate.SelectedDate.Value) > 0) { this.ShowMsg("开始日期不能晚于结束日期!", false); } else { dateTime = this.calendarStartDate.SelectedDate.Value; DateTime now = DateTime.Now; if (dateTime.CompareTo(DateTime.Parse(now.ToString("yyyy-MM-dd"))) < 0) { this.ShowMsg("开始日期不能早于当前时间!", false); } else { dateTime = this.calendarEndDate.SelectedDate.Value; now = DateTime.Now; if (dateTime.CompareTo(DateTime.Parse(now.ToString("yyyy-MM-dd"))) < 0) { this.ShowMsg("结束日期不能早于当前时间!", false); } else { List <CombinationBuySKUInfo> items = JsonHelper.ParseFormJson <List <CombinationBuySKUInfo> >(this.hidSubmitData.Value); CombinationBuyInfo combinationBuyInfo = new CombinationBuyInfo(); combinationBuyInfo.MainProductId = num; combinationBuyInfo.OtherProductIds = this.hidOtherProductIds.Value; CombinationBuyInfo combinationBuyInfo2 = combinationBuyInfo; dateTime = this.calendarStartDate.SelectedDate.Value; combinationBuyInfo2.StartDate = dateTime.Date; CombinationBuyInfo combinationBuyInfo3 = combinationBuyInfo; dateTime = this.calendarEndDate.SelectedDate.Value; dateTime = dateTime.Date; dateTime = dateTime.AddDays(1.0); combinationBuyInfo3.EndDate = dateTime.AddSeconds(-1.0); if (CombinationBuyHelper.AddCombinationBuy(combinationBuyInfo, items)) { this.ShowMsg("添加组合购活动成功!", true, "CombinationBuy.aspx"); } else { this.ShowMsg("添加失败!", false); } } } } } }
protected override void AttachChildControls() { if (!int.TryParse(base.GetParameter("productId", false), out this.productId)) { base.GotoResourceNotFound(); } this.hidSupName = (HtmlInputHidden)this.FindControl("hidSupName"); this.litSupplierName = (Literal)this.FindControl("litSupplierName"); this.hiddenpid = (HtmlInputHidden)this.FindControl("hiddenpid"); this.hidCartQuantity = (HtmlInputHidden)this.FindControl("txCartQuantity"); this.hiddenpid.Value = this.productId.ToString(); this.common_Location = (Common_Location)this.FindControl("common_Location"); this.litProductName = (Literal)this.FindControl("litProductName"); this.lblStock = (StockLabel)this.FindControl("lblStock"); this.litUnit = (Literal)this.FindControl("litUnit"); this.litSaleCounts = (Literal)this.FindControl("litSaleCounts"); this.lblMarkerPrice = (FormatedMoneyLabel)this.FindControl("lblMarkerPrice"); this.lblBuyPrice = (Label)this.FindControl("lblBuyPrice"); this.lblTotalPrice = (TotalLabel)this.FindControl("lblTotalPrice"); this.lblSku = (SkuLabel)this.FindControl("lblSku"); this.litDescription = (Literal)this.FindControl("litDescription"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.btnBuy = (BuyButton)this.FindControl("btnBuy"); this.btnaddgouwu = (AddCartButton)this.FindControl("btnaddgouwu"); this.hpkProductConsultations = (HyperLink)this.FindControl("hpkProductConsultations"); this.ltlSaleCount = (Literal)this.FindControl("ltlSaleCount"); this.ltlReviewCount = (Literal)this.FindControl("ltlReviewCount"); this.litReviewCount = (Literal)this.FindControl("litReviewCount"); this.ltlConsultation = (Literal)this.FindControl("ltlConsultation"); this.images = (Common_ProductImages)this.FindControl("common_ProductImages"); this.rptExpandAttributes = (ThemedTemplatedRepeater)this.FindControl("rptExpandAttributes"); this.rptOnlineService = (ThemedTemplatedRepeater)this.FindControl("rptOnlineService"); this.skuSelector = (SKUSelector)this.FindControl("SKUSelector"); this.consultations = (Common_ProductConsultations)this.FindControl("list_Common_ProductConsultations"); this.correlative = (Common_GoodsList_Correlative)this.FindControl("list_Common_GoodsList_Correlative"); this.lbUserProductRefer = (UserProductReferLabel)this.FindControl("lbUserProductRefer"); this.hidden_skus = (HtmlInputHidden)this.FindControl("hidden_skus"); this.hidden_skuItem = (HtmlInputHidden)this.FindControl("hidden_skuItem"); this.hidIsOpenMultiStore = (HtmlInputHidden)this.FindControl("hidIsOpenMultiStore"); this.aCountDownUrl = (HyperLink)this.FindControl("aCountDownUrl"); this.imgQrCode = (Image)this.FindControl("imgQrCode"); this.phonePriceQrCode = (Image)this.FindControl("phonePriceQrCode"); this.liCode = (HtmlGenericControl)this.FindControl("liCode"); this.hidden_productId = (HtmlInputHidden)this.FindControl("hidden_productId"); this.hidHasStores = (HtmlInputHidden)this.FindControl("hidHasStores"); this.divGift = (HtmlGenericControl)this.FindControl("divGift"); this.ltlGiftName = (Literal)this.FindControl("ltlGiftName"); this.ltlGiftNum = (Literal)this.FindControl("ltlGiftNum"); this.aBrand = (HtmlAnchor)this.FindControl("aBrand"); this.imgBrand = (HiImage)this.FindControl("imgBrand"); this.imgpdorequest = (HtmlImage)this.FindControl("imgpdorequest"); this.imgTakeonstore = (HtmlImage)this.FindControl("imgTakeonstore"); this.imgCustomerService = (HtmlImage)this.FindControl("imgCustomerService"); this.ltlOrderPromotion = (Literal)this.FindControl("ltlOrderPromotion"); this.ltlOrderPromotion_free = (Literal)this.FindControl("ltlOrderPromotion_free"); this.divOrderPromotions = (HtmlGenericControl)this.FindControl("divOrderPromotions"); this.divOrderPromotions2 = (HtmlGenericControl)this.FindControl("divOrderPromotions2"); this.divOrderPromotions3 = (HtmlGenericControl)this.FindControl("divOrderPromotions3"); this.divPhonePrice = (HtmlGenericControl)this.FindControl("divPhonePrice"); this.litPhonePrice = (Literal)this.FindControl("litPhonePrice"); this.litPhonePriceEndDate = (Literal)this.FindControl("litPhonePriceEndDate"); this.divCuxiao = (HtmlGenericControl)this.FindControl("divCuxiao"); this.ltlUnit = (Literal)this.FindControl("ltlUnit"); this.divProductReferral = (HtmlGenericControl)this.FindControl("divProductReferral"); this.ltlProductSendGifts = (Literal)this.FindControl("ltlProductSendGifts"); this.setDeliverRegion = (Common_SetDeliveryRegion)this.FindControl("setDeliverRegion"); this.hidShowCombinationBuy = (HtmlInputHidden)this.FindControl("hidShowCombinationBuy"); this.hidCombinationId = (HtmlInputHidden)this.FindControl("hidCombinationId"); this.imgMainPic = (HtmlImage)this.FindControl("imgMainPic"); this.divqq = (HtmlGenericControl)this.FindControl("divqq"); HtmlAnchor htmlAnchor = (HtmlAnchor)this.FindControl("aMainName"); this.lblMainPrice = (Label)this.FindControl("lblMainPrice"); ThemedTemplatedRepeater themedTemplatedRepeater = (ThemedTemplatedRepeater)this.FindControl("rptOtherProducts"); this.spdiscount = (HtmlGenericControl)this.FindControl("spdiscount"); this.aCountDownUrl.Visible = false; this.buyProduct = (HtmlTableRow)this.FindControl("buyProduct"); this.serviceProduct = (HtmlTableRow)this.FindControl("serviceProduct"); if (this.Page.IsPostBack) { return; } SiteSettings masterSettings = SettingsManager.GetMasterSettings(); if (this.spdiscount != null && HiContext.Current.User.UserId > 0) { MemberGradeInfo memberGrade = MemberProcessor.GetMemberGrade(HiContext.Current.User.GradeId); this.spdiscount.Visible = true; this.spdiscount.InnerHtml = "<strong class='vip_price'><img src='/templates/pccommon/images/vip_price.png' />" + memberGrade.Name + "价</strong>"; } if (this.imgQrCode != null) { string text = "/Storage/master/QRCode/" + HttpContext.Current.Request.Url.Host + "_" + this.productId + ".png"; Globals.CreateQRCode(HttpContext.Current.Request.Url.ToString(), text, false, ImageFormats.Png); this.imgQrCode.ImageUrl = text; } if (this.phonePriceQrCode != null) { string text2 = "/Storage/master/QRCode/" + HttpContext.Current.Request.Url.Host + "_" + this.productId + ".png"; Globals.CreateQRCode(HttpContext.Current.Request.Url.ToString(), text2, false, ImageFormats.Png); this.phonePriceQrCode.ImageUrl = text2; } if (this.liCode != null && HiContext.Current.SiteSettings.OpenAliho == 0 && HiContext.Current.SiteSettings.OpenVstore == 0 && HiContext.Current.SiteSettings.OpenWap == 0 && HiContext.Current.SiteSettings.OpenMobbile == 0) { this.liCode.Visible = false; } ProductBrowseInfo productBrowseInfo = ProductBrowser.GetProductBrowseInfo(this.productId, null, this.sitesettings.OpenMultStore, 0); if (productBrowseInfo.Product == null || productBrowseInfo.Product.SaleStatus == ProductSaleStatus.Delete) { this.Page.Response.Redirect("/ProductDelete.aspx"); return; } if (productBrowseInfo.Product.SaleStatus == ProductSaleStatus.UnSale) { this.Page.Response.Redirect(base.GetRouteUrl("unproductdetails", new { ProductId = this.productId })); } if (productBrowseInfo.Product.SupplierId > 0 && productBrowseInfo.Product.AuditStatus != ProductAuditStatus.Pass) { this.Page.Response.Redirect(base.GetRouteUrl("unproductdetailsaudit", new { ProductId = this.productId })); } if (productBrowseInfo.Product.SaleStatus == ProductSaleStatus.OnStock) { this.Page.Response.Redirect("/ResourceNotFound.aspx?errorMsg=" + Globals.UrlEncode("该商品已入库")); return; } this.setDeliverRegion.ShippingTemplateId = productBrowseInfo.Product.ShippingTemplateId; this.setDeliverRegion.Volume = productBrowseInfo.Product.Weight; this.setDeliverRegion.Weight = productBrowseInfo.Product.Weight; this.ActivityBusiness(); if (this.hidCartQuantity != null) { this.hidCartQuantity.Value = ShoppingCartProcessor.GetQuantity_Product(productBrowseInfo.Product.ProductId); } IEnumerable value = from item in productBrowseInfo.Product.Skus select item.Value; if (JsonConvert.SerializeObject(productBrowseInfo.DbSKUs) != null) { this.hidden_skuItem.Value = JsonConvert.SerializeObject(productBrowseInfo.DbSKUs); } if (this.hidden_skus != null) { this.hidden_skus.Value = JsonConvert.SerializeObject(value); } this.hidden_productId.Value = this.productId.ToString(); this.LoadPageSearch(productBrowseInfo.Product); if (this.lbUserProductRefer != null && this.sitesettings.OpenReferral == 1 && this.sitesettings.ShowDeductInProductPage) { this.lbUserProductRefer.product = productBrowseInfo.Product; } HyperLink hyperLink = this.hpkProductConsultations; int num = productBrowseInfo.ConsultationCount; hyperLink.Text = "查看全部" + num.ToString() + "条咨询"; Literal literal = this.ltlConsultation; num = productBrowseInfo.ConsultationCount; literal.Text = num.ToString(); Literal literal2 = this.ltlSaleCount; num = productBrowseInfo.SaleCount; literal2.Text = num.ToString(); Literal literal3 = this.ltlReviewCount; num = productBrowseInfo.ReviewCount; literal3.Text = num.ToString(); Literal literal4 = this.litReviewCount; num = productBrowseInfo.ReviewCount; literal4.Text = num.ToString(); this.hpkProductConsultations.NavigateUrl = $"ProductConsultationsAndReplay.aspx?productId={this.productId}"; this.LoadProductInfo(productBrowseInfo.Product, productBrowseInfo.BrandName); this.btnBuy.Stock = (this.sitesettings.OpenMultStore ? productBrowseInfo.Product.DefaultSku.MaxStock : productBrowseInfo.Product.Stock); this.ltlUnit.Text = productBrowseInfo.Product.Unit; this.divqq.Visible = (this.sitesettings.ServiceIsOpen == "1"); MemberInfo user = HiContext.Current.User; if (user != null && user.IsReferral() && (!(this.sitesettings.SubMemberDeduct <= decimal.Zero) || productBrowseInfo.Product.SubMemberDeduct.HasValue)) { if (!productBrowseInfo.Product.SubMemberDeduct.HasValue) { goto IL_0c9e; } decimal?subMemberDeduct = productBrowseInfo.Product.SubMemberDeduct; if (!(subMemberDeduct.GetValueOrDefault() <= default(decimal)) || !subMemberDeduct.HasValue) { goto IL_0c9e; } } goto IL_0cd8; IL_0cd9: int num2; if (num2 != 0) { this.divProductReferral.Visible = false; } this.btnaddgouwu.Stock = (this.sitesettings.OpenMultStore ? productBrowseInfo.Product.DefaultSku.MaxStock : productBrowseInfo.Product.Stock); BrowsedProductQueue.EnQueue(this.productId); this.images.ImageInfo = productBrowseInfo.Product; if (productBrowseInfo.DbAttribute != null) { this.rptExpandAttributes.DataSource = productBrowseInfo.DbAttribute; this.rptExpandAttributes.DataBind(); } if (productBrowseInfo.DbSKUs != null) { this.skuSelector.ProductId = this.productId; this.skuSelector.DataSource = productBrowseInfo.DbSKUs; } int supplierId = productBrowseInfo.Product.SupplierId; if (supplierId > 0) { SupplierInfo supplierById = SupplierHelper.GetSupplierById(supplierId); if (!string.IsNullOrEmpty(supplierById.Picture)) { this.imgBrand.ImageUrl = supplierById.Picture; } else if (productBrowseInfo.Product.BrandId.HasValue) { BrandCategoryInfo brandCategory = CatalogHelper.GetBrandCategory(productBrowseInfo.Product.BrandId.Value); if (brandCategory != null && !string.IsNullOrEmpty(brandCategory.Logo)) { this.imgBrand.ImageUrl = brandCategory.Logo; this.aBrand.HRef = base.GetRouteUrl("branddetails", new { brandId = brandCategory.BrandId }); } } else { this.imgBrand.Visible = false; } this.litSupplierName.Text = "<a href=\"/SupplierAbout?SupplierId=" + supplierById.SupplierId + "\">" + supplierById.SupplierName + "</a>"; this.hidSupName.Value = supplierById.SupplierName; } else { this.litSupplierName.Visible = false; if (productBrowseInfo.Product.BrandId.HasValue) { BrandCategoryInfo brandCategory2 = CatalogHelper.GetBrandCategory(productBrowseInfo.Product.BrandId.Value); if (brandCategory2 != null && !string.IsNullOrEmpty(brandCategory2.Logo)) { this.imgBrand.ImageUrl = brandCategory2.Logo; this.aBrand.HRef = base.GetRouteUrl("branddetails", new { brandId = brandCategory2.BrandId }); } } } if (SalesHelper.IsSupportPodrequest() && productBrowseInfo.Product.SupplierId == 0) { this.imgpdorequest.Visible = true; } if (masterSettings.OpenMultStore) { if (StoresHelper.ProductInStoreAndIsAboveSelf(this.productId)) { this.imgTakeonstore.Visible = true; } } else if (masterSettings.IsOpenPickeupInStore && productBrowseInfo.Product.SupplierId == 0) { this.imgTakeonstore.Visible = true; } if (productBrowseInfo.DBConsultations != null) { this.consultations.DataSource = productBrowseInfo.DBConsultations; this.consultations.DataBind(); } if (productBrowseInfo.DbCorrelatives != null) { this.correlative.DataSource = productBrowseInfo.DbCorrelatives; this.correlative.DataBind(); } this.BindOrderPromotions(); if (!this.divOrderPromotions.Visible && !this.divOrderPromotions2.Visible && !this.divOrderPromotions3.Visible && !this.divPhonePrice.Visible) { this.divCuxiao.Style.Add("display", "none"); } if (this.rptOnlineService != null) { IList <OnlineServiceInfo> allOnlineService = OnlineServiceHelper.GetAllOnlineService(0, 1); IList <OnlineServiceInfo> allOnlineService2 = OnlineServiceHelper.GetAllOnlineService(0, 2); if (allOnlineService2 != null) { foreach (OnlineServiceInfo item in allOnlineService2) { allOnlineService.Add(item); } } this.rptOnlineService.DataSource = allOnlineService; this.rptOnlineService.DataBind(); } if (productBrowseInfo.Product.Stock > 0) { CombinationBuyInfo combinationBuyByMainProductId = CombinationBuyHelper.GetCombinationBuyByMainProductId(this.productId); if (combinationBuyByMainProductId != null) { List <CombinationBuyandProductUnionInfo> combinationProductListByProductId = CombinationBuyHelper.GetCombinationProductListByProductId(this.productId); CombinationBuyandProductUnionInfo combinationBuyandProductUnionInfo = combinationProductListByProductId.FirstOrDefault((CombinationBuyandProductUnionInfo c) => c.ProductId == this.productId); if (combinationBuyandProductUnionInfo != null) { HtmlInputHidden htmlInputHidden = this.hidCombinationId; num = combinationBuyandProductUnionInfo.CombinationId; htmlInputHidden.Value = num.ToString(); string value2 = string.IsNullOrEmpty(combinationBuyandProductUnionInfo.ThumbnailUrl100) ? this.sitesettings.DefaultProductThumbnail3 : combinationBuyandProductUnionInfo.ThumbnailUrl100; this.imgMainPic.Attributes["data-url"] = value2; htmlAnchor.InnerText = combinationBuyandProductUnionInfo.ProductName; this.lblMainPrice.Text = combinationBuyandProductUnionInfo.MinCombinationPrice.F2ToString("f2"); this.lblMainPrice.Attributes["salePrice"] = combinationBuyandProductUnionInfo.MinSalePrice.F2ToString("f2"); } combinationProductListByProductId.Remove(combinationBuyandProductUnionInfo); if (combinationProductListByProductId != null && combinationProductListByProductId.Count > 0) { for (int i = 0; i < combinationProductListByProductId.Count; i++) { string thumbnailUrl = string.IsNullOrEmpty(combinationProductListByProductId[i].ThumbnailUrl100) ? this.sitesettings.DefaultProductThumbnail3 : combinationProductListByProductId[i].ThumbnailUrl100; combinationProductListByProductId[i].ThumbnailUrl100 = thumbnailUrl; combinationProductListByProductId[i].Index = i + 1; } themedTemplatedRepeater.DataSource = combinationProductListByProductId; themedTemplatedRepeater.DataBind(); this.hidShowCombinationBuy.Value = "1"; } } } return; IL_0cd8: num2 = 1; goto IL_0cd9; IL_0c9e: if (HiContext.Current.SiteSettings.OpenReferral == 1 && HiContext.Current.SiteSettings.ShowDeductInProductPage && user.Referral != null) { num2 = (user.Referral.IsRepeled ? 1 : 0); goto IL_0cd9; } goto IL_0cd8; }