private void SetProductItemLinks() { foreach (DataListItem li in ProductList.Items) { Label hdnProductID = (Label)li.FindControl("hdnProductID"); Label hdnProductExtra = (Label)li.FindControl("hdnProductExtra"); //Setting Productlist link string culture = "en-US"; if (Session["culture"] != null) culture = Session["culture"] as string; HyperLink HLBuyProduct = (HyperLink)li.FindControl("HLBuyProduct"); ClientInfo ci = null; long userId = Util.UserId; using (Database db = new MySqlDatabase()) { if (userId > -1) ci = db.GetClientInfo(userId); string currency = "EUR"; string countryIso2 = "NL"; string currencyFmt = "{0} {1:N2}"; if (ci != null) { countryIso2 = Util.GetCountryIso2(ci.Country); currency = Util.GetCurrencyIsoNameByCountryIso2("NL"); currencyFmt = Util.GetCurrencyFormatByCountryIso2("NL"); } ProductPriceInfoList ppil = db.GetProductPrices(Convert.ToInt32(hdnProductID.Text.Trim()), culture); if (ppil[0].Price > 0m) { string price = Convert.ToString(ppil[0].Price); if (price.Contains(".")) { price = price.Replace(".", ","); } // Normal products, just process them if (hdnProductExtra.Text.Trim().ToLower() != "subscription") { //HLBuyProduct.NavigateUrl = string.Format(Session["userid"] != null ? // "~/Member/BuyProduct.aspx?pid={0}&country={1}&price={2}" : // "~/Account/Login.aspx?pid={0}&country={1}&price={2}", // Convert.ToInt32(hdnProductID.Text.Trim()), countryIso2, ppil[0].Price); HLBuyProduct.NavigateUrl = string.Format(Session["userid"] != null ? "~/Member/BuyProduct.aspx?pid={0}&country={1}&price={2}" : "~/Account/Login.aspx?pid={0}&country={1}&price={2}", Convert.ToInt32(hdnProductID.Text.Trim()), "NL", price); } else { //HLBuyProduct.NavigateUrl = string.Format(Session["userid"] != null // ? "~/Member/Subscription.aspx?pid={0}&country={1}&price={2}" // : "~/Account/Login.aspx?pid={0}&country={1}&price={2}", // Convert.ToInt32(hdnProductID.Text.Trim()), countryIso2, ppil[0].Price); HLBuyProduct.NavigateUrl = string.Format(Session["userid"] != null ? "~/Member/Subscription.aspx?pid={0}&country={1}&price={2}" : "~/Account/Login.aspx?pid={0}&country={1}&price={2}", Convert.ToInt32(hdnProductID.Text.Trim()), "NL", price); } } else { HLBuyProduct.NavigateUrl = string.Format(Session["userid"] != null ? "~/Member/Subscription.aspx?pid={0}&country={1}&price={2}" : "~/Account/Login.aspx?pid={0}&country={1}&price={2}", Convert.ToInt32(hdnProductID.Text.Trim()), countryIso2, 0); } } } }
protected void SubscriptionSubmit_Click(object sender, EventArgs e) { int ecl, vcl; Util.GetUserClearanceLevels(Util.UserId, out vcl, out ecl); int qty = 0; if (int.TryParse(QuantityEdit.Text, out qty)) { int prodid = (int)Session["subscription.productid"]; decimal unitprice = (decimal)Session["subscription.unitprice"]; decimal baseprice = 0m; string desc = string.Empty; ProductInfo pi; using (Database db = new MySqlDatabase()) { pi = db.GetProductById(prodid); if (ecl < 100 || vcl < 100) { ProductPriceInfoList ppil = db.GetProductPrices(prodid, Request.Params["country"]); desc = pi.Name; baseprice = ppil[0].Price; } } decimal totalprice = baseprice + (unitprice * qty); Session["amt"] = totalprice; if (pi.Extra.Length > 0) pi.Extra += "\x01"; pi.Extra += string.Format("{0:F2}", baseprice); List<ProductInfo> products = new List<ProductInfo>(); if (baseprice > 0m) products.Add(pi); string name = string.Format("{0} credits", qty); //desc = string.Format("{0} credits @ EUR {1:F2}", qty, unitprice); desc = string.Format("Managed Plan {0} credits", qty); pi = new ProductInfo(0, name, desc, qty, unitprice.ToString()); if (baseprice == 0m) pi.Extra = "subscription"; products.Add(pi); PurchaseProduct(prodid, totalprice, desc, products.ToArray()); } }
private void getProductList(long userId) { int ecl = 0; int vcl = 0; Util.GetUserClearanceLevels(userId, out ecl, out vcl); List<Product> listProductInformation = new List<Product>(); using (Database db = new MySqlDatabase()) { ClientInfo ci = null; if (userId > -1) ci = db.GetClientInfo(userId); string currency = "EUR"; string countryIso2 = "NL"; string currencyFmt = "{0} {1:N2}"; if (ci != null) { countryIso2 = Util.GetCountryIso2(ci.Country); currency = Util.GetCurrencyIsoNameByCountryIso2("NL"); currencyFmt = Util.GetCurrencyFormatByCountryIso2("NL"); } string culture = "en-US"; if (Session["culture"] != null) culture = Session["culture"] as string; if (culture.Length == 2) { switch (culture) { case "nl": culture += "-NL"; break; case "en": culture += "US"; break; case "NL": culture = "nl-" + culture; break; case "US": culture = "en" + culture; break; } } ProductInfoList pil = db._GetProducts(); foreach (ProductInfo prod in pil) { String price = string.Empty; ProductPriceInfoList ppil = db.GetProductPrices(prod.ProductId, culture); if (ppil[0].Price > 0m) { price = string.Format( currencyFmt, Util.GetCurrencySymbolByCountryIso2("NL"), ppil[0].Price); } else { price = Resources.Resource.Quotation; } string desc = db.GetProduct_Desc_Price(prod.ProductId, culture); Product _product = new Product(); if (ecl >= 100 && vcl >= 100 && prod.ProductId == 4) _product.ProductPlan = Resources.Resource.ManagedPlan; else _product.ProductPlan = prod.ProductPlan; if (prod.Credits <= 0) _product.Credits = string.Empty; else _product.Credits = Convert.ToString(prod.Credits); _product.ProductDesc = desc.Split('#')[0]; _product.ProductPrice = desc.Split('#')[1]; _product.ProductId = prod.ProductId; _product.Extra = prod.Extra; if (ecl >= 100 && vcl >= 100 && prod.ProductId == 4) _product.Price = string.Empty; else _product.Price = price; listProductInformation.Add(_product); } if (ecl >= 100 && vcl >= 100) { List<Product> productInfoList = new List<Product>(); List<Product> unmanagedProductList = new List<Product>(); List<Product> managedProductList = new List<Product>(); int count = 0; foreach (Product product in listProductInformation) { if (count < 3) unmanagedProductList.Add(product); else managedProductList.Add(product); count++; } foreach (var _managedProduct in managedProductList) { productInfoList.Add(_managedProduct); } foreach (var _unmanagedProduct in unmanagedProductList) { productInfoList.Add(_unmanagedProduct); } ProductList.DataSource = productInfoList; } else { ProductList.DataSource = listProductInformation; } ProductList.DataBind(); } }