private void CreateSliderAndFav(Product pdt, int position, string itemCssClass, int carouselPosition, ref Panel favCarousel, ref HtmlGenericControl slider, string sliderId) { Panel item = new Panel(); item.CssClass = itemCssClass; HyperLink link = new HyperLink(); System.Web.UI.WebControls.Image fav = new System.Web.UI.WebControls.Image(); link.Controls.Add(fav); fav.ImageUrl = pdt.GetThumbnailUrl(); fav.AlternateText = pdt.name; link.NavigateUrl = "javascript:sliderselect(" + position + "," + carouselPosition + ")"; link.ToolTip = pdt.name; item.Controls.Add(link); favCarousel.Controls.Add(item); HtmlGenericControl newLi = new HtmlGenericControl("li"); Panel productPanel = new Panel(); productPanel.ID = sliderId + "div" + carouselPosition.ToString(); productPanel.CssClass = position == 1 ? "product-image" : "product-small-image"; ProductHyperLink pdtlink = new ProductHyperLink(pdt); pdtlink.NavigateUrl = pdt.AffiliateUrl; System.Web.UI.WebControls.Image pdtImg = new System.Web.UI.WebControls.Image(); pdtImg.ImageUrl = position == 1 ? pdt.GetImageUrl() : pdt.GetNormalImageUrl(); pdtImg.AlternateText = pdt.name; pdtImg.ToolTip = pdt.name; pdtImg.ID = "pdt-" + pdt.id.ToString(); pdtlink.Controls.Add(pdtImg); pdtImg.Attributes.Add("color", pdt.GetColor()); productPanel.Controls.Add(pdtlink); newLi.Controls.Add(productPanel); slider.Controls.Add(newLi); }
private void GetFavoriteProduct() { string db = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString; string query = "EXEC [stp_SS_GetLovesByCategoryWithColor] @uId=" + this.userId + ", @position=" + this.position + ",@color=N'" + this.color + "',@contestId=" + this.contestId + ",@categoryId=N'" + this.category + "'"; SqlConnection myConnection = new SqlConnection(db); try { myConnection.Open(); using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection)) { SqlCommand cmd = adp.SelectCommand; cmd.CommandTimeout = 300000; System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader(); IList <Product> loves = new List <Product>(); while (dr.Read()) { Product p = Product.GetProductFromSqlDataReader(dr); loves.Add(p); } string itemCssClass = "fav-image", sliderId = "sliderCreate", shapeClass = "create-big-shape", contentClass = "create-content-text"; string text = "SELECT A DRESS"; if (position > 1) { itemCssClass += ("_" + position); sliderId += position; text = position == 2 ? "SELECT A HANDBAG" : "SELECT A SHOE"; shapeClass = "create-small-shape"; contentClass = "create-content-small-text"; } Panel favCarousel = new Panel(); Panel slider = new Panel(); //add the emoty box HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(new LiteralControl("<div class=\"" + shapeClass + "\"><div class=\"" + contentClass + "\"><strong>" + text + "</strong><br>FROM FAVORITES</div></div>")); slider.Controls.Add(li); int carouselPosition = 1; foreach (ShopSenseDemo.Product love in loves) { Panel item = new Panel(); item.CssClass = itemCssClass; HyperLink link = new HyperLink(); System.Web.UI.WebControls.Image fav = new System.Web.UI.WebControls.Image(); link.Controls.Add(fav); fav.ImageUrl = love.GetThumbnailUrl(); fav.AlternateText = love.name; link.NavigateUrl = "javascript:sliderselect(" + position + "," + carouselPosition + ")"; link.ToolTip = love.name; item.Controls.Add(link); favCarousel.Controls.Add(item); //Add the item to the top slider HtmlGenericControl newLi = new HtmlGenericControl("li"); Panel productPanel = new Panel(); productPanel.ID = "MainContent_" + sliderId + "div" + carouselPosition.ToString(); productPanel.CssClass = position == 1 ? "product-image" : "product-small-image"; ProductHyperLink pdtlink = new ProductHyperLink(love); pdtlink.NavigateUrl = love.AffiliateUrl; System.Web.UI.WebControls.Image pdtImg = new System.Web.UI.WebControls.Image(); pdtImg.ImageUrl = position == 1 ? love.GetImageUrl() : love.GetNormalImageUrl(); pdtImg.AlternateText = love.name; pdtImg.ToolTip = love.name; pdtImg.ID = "pdt-" + love.id.ToString(); pdtlink.Controls.Add(pdtImg); productPanel.Controls.Add(pdtlink); newLi.Controls.Add(productPanel); slider.Controls.Add(newLi); carouselPosition++; } ProductsMessage msg = new ProductsMessage(); msg.Position = position; msg.FavoriteHtml = WebHelper.RenderHtml(favCarousel); msg.SliderHtml = WebHelper.RenderHtml(slider); msg.Color = this.color; msg.Category = this.category; string callbackName = Request.QueryString["callback"]; Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(ProductsMessage), msg) + ");"); } } finally { myConnection.Close(); } }
public void SaveVote() { string db = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString; string query = "EXEC [stp_SS_SaveVote] @uid=" + this.userId + ", @lid=" + this.lookId + ", @vote=" + this.vote.GetHashCode() + ", @pointinc=" + this.pointIncrement; SqlConnection myConnection = new SqlConnection(db); try { myConnection.Open(); using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection)) { SqlCommand cmd = adp.SelectCommand; cmd.CommandTimeout = 300000; cmd.ExecuteNonQuery(); } if (this.isLightWeight) { return; } Look look = Look.GetRandomLook(this.contestId, this.userId, db); VoteStatusMessage msg = new VoteStatusMessage(); msg.Look = look; bool P1love, P2love, P3love; IList <ShopSenseDemo.Product> loves = UserProfile.GetLovesByUserId(this.userId, look, this.retailerId, db, out P1love, out P2love, out P3love); //set up th product panel li Panel itemWrapper = new Panel(); itemWrapper.CssClass = "items-wrapper"; if (look.products.Count == 3) { Panel leftItem = WebHelper.GetProductPanel("left3Item", look.products[0], true, true, P1love, false); Panel plusItem = new Panel(); plusItem.CssClass = "plus-content-3items"; plusItem.Controls.Add(new LiteralControl("+")); Panel rightItem = new Panel(); rightItem.CssClass = "right-content-parts-wrapper"; rightItem.Controls.Add(new LiteralControl("<center>")); Panel rightUpperItem = WebHelper.GetProductPanel("rightUpperSmall", look.products[1], true, true, P2love, false); Panel rightLowerItem = WebHelper.GetProductPanel("rightLowerSmall", look.products[2], true, true, P3love, false); rightItem.Controls.Add(rightUpperItem); rightItem.Controls.Add(rightLowerItem); rightItem.Controls.Add(new LiteralControl("</center>")); itemWrapper.Controls.Add(leftItem); itemWrapper.Controls.Add(plusItem); itemWrapper.Controls.Add(rightItem); } else { Panel leftItem = WebHelper.GetProductPanel("left", look.products[0], true, true, P1love, false); Panel plusItem = new Panel(); plusItem.CssClass = "plus-content"; plusItem.Controls.Add(new LiteralControl("+")); Panel rightItem = WebHelper.GetProductPanel("right", look.products[1], true, true, P2love, false); itemWrapper.Controls.Add(leftItem); itemWrapper.Controls.Add(plusItem); itemWrapper.Controls.Add(rightItem); } msg.ProductsHtml = WebHelper.RenderHtml(itemWrapper); msg.VoteType = this.vote.ToString(); Panel favorites = new Panel(); foreach (ShopSenseDemo.Product love in loves) { Panel panel = new Panel(); panel.CssClass = "fav-image"; ProductHyperLink link = new ProductHyperLink(love); System.Web.UI.WebControls.Image fav = new System.Web.UI.WebControls.Image(); link.Controls.Add(fav); fav.ImageUrl = love.GetThumbnailUrl(); fav.AlternateText = love.name; panel.Controls.Add(link); favorites.Controls.Add(panel); } if (loves.Count < 7) { for (int i = 0; i < 7 - loves.Count; i++) { Panel panel = new Panel(); panel.CssClass = "fav-image-standart"; favorites.Controls.Add(panel); } } msg.FavoritesHtml = WebHelper.RenderHtml(favorites); //set follower bit msg.IsFollower = UserProfile.IsFollower(msg.Look.creator.userId, this.userId, db) ? 1 : 0; string callbackName = Request.QueryString["callback"]; Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(VoteStatusMessage), msg) + ");"); } finally { myConnection.Close(); } }
public static Panel GetProductPanel(string position, Product product, bool isContentPanel = false, bool isLovePanel = false, bool isProductLoved = false, bool isPricePanel = false) { Panel productPanel = new Panel(); bool bigImage = true; string panelCss = string.Empty, productImageCss = "product-image", lovePanelId = string.Empty, loveLabelId = string.Empty, loveImageId = string.Empty; switch (position) { case "left": panelCss = "left-item-wrapper"; lovePanelId = "MainContent_P1LoveButton"; loveLabelId = "MainContent_P1Love"; loveImageId = "MainContent_P1LoveImg"; break; case "left3Item": panelCss = "left-item-wrapper-more"; lovePanelId = "MainContent_P1LoveButton"; loveLabelId = "MainContent_P1Love"; loveImageId = "MainContent_P1LoveImg"; break; case "right": panelCss = "right-item-wrapper"; lovePanelId = "MainContent_P2LoveButton"; loveLabelId = "MainContent_P2Love"; loveImageId = "MainContent_P2LoveImg"; break; case "rightUpperSmall": panelCss = ""; bigImage = false; lovePanelId = "MainContent_P2LoveButton"; loveLabelId = "MainContent_P2Love"; loveImageId = "MainContent_P2LoveImg"; productImageCss = "product-small-image"; break; case "rightLowerSmall": panelCss = ""; bigImage = false; lovePanelId = "MainContent_P3LoveButton"; loveLabelId = "MainContent_P3Love"; loveImageId = "MainContent_P3LoveImg"; productImageCss = "product-small-image"; break; } productPanel.CssClass = panelCss; ProductHyperLink productLink = new ProductHyperLink(product); productPanel.Controls.Add(productLink); Panel productImage = new Panel(); productImage.CssClass = productImageCss; System.Web.UI.WebControls.Image fav = new System.Web.UI.WebControls.Image(); productImage.Controls.Add(fav); fav.ImageUrl = bigImage == true?product.GetImageUrl() : product.GetNormalImageUrl(); fav.AlternateText = product.name; productLink.Controls.Add(productImage); //if lovepanel needs to be included if (isLovePanel) { Panel lovePanel = new Panel(); lovePanel.ID = lovePanelId; Label loveCount = new Label(); loveCount.ID = loveLabelId; System.Web.UI.WebControls.Image loveImg = new System.Web.UI.WebControls.Image(); loveImg.Style.Add(HtmlTextWriterStyle.VerticalAlign, "middle"); loveImg.Style.Add(HtmlTextWriterStyle.Width, "24px"); loveImg.Style.Add(HtmlTextWriterStyle.MarginLeft, "8px"); loveImg.ID = loveImageId; loveImg.ToolTip = "Love It"; loveImg.AlternateText = "Love It"; HyperLink buylink = new HyperLink(); buylink.Text = "Buy"; buylink.Target = "_blank"; buylink.NavigateUrl = product.AffiliateUrl; buylink.CssClass = "buylink"; lovePanel.Controls.Add(loveCount); lovePanel.Controls.Add(loveImg); lovePanel.Controls.Add(buylink); productPanel.Controls.Add(lovePanel); loveCount.Text = product.loves.ToString(); if (isProductLoved) { lovePanel.CssClass = "text-heart-red"; loveImg.ImageUrl = "images/heart_filled.jpg"; } else { lovePanel.CssClass = "text-heart"; loveImg.ImageUrl = "images/heart_empty.jpg"; } } if (isContentPanel) { Panel productContentPanel = new Panel(); productContentPanel.CssClass = "item-content"; //ProductHyperLink brandTitle = new ProductHyperLink(product); //brandTitle.CssClass += " brandTitle"; //brandTitle.Text = product.GetBrandName(); //productContentPanel.Controls.Add(brandTitle); Panel productTitlePanel = new Panel(); ProductHyperLink pdtTitle = new ProductHyperLink(product); pdtTitle.CssClass += " pdtTitle"; pdtTitle.Text = product.GetName(); productTitlePanel.Controls.Add(pdtTitle); productContentPanel.Controls.Add(productTitlePanel); productPanel.Controls.Add(productContentPanel); } if (isPricePanel) { Panel productPrice = new Panel(); productPrice.CssClass = "price-content"; Label price = new Label(); price.CssClass = "inline"; price.Text = string.Format("{0:c}", product.price); productPrice.Controls.Add(price); if (product.salePrice != 0) { price.CssClass += " strike-through"; Label salePrice = new Label(); salePrice.CssClass = "inline"; salePrice.Text = string.Format("{0:c}", product.salePrice); productPrice.Controls.Add(salePrice); } productPanel.Controls.Add(productPrice); } return(productPanel); }