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; } } }
protected void Button41_Click(object sender, EventArgs e) { decimal?price = ProductPrices.GetPriceMarket(10, 23); lblCacheTip.Text = price.HasValue ? price.Value.ToString() : "询价"; price = ProductPrices.GetPriceMember(10, 23); Label5.Text = price.HasValue ? price.Value.ToString() : "询价"; }
protected void egvShoppings_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Literal ltPN = e.Row.FindControl("ltProductName") as Literal; Literal ltMN = e.Row.FindControl("ltModelName") as Literal; Literal ltPC = e.Row.FindControl("ltPrice") as Literal; Shopping shop = (Shopping)e.Row.DataItem; Product p = Products.GetProduct(shop.ProductID); ltPN.Text = string.Format(productFormat, GlobalSettings.Encrypt(p.ProductID.ToString()), p.ProductName, p.ProductAbstract, p.GetDefaultImageUrl(50, 50)); decimal?price1 = null; decimal?price2 = null; if (Profile.IsAnonymous) { price1 = ProductPrices.GetPriceDefault(p.ProductID); } else { price1 = ProductPrices.GetPriceMarket(Profile.AccountInfo.UserID, p.ProductID); price2 = ProductPrices.GetPriceMember(Profile.AccountInfo.UserID, p.ProductID); } ltPC.Text = GlobalSettings.GetPrice(price1, price2); if (shop.ModelID != 0) { ProductModel pm = ProductModels.GetModel(shop.ModelID); ltMN.Text = pm.ModelName; } else { ltMN.Text = "——"; } } }
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")); } }