protected void dlProduct_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Product product = e.Item.DataItem as Product; Literal ltImage = e.Item.FindControl("ltImage") as Literal; if (ltImage != null) { ltImage.Text = "<div class=\"productImage\" style=\"background-image:url(" + GlobalSettings.RelativeWebRoot + product.GetDefaultImageUrl(100, 100) + ")\"></div>"; } Literal ltPrice = e.Item.FindControl("ltPrice") as Literal; if (ltPrice != null) { decimal?p1 = null; decimal?p2 = null; decimal?p = null; string priceText = string.Empty; if (!Context.User.Identity.IsAuthenticated) { p1 = ProductPrices.GetPriceDefault(product.ProductID); p2 = IsPromote(product.ProductID) ? ProductPrices.GetPricePromote(0, product.ProductID) : null; priceText = GlobalSettings.GetPrice(p1, p2); } else { p1 = ProductPrices.GetPriceMarket(Profile.AccountInfo.UserID, product.ProductID); p2 = ProductPrices.GetPriceMember(Profile.AccountInfo.UserID, product.ProductID); p = IsPromote(product.ProductID) ?ProductPrices.GetPricePromote(Profile.AccountInfo.UserID, product.ProductID):null; priceText = GlobalSettings.GetPrice(true, p, GlobalSettings.GetMinPrice(p1, p2)); } ltPrice.Text = priceText; } } }
string GetPrice(int pId) { decimal?price1 = null; decimal?price2 = null; decimal?price3 = null; decimal?p = null; if (Context.User.Identity.IsAuthenticated) { SettingsPropertyValueCollection spvc = this.Context.Profile.PropertyValues; User u = spvc["AccountInfo"].PropertyValue as User; price1 = ProductPrices.GetPriceMarket(u.UserID, pId); price2 = ProductPrices.GetPriceMember(u.UserID, pId); price3 = ProductPrices.GetPricePromote(u.UserID, pId); p = GlobalSettings.GetMinPrice(price1, price2); return(GlobalSettings.GetPrice(p, price3)); } else { price1 = ProductPrices.GetPriceDefault(pId); price3 = ProductPrices.GetPricePromote(0, pId); return(GlobalSettings.GetPrice(price1, price3)); } }
void BindPrice(int pId) { decimal?p = null, p1 = null, p2 = null; string priceText = string.Empty; if (!Context.User.Identity.IsAuthenticated) { p1 = ProductPrices.GetPriceDefault(pId); p2 = IsPromote(pId) ? ProductPrices.GetPricePromote(0, pId) : null; if (p2 != null) { lblPrice.Text = "促销价"; ltPrice1.Text = p2.Value.ToString("c"); } else { ltPrice1.Text = (p1 == null ? "需询价" : p1.Value.ToString("c")); } } else { p1 = ProductPrices.GetPriceMarket(Profile.AccountInfo.UserID, pId); p2 = ProductPrices.GetPriceMember(Profile.AccountInfo.UserID, pId); p = IsPromote(pId) ? ProductPrices.GetPricePromote(Profile.AccountInfo.UserID, pId) : null; if (p != null) { lblPrice.Text = "促销价"; ltPrice1.Text = p.Value.ToString("c"); } else { ltPrice1.Text = (p1 == null ? "需询价" : p1.Value.ToString("c")); } ltPrice2.Text = (p2 == null ? "需询价" : p2.Value.ToString("c")); } }