protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId) || !int.TryParse(this.Page.Request.QueryString["exchangeId"], out this.exchangeId)) { base.GotoResourceNotFound(""); } this.rptProductImages = (VshopTemplatedRepeater)this.FindControl("rptProductImages"); this.litItemParams = (Literal)this.FindControl("litItemParams"); this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litSalePoint = (Literal)this.FindControl("litSalePoint"); this.litMarketPrice = (Literal)this.FindControl("litMarketPrice"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSurplusTime = (Literal)this.FindControl("litSurplusTime"); this.litDescription = (Literal)this.FindControl("litDescription"); this.litStock = (Literal)this.FindControl("litStock"); this.litEachCount = (Literal)this.FindControl("litEachCount"); this.skuSelector = (Common_SKUSelector)this.FindControl("skuSelector"); this.linkDescription = (HyperLink)this.FindControl("linkDescription"); this.expandAttr = (Common_ExpandAttributes)this.FindControl("ExpandAttributes"); this.litSoldCount = (Literal)this.FindControl("litSoldCount"); this.litConsultationsCount = (Literal)this.FindControl("litConsultationsCount"); this.litReviewsCount = (Literal)this.FindControl("litReviewsCount"); this.hdHasCollected = (HtmlInputHidden)this.FindControl("hdHasCollected"); this.hdCategoryId = (HtmlInputHidden)this.FindControl("hdCategoryId"); this.hdEachCount = (HtmlInputHidden)this.FindControl("hdEachCount"); this.hdProductId = (HtmlInputHidden)this.FindControl("hdProductId"); this.hdStock = (HtmlInputHidden)this.FindControl("hdStock"); this.hdIsActive = (HtmlInputHidden)this.FindControl("hdIsActive"); this.hdIsInRange = (HtmlInputHidden)this.FindControl("hdIsInRange"); this.hdPoint = (HtmlInputHidden)this.FindControl("hdPoint"); this.hdTemplateid = (HtmlInputHidden)this.FindControl("hdTemplateid"); this.hdUserExchanged = (HtmlInputHidden)this.FindControl("hdUserExchanged"); PointExChangeInfo info = PointExChangeHelper.Get(this.exchangeId); PointExchangeProductInfo productInfo = PointExChangeHelper.GetProductInfo(this.exchangeId, this.productId); ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId); if (((info != null) && (product != null)) && (productInfo != null)) { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { this.hdPoint.Value = currentMember.Points.ToString(); if (MemberProcessor.CheckCurrentMemberIsInRange(info.MemberGrades, info.DefualtGroup, info.CustomGroup)) { this.hdIsInRange.Value = "true"; } else { this.hdIsInRange.Value = "false"; } } if (info.EndDate < DateTime.Now) { this.litSurplusTime.Text = "已结束"; this.hdIsActive.Value = "0"; } else if (info.BeginDate > DateTime.Now) { this.litSurplusTime.Text = "未开始"; this.hdIsActive.Value = "0"; } else { this.hdIsActive.Value = "1"; TimeSpan span = (TimeSpan)(info.EndDate - DateTime.Now); if (span.Days > 1) { this.litSurplusTime.Text = string.Concat(new object[] { "还剩", span.Days, "天", span.Hours, "小时" }); } else { this.litSurplusTime.Text = "还剩" + span.Hours + "小时"; } } this.hdProductId.Value = this.productId.ToString(); if (product == null) { base.GotoResourceNotFound("此商品已不存在"); } if (product.SaleStatus != ProductSaleStatus.OnSale) { base.GotoResourceNotFound(ErrorType.前台商品下架, "此商品已下架"); } if (this.rptProductImages != null) { string locationUrl = "javascript:;"; SlideImage[] imageArray = new SlideImage[] { new SlideImage(product.ImageUrl1, locationUrl), new SlideImage(product.ImageUrl2, locationUrl), new SlideImage(product.ImageUrl3, locationUrl), new SlideImage(product.ImageUrl4, locationUrl), new SlideImage(product.ImageUrl5, locationUrl) }; this.rptProductImages.DataSource = from item in imageArray where !string.IsNullOrWhiteSpace(item.ImageUrl) select item; this.rptProductImages.DataBind(); } string mainCategoryPath = product.MainCategoryPath; if (!string.IsNullOrEmpty(mainCategoryPath)) { this.hdCategoryId.Value = mainCategoryPath.Split(new char[] { '|' })[0]; } else { this.hdCategoryId.Value = "0"; } this.litProdcutName.Text = product.ProductName; this.hdTemplateid.Value = product.FreightTemplateId.ToString(); this.litSalePoint.Text = productInfo.PointNumber.ToString(); if (product.MarketPrice.HasValue && (product.MarketPrice > 0M)) { this.litMarketPrice.Text = "<del class=\"text-muted font-s\">\x00a5" + product.MarketPrice.Value.ToString("F2") + "</del>"; } this.litShortDescription.Text = product.ShortDescription; string description = product.Description; if (!string.IsNullOrEmpty(description)) { description = Regex.Replace(description, "<img[^>]*\\bsrc=('|\")([^'\">]*)\\1[^>]*>", "<img alt='" + HttpContext.Current.Server.HtmlEncode(product.ProductName) + "' src='$2' />", RegexOptions.IgnoreCase); } if (this.litDescription != null) { this.litDescription.Text = description; } this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString()); int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(this.exchangeId, this.productId); int num2 = ((productInfo.ProductNumber - productExchangedCount) >= 0) ? (productInfo.ProductNumber - productExchangedCount) : 0; this.litStock.Text = num2.ToString(); this.hdStock.Value = num2.ToString(); this.litEachCount.Text = productInfo.EachMaxNumber.ToString(); this.hdEachCount.Value = productInfo.EachMaxNumber.ToString(); this.skuSelector.ProductId = this.productId; if (this.expandAttr != null) { this.expandAttr.ProductId = this.productId; } if (this.linkDescription != null) { this.linkDescription.NavigateUrl = "/Vshop/ProductDescription.aspx?productId=" + this.productId; } int productConsultationsCount = ProductBrowser.GetProductConsultationsCount(this.productId, false); this.litConsultationsCount.SetWhenIsNotNull(productConsultationsCount.ToString()); this.litReviewsCount.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(this.productId).ToString()); bool flag = false; if (currentMember != null) { this.hdUserExchanged.Value = PointExChangeHelper.GetUserProductExchangedCount(this.exchangeId, this.productId, currentMember.UserId).ToString(); flag = ProductBrowser.CheckHasCollect(currentMember.UserId, this.productId); this.hdHasCollected.SetWhenIsNotNull(flag ? "1" : "0"); } ProductBrowser.UpdateVisitCounts(this.productId); PageTitle.AddSiteNameTitle("积分商品"); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false); string objStr = ""; if (!string.IsNullOrEmpty(masterSettings.GoodsPic)) { objStr = Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic; } this.litItemParams.Text = Globals.GetReplaceStr(objStr, "|", "|") + "|" + Globals.GetReplaceStr(masterSettings.GoodsName, "|", "|") + "|" + Globals.GetReplaceStr(masterSettings.GoodsDescription, "|", "|") + "$" + Globals.HostPath(HttpContext.Current.Request.Url).Replace("|", "|") + Globals.GetReplaceStr(product.ImageUrl1, "|", "|") + "|" + Globals.GetReplaceStr(product.ProductName, "|", "|") + "|" + Globals.GetReplaceStr(product.ShortDescription, "|", "|") + "|" + HttpContext.Current.Request.Url.ToString().Replace("|", "|"); } else { HttpContext.Current.Response.Redirect("/default.aspx"); HttpContext.Current.Response.End(); } }
private void BindProducts(int exchangeId) { if (exchangeId == 0) { return; } string text = this.txt_name.Text; string text2 = this.txt_minPrice.Text; string text3 = this.txt_maxPrice.Text; decimal?minPrice = null; decimal?maxPrice = null; decimal value = 0m; if (!this.bDecimal(text2, ref value)) { minPrice = null; } else { minPrice = new decimal?(value); } if (!this.bDecimal(text3, ref value)) { maxPrice = null; } else { maxPrice = new decimal?(value); } ProductQuery productQuery = new ProductQuery { Keywords = text, ProductCode = "", CategoryId = null, PageSize = this.pager.PageSize, PageIndex = this.pager.PageIndex, SortOrder = SortAction.Desc, SortBy = "DisplaySequence", StartDate = null, BrandId = null, EndDate = null, TypeId = null, SaleStatus = this.status, minPrice = minPrice, maxPrice = maxPrice, TwoSaleStatus = "OnStock" }; Globals.EntityCoding(productQuery, true); DbQueryResult products = ProductHelper.GetProducts(productQuery); System.Data.DataTable dataTable = (System.Data.DataTable)products.Data; System.Data.DataTable products2 = PointExChangeHelper.GetProducts(this.eId); dataTable.Columns.Add("ProductNumber"); dataTable.Columns.Add("PointNumber"); dataTable.Columns.Add("eachMaxNumber"); dataTable.Columns.Add("seledStatus"); dataTable.Columns.Add("canSelStatus"); dataTable.Columns.Add("canChkStatus"); if (dataTable != null && dataTable.Rows.Count > 0) { for (int i = 0; i < dataTable.Rows.Count; i++) { dataTable.Rows[i]["ProductNumber"] = 0; dataTable.Rows[i]["PointNumber"] = 0; dataTable.Rows[i]["eachMaxNumber"] = 0; } } if (products2 != null) { if (dataTable.Rows.Count > 0 && products2.Rows.Count > 0) { for (int j = 0; j < dataTable.Rows.Count; j++) { int num = int.Parse(dataTable.Rows[j]["ProductId"].ToString()); if (products2.Select(string.Format("ProductId={0}", num)).Length > 0) { dataTable.Rows[j]["seledStatus"] = "''"; dataTable.Rows[j]["canSelStatus"] = "none"; dataTable.Rows[j]["canChkStatus"] = "disabled"; PointExchangeProductInfo productInfo = PointExChangeHelper.GetProductInfo(exchangeId, num); if (productInfo != null) { dataTable.Rows[j]["ProductNumber"] = productInfo.ProductNumber.ToString(); dataTable.Rows[j]["PointNumber"] = productInfo.PointNumber.ToString(); dataTable.Rows[j]["eachMaxNumber"] = productInfo.EachMaxNumber.ToString(); } } else { dataTable.Rows[j]["seledStatus"] = "none"; dataTable.Rows[j]["canSelStatus"] = "''"; dataTable.Rows[j]["canChkStatus"] = string.Empty; } } } else if (dataTable.Rows.Count > 0) { for (int k = 0; k < dataTable.Rows.Count; k++) { dataTable.Rows[k]["seledStatus"] = "none"; dataTable.Rows[k]["canSelStatus"] = "''"; dataTable.Rows[k]["canChkStatus"] = string.Empty; } } } this.grdProducts.DataSource = products.Data; this.grdProducts.DataBind(); this.pager.TotalRecords = products.TotalRecords; this.lbwareNumber.Text = products.TotalRecords.ToString(); this.lbSelectNumber.Text = ((products2 != null) ? products2.Rows.Count.ToString() : "0"); this.setInSale(); }
private void BindProducts(int exchangeId) { if (exchangeId != 0) { string text = this.txt_name.Text; string val = this.txt_minPrice.Text; string str3 = this.txt_maxPrice.Text; decimal?nullable = null; decimal?nullable2 = null; decimal i = 0M; if (!this.bDecimal(val, ref i)) { nullable = null; } else { nullable = new decimal?(i); } if (!this.bDecimal(str3, ref i)) { nullable2 = null; } else { nullable2 = new decimal?(i); } ProductQuery entity = new ProductQuery { Keywords = text, ProductCode = "", CategoryId = null, PageSize = this.pager.PageSize, PageIndex = this.pager.PageIndex, SortOrder = SortAction.Desc, SortBy = "DisplaySequence", StartDate = null, BrandId = null, EndDate = null, TypeId = null, SaleStatus = this.status, minPrice = nullable, maxPrice = nullable2 }; Globals.EntityCoding(entity, true); DbQueryResult products = ProductHelper.GetProducts(entity); DataTable data = (DataTable)products.Data; DataTable table2 = PointExChangeHelper.GetProducts(this.eId); data.Columns.Add("ProductNumber"); data.Columns.Add("PointNumber"); data.Columns.Add("eachMaxNumber"); data.Columns.Add("seledStatus"); data.Columns.Add("canSelStatus"); data.Columns.Add("canChkStatus"); if ((data != null) && (data.Rows.Count > 0)) { for (int j = 0; j < data.Rows.Count; j++) { data.Rows[j]["ProductNumber"] = 0; data.Rows[j]["PointNumber"] = 0; data.Rows[j]["eachMaxNumber"] = 0; } } if (table2 != null) { if ((data.Rows.Count > 0) && (table2.Rows.Count > 0)) { for (int k = 0; k < data.Rows.Count; k++) { int num4 = int.Parse(data.Rows[k]["ProductId"].ToString()); if (table2.Select(string.Format("ProductId={0}", num4)).Length > 0) { data.Rows[k]["seledStatus"] = "''"; data.Rows[k]["canSelStatus"] = "none"; data.Rows[k]["canChkStatus"] = "disabled"; PointExchangeProductInfo productInfo = PointExChangeHelper.GetProductInfo(exchangeId, num4); if (productInfo != null) { data.Rows[k]["ProductNumber"] = productInfo.ProductNumber.ToString(); data.Rows[k]["PointNumber"] = productInfo.PointNumber.ToString(); data.Rows[k]["eachMaxNumber"] = productInfo.EachMaxNumber.ToString(); } } else { data.Rows[k]["seledStatus"] = "none"; data.Rows[k]["canSelStatus"] = "''"; data.Rows[k]["canChkStatus"] = string.Empty; } } } else if (data.Rows.Count > 0) { for (int m = 0; m < data.Rows.Count; m++) { data.Rows[m]["seledStatus"] = "none"; data.Rows[m]["canSelStatus"] = "''"; data.Rows[m]["canChkStatus"] = string.Empty; } } } this.grdProducts.DataSource = products.Data; this.grdProducts.DataBind(); this.pager.TotalRecords = products.TotalRecords; this.lbsaleNumber.Text = products.TotalRecords.ToString(); this.lbSelectNumber.Text = (table2 != null) ? table2.Rows.Count.ToString() : "0"; this.setInStock(); } }
protected override void AttachChildControls() { if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId) || !int.TryParse(this.Page.Request.QueryString["exchangeId"], out this.exchangeId)) { base.GotoResourceNotFound(""); } this.rptProductImages = (VshopTemplatedRepeater)this.FindControl("rptProductImages"); this.litItemParams = (Literal)this.FindControl("litItemParams"); this.litProdcutName = (Literal)this.FindControl("litProdcutName"); this.litActivities = (Literal)this.FindControl("litActivities"); this.litSalePoint = (Literal)this.FindControl("litSalePoint"); this.litMarketPrice = (Literal)this.FindControl("litMarketPrice"); this.litShortDescription = (Literal)this.FindControl("litShortDescription"); this.litSurplusTime = (Literal)this.FindControl("litSurplusTime"); this.litDescription = (Literal)this.FindControl("litDescription"); this.litStock = (Literal)this.FindControl("litStock"); this.litEachCount = (Literal)this.FindControl("litEachCount"); this.skuSelector = (Common_SKUSelector)this.FindControl("skuSelector"); this.linkDescription = (HyperLink)this.FindControl("linkDescription"); this.expandAttr = (Common_ExpandAttributes)this.FindControl("ExpandAttributes"); this.litSoldCount = (Literal)this.FindControl("litSoldCount"); this.litConsultationsCount = (Literal)this.FindControl("litConsultationsCount"); this.litReviewsCount = (Literal)this.FindControl("litReviewsCount"); this.hdHasCollected = (HtmlInputHidden)this.FindControl("hdHasCollected"); this.hdCategoryId = (HtmlInputHidden)this.FindControl("hdCategoryId"); this.hdEachCount = (HtmlInputHidden)this.FindControl("hdEachCount"); this.hdProductId = (HtmlInputHidden)this.FindControl("hdProductId"); this.hdStock = (HtmlInputHidden)this.FindControl("hdStock"); this.hdIsActive = (HtmlInputHidden)this.FindControl("hdIsActive"); this.hdNeedGrade = (HtmlInputHidden)this.FindControl("hdNeedGrade"); this.hdGradeId = (HtmlInputHidden)this.FindControl("hdGradeId"); this.hdPoint = (HtmlInputHidden)this.FindControl("hdPoint"); this.hdTemplateid = (HtmlInputHidden)this.FindControl("hdTemplateid"); this.hdUserExchanged = (HtmlInputHidden)this.FindControl("hdUserExchanged"); PointExChangeInfo info = PointExChangeHelper.Get(this.exchangeId); PointExchangeProductInfo productInfo = PointExChangeHelper.GetProductInfo(this.exchangeId, this.productId); ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId); if (((info != null) && (product != null)) && (productInfo != null)) { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (currentMember != null) { this.hdGradeId.Value = currentMember.GradeId.ToString(); this.hdPoint.Value = currentMember.Points.ToString(); this.hdNeedGrade.Value = info.MemberGrades; if (info.EndDate < DateTime.Now) { this.litSurplusTime.Text = "已结束"; this.hdIsActive.Value = "0"; } else if (info.BeginDate > DateTime.Now) { this.litSurplusTime.Text = "未开始"; this.hdIsActive.Value = "0"; } else { this.hdIsActive.Value = "1"; TimeSpan span = (TimeSpan)(info.EndDate - DateTime.Now); if (span.Days > 1) { this.litSurplusTime.Text = string.Concat(new object[] { "还剩", span.Days, "天", span.Hours, "小时" }); } else { this.litSurplusTime.Text = "还剩" + span.Hours + "小时"; } } this.hdProductId.Value = this.productId.ToString(); if (!string.IsNullOrEmpty(product.MainCategoryPath)) { DataTable allFull = ProductBrowser.GetAllFull(int.Parse(product.MainCategoryPath.Split(new char[] { '|' })[0].ToString())); this.litActivities.Text = "<div class=\"price clearfix\"><span class=\"title\">促销活动:</span><div class=\"all-action\">"; if (allFull.Rows.Count > 0) { for (int i = 0; i < allFull.Rows.Count; i++) { if (i == 0) { object text = this.litActivities.Text; this.litActivities.Text = string.Concat(new object[] { text, "<div class=\"action\"><span class=\"purchase\"><a href=\"/Vshop/ActivityDetail.aspx?ActivitiesId=", allFull.Rows[i]["ActivitiesId"], "&CategoryId=", allFull.Rows[i]["ActivitiesType"], "\">", allFull.Rows[i]["ActivitiesName"].ToString(), "满", decimal.Parse(allFull.Rows[i]["MeetMoney"].ToString()).ToString("0"), "减", decimal.Parse(allFull.Rows[i]["ReductionMoney"].ToString()).ToString("0"), "</a> </span></div>" }); } else { object obj3 = this.litActivities.Text; this.litActivities.Text = string.Concat(new object[] { obj3, "<div class=\"action actionnone\"><span class=\"purchase\"><a href=\"/Vshop/ActivityDetail.aspx?ActivitiesId=", allFull.Rows[i]["ActivitiesId"], "&CategoryId=", allFull.Rows[i]["ActivitiesType"], "\">", allFull.Rows[i]["ActivitiesName"].ToString(), "满", decimal.Parse(allFull.Rows[i]["MeetMoney"].ToString()).ToString("0"), "减", decimal.Parse(allFull.Rows[i]["ReductionMoney"].ToString()).ToString("0"), "</a> </span></div>" }); } } this.litActivities.Text = this.litActivities.Text + "</div><em> more</em></div>"; } else { this.litActivities.Text = ""; } } if (!string.IsNullOrEmpty(this.litActivities.Text) && (product == null)) { base.GotoResourceNotFound("此商品已不存在"); } if (product.SaleStatus != ProductSaleStatus.OnSale) { base.GotoResourceNotFound("此商品已下架"); } if (this.rptProductImages != null) { string locationUrl = "javascript:;"; SlideImage[] imageArray = new SlideImage[] { new SlideImage(product.ImageUrl1, locationUrl), new SlideImage(product.ImageUrl2, locationUrl), new SlideImage(product.ImageUrl3, locationUrl), new SlideImage(product.ImageUrl4, locationUrl), new SlideImage(product.ImageUrl5, locationUrl) }; this.rptProductImages.DataSource = from item in imageArray where !string.IsNullOrWhiteSpace(item.ImageUrl) select item; this.rptProductImages.DataBind(); } string mainCategoryPath = product.MainCategoryPath; if (!string.IsNullOrEmpty(mainCategoryPath)) { this.hdCategoryId.Value = mainCategoryPath.Split(new char[] { '|' })[0]; } else { this.hdCategoryId.Value = "0"; } this.litProdcutName.Text = product.ProductName; this.hdTemplateid.Value = product.FreightTemplateId.ToString(); this.litSalePoint.Text = productInfo.PointNumber.ToString(); if (product.MarketPrice.HasValue) { this.litMarketPrice.SetWhenIsNotNull(product.MarketPrice.GetValueOrDefault(0M).ToString("F2")); } this.litShortDescription.Text = product.ShortDescription; if (this.litDescription != null) { this.litDescription.Text = product.Description; } this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString()); int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(this.exchangeId, this.productId); int num3 = ((productInfo.ProductNumber - productExchangedCount) >= 0) ? (productInfo.ProductNumber - productExchangedCount) : 0; this.litStock.Text = num3.ToString(); this.hdStock.Value = num3.ToString(); this.litEachCount.Text = productInfo.EachMaxNumber.ToString(); this.hdEachCount.Value = productInfo.EachMaxNumber.ToString(); this.hdUserExchanged.Value = PointExChangeHelper.GetUserProductExchangedCount(this.exchangeId, this.productId, currentMember.UserId).ToString(); this.skuSelector.ProductId = this.productId; if (this.expandAttr != null) { this.expandAttr.ProductId = this.productId; } if (this.linkDescription != null) { this.linkDescription.NavigateUrl = "/Vshop/ProductDescription.aspx?productId=" + this.productId; } int productConsultationsCount = ProductBrowser.GetProductConsultationsCount(this.productId, false, currentMember.UserId); this.litConsultationsCount.SetWhenIsNotNull(productConsultationsCount.ToString()); this.litReviewsCount.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(this.productId, currentMember.UserId).ToString()); bool flag = false; flag = ProductBrowser.CheckHasCollect(currentMember.UserId, this.productId); this.hdHasCollected.SetWhenIsNotNull(flag ? "1" : "0"); ProductBrowser.UpdateVisitCounts(this.productId); PageTitle.AddSiteNameTitle("积分商品"); SiteSettings masterSettings = SettingsManager.GetMasterSettings(false, wid); string str3 = ""; if (!string.IsNullOrEmpty(masterSettings.GoodsPic)) { str3 = Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic; } this.litItemParams.Text = string.Concat(new object[] { str3, "|", masterSettings.GoodsName, "|", masterSettings.GoodsDescription, "$", Globals.HostPath(HttpContext.Current.Request.Url), product.ImageUrl1, "|", this.litProdcutName.Text, "|", product.ShortDescription, "|", HttpContext.Current.Request.Url }); } } else { HttpContext.Current.Response.Redirect("/vshop/"); HttpContext.Current.Response.End(); } }