// This sorts the stores so they are in decending order by the number of the first item on the wanted list. // If they have the same number, then they are ordered by the number of the second item, etc. private List <Store> SortStoresByNumberOfFirstSeveralItems(List <Store> storeList, List <Item> itemList) { StoreComparer sc = new StoreComparer(itemList); storeList.Sort(sc); return(storeList); }
protected void lvFeatProd_ItemDataBound(object sender, ListViewItemEventArgs e) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; AggProduct p = (AggProduct)dataItem.DataItem; StoreComparer comparer = new StoreComparer(p); string img_format = "s.jpg"; HyperLink prod_link1F = (HyperLink)e.Item.FindControl("prod_link1F"); HyperLink prod_link2F = (HyperLink)e.Item.FindControl("prod_link2F"); Literal prod_manF = (Literal)e.Item.FindControl("prod_manF"); Literal prod_nameF = (Literal)e.Item.FindControl("prod_nameF"); Literal priceShop1F = (Literal)e.Item.FindControl("priceShop1F"); Literal priceShop2F = (Literal)e.Item.FindControl("priceShop2F"); Literal priceShop3F = (Literal)e.Item.FindControl("priceShop3F"); Literal ltShop1BestBuyF = (Literal)e.Item.FindControl("ltShop1BestBuyF"); Literal ltShop2BestBuyF = (Literal)e.Item.FindControl("ltShop2BestBuyF"); Literal ltShop3BestBuyF = (Literal)e.Item.FindControl("ltShop3BestBuyF"); HyperLink hlShop1F = (HyperLink)e.Item.FindControl("hlShop1F"); HyperLink hlShop2F = (HyperLink)e.Item.FindControl("hlShop2F"); HyperLink hlShop3F = (HyperLink)e.Item.FindControl("hlShop3F"); Image prod_imgF = (Image)e.Item.FindControl("prod_imgF"); Panel pShop1F = (Panel)e.Item.FindControl("pShop1F"); Panel pShop2F = (Panel)e.Item.FindControl("pShop2F"); Panel pShop3F = (Panel)e.Item.FindControl("pShop3F"); prod_link1F.NavigateUrl = "~/ViewProduct.aspx?id=" + p.prod_id; prod_link2F.NavigateUrl = "~/ViewProduct.aspx?id=" + p.prod_id; prod_manF.Text = p.AggManufacter.man_name; prod_nameF.Text = p.prod_name; priceShop1F.Text += "€ " + comparer.CpPrice; priceShop2F.Text += "€ " + comparer.UthPrice; priceShop3F.Text += "€ " + comparer.XhPrice; hlShop1F.NavigateUrl = "localhost/app1/ViewProduct.aspx?id=" + p.cp_id; hlShop2F.NavigateUrl = "localhost/app2/ViewProduct.aspx?id=" + p.uth_id; hlShop3F.NavigateUrl = "localhost/app3/ViewProduct.aspx?id=" + p.xh_id; prod_imgF.ImageUrl = "~/ViewImage.aspx?img=" + p.img_id + img_format; if (comparer.CpPrice < 0) { pShop1F.Visible = false; } if (comparer.UthPrice < 0) { pShop2F.Visible = false; } if (comparer.XhPrice < 0) { pShop3F.Visible = false; } ltShop1BestBuyF.Visible = comparer.CpIsBestBuy; ltShop2BestBuyF.Visible = comparer.UthIsBestBuy; ltShop3BestBuyF.Visible = comparer.XhIsBestBuy; if (comparer.CpIsBestBuy) { pShop1F.CssClass = "bestbuy"; } else if (comparer.UthIsBestBuy) { pShop2F.CssClass = "bestbuy"; } else if (comparer.XhIsBestBuy) { pShop3F.CssClass = "bestbuy"; } }
protected void lvProdDetail_ItemDataBound(object sender, ListViewItemEventArgs e) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; AggProduct p = (AggProduct)dataItem.DataItem; StoreComparer comparer = new StoreComparer(p); string img_medium = "m.jpg"; string img_large = "l.jpg"; Literal prod_man = (Literal)e.Item.FindControl("prod_man"); prod_man.Text += p.AggManufacter.man_name; Literal prod_name = (Literal)e.Item.FindControl("prod_name"); prod_name.Text += p.prod_name; HyperLink hlEnlargeImage = (HyperLink)e.Item.FindControl("hlEnlargeImage"); hlEnlargeImage.NavigateUrl = "~/ViewImage.aspx?img=" + p.img_id.ToString() + img_large; hlEnlargeImage.Attributes.Add("rel", "lightbox"); hlEnlargeImage.Attributes.Add("title", p.AggManufacter.man_name + " " + p.prod_name); Image imgProductMedium = (Image)e.Item.FindControl("imgProductMedium"); imgProductMedium.ImageUrl = "~/ViewImage.aspx?img=" + p.img_id.ToString() + img_medium; HyperLink prod_link1 = (HyperLink)e.Item.FindControl("prod_link1"); HyperLink prod_link2 = (HyperLink)e.Item.FindControl("prod_link2"); Literal priceShop1 = (Literal)e.Item.FindControl("priceShop1"); Literal priceShop2 = (Literal)e.Item.FindControl("priceShop2"); Literal priceShop3 = (Literal)e.Item.FindControl("priceShop3"); Literal ltShop1BestBuy = (Literal)e.Item.FindControl("ltShop1BestBuy"); Literal ltShop2BestBuy = (Literal)e.Item.FindControl("ltShop2BestBuy"); Literal ltShop3BestBuy = (Literal)e.Item.FindControl("ltShop3BestBuy"); Literal ltInfoShop1 = (Literal)e.Item.FindControl("ltInfoShop1"); Literal ltInfoShop2 = (Literal)e.Item.FindControl("ltInfoShop2"); Literal ltInfoShop3 = (Literal)e.Item.FindControl("ltInfoShop3"); HyperLink hlShop1 = (HyperLink)e.Item.FindControl("hlShop1"); HyperLink hlShop2 = (HyperLink)e.Item.FindControl("hlShop2"); HyperLink hlShop3 = (HyperLink)e.Item.FindControl("hlShop3"); Image prod_img = (Image)e.Item.FindControl("prod_img"); PlaceHolder pShop1 = (PlaceHolder)e.Item.FindControl("pShop1"); PlaceHolder pShop2 = (PlaceHolder)e.Item.FindControl("pShop2"); PlaceHolder pShop3 = (PlaceHolder)e.Item.FindControl("pShop3"); prod_man.Text = p.AggManufacter.man_name; prod_name.Text = p.prod_name; priceShop1.Text += "€ " + comparer.CpPrice; priceShop2.Text += "€ " + comparer.UthPrice; priceShop3.Text += "€ " + comparer.XhPrice; hlShop1.NavigateUrl = "localhost/app1/ViewProduct.aspx?id=" + p.cp_id; hlShop2.NavigateUrl = "localhost/app2/ViewProduct.aspx?id=" + p.uth_id; hlShop3.NavigateUrl = "localhost/app3/ViewProduct.aspx?id=" + p.xh_id; ltInfoShop1.Text += comparer.CpStock + " unit(s) in stock and can deliver on " + comparer.CpDate.ToShortDateString() + "."; ltInfoShop2.Text += comparer.UthStock + " unit(s) in stock and can deliver on " + comparer.UthDate.ToShortDateString() + "."; ltInfoShop3.Text += comparer.XhStock + " unit(s) in stock and can deliver on " + comparer.XhDate.ToShortDateString() + "."; if (comparer.CpPrice < 0) { pShop1.Visible = false; } if (comparer.UthPrice < 0) { pShop2.Visible = false; } if (comparer.XhPrice < 0) { pShop3.Visible = false; } ltShop1BestBuy.Visible = comparer.CpIsBestBuy; ltShop2BestBuy.Visible = comparer.UthIsBestBuy; ltShop3BestBuy.Visible = comparer.XhIsBestBuy; }
protected void lvProducts_ItemDataBound(object sender, ListViewItemEventArgs e) { ListViewDataItem dataItem = (ListViewDataItem)e.Item; AggProduct p = (AggProduct)dataItem.DataItem; StoreComparer comparer = new StoreComparer(p); string img_format = "s.jpg"; HyperLink prod_link1 = (HyperLink)e.Item.FindControl("prod_link1"); HyperLink prod_link2 = (HyperLink)e.Item.FindControl("prod_link2"); Literal prod_man = (Literal)e.Item.FindControl("prod_man"); Literal prod_name = (Literal)e.Item.FindControl("prod_name"); Literal priceShop1 = (Literal)e.Item.FindControl("priceShop1"); Literal priceShop2 = (Literal)e.Item.FindControl("priceShop2"); Literal priceShop3 = (Literal)e.Item.FindControl("priceShop3"); Literal ltShop1BestBuy = (Literal)e.Item.FindControl("ltShop1BestBuy"); Literal ltShop2BestBuy = (Literal)e.Item.FindControl("ltShop2BestBuy"); Literal ltShop3BestBuy = (Literal)e.Item.FindControl("ltShop3BestBuy"); HyperLink hlShop1 = (HyperLink)e.Item.FindControl("hlShop1"); HyperLink hlShop2 = (HyperLink)e.Item.FindControl("hlShop2"); HyperLink hlShop3 = (HyperLink)e.Item.FindControl("hlShop3"); Image prod_img = (Image)e.Item.FindControl("prod_img"); DataPager dpProducts = (DataPager)lvProducts.FindControl("dpProducts"); Panel pShop1 = (Panel)e.Item.FindControl("pShop1"); Panel pShop2 = (Panel)e.Item.FindControl("pShop2"); Panel pShop3 = (Panel)e.Item.FindControl("pShop3"); prod_link1.NavigateUrl = "~/ViewProduct.aspx?id=" + p.prod_id; prod_link2.NavigateUrl = "~/ViewProduct.aspx?id=" + p.prod_id; prod_man.Text = p.AggManufacter.man_name; prod_name.Text = p.prod_name; priceShop1.Text += "€ " + comparer.CpPrice; priceShop2.Text += "€ " + comparer.UthPrice; priceShop3.Text += "€ " + comparer.XhPrice; hlShop1.NavigateUrl = "localhost/app1/ViewProduct.aspx?id=" + p.cp_id; hlShop2.NavigateUrl = "localhost/app2/ViewProduct.aspx?id=" + p.uth_id; hlShop3.NavigateUrl = "localhost/app3/ViewProduct.aspx?id=" + p.xh_id; prod_img.ImageUrl = "~/ViewImage.aspx?img=" + p.img_id + img_format; dpProducts.Visible = (howManyResults > dpProducts.PageSize); if (comparer.CpPrice < 0) { pShop1.Visible = false; } if (comparer.UthPrice < 0) { pShop2.Visible = false; } if (comparer.XhPrice < 0) { pShop3.Visible = false; } ltShop1BestBuy.Visible = comparer.CpIsBestBuy; ltShop2BestBuy.Visible = comparer.UthIsBestBuy; ltShop3BestBuy.Visible = comparer.XhIsBestBuy; if (comparer.CpIsBestBuy) { pShop1.CssClass = "bestbuy"; } else if (comparer.UthIsBestBuy) { pShop2.CssClass = "bestbuy"; } else if (comparer.XhIsBestBuy) { pShop3.CssClass = "bestbuy"; } }
// This sorts the stores so they are in decending order by the number of the first item on the wanted list. // If they have the same number, then they are ordered by the number of the second item, etc. private List<Store> SortStoresByNumberOfFirstSeveralItems(List<Store> storeList, List<Item> itemList) { StoreComparer sc = new StoreComparer(itemList); storeList.Sort(sc); return storeList; }