protected void BuyProductFromAdOrMarketplaceBalance_Click(object sender, EventArgs e) { ErrorMessage.Text = string.Empty; ErrorMessagePanel.Visible = false; var targetBalance = BalanceType.PurchaseBalance; if (((Button)sender).ID == "BuyProductFromMarketplaceBalance") { targetBalance = BalanceType.MarketplaceBalance; } try { int productId = Convert.ToInt32(((Button)sender).CommandArgument); int quantity = Convert.ToInt32(ProductInfoBuyCount.Text); string deliveryAddress = InputChecker.HtmlEncode(DeliveryAddressTextBox.Text, DeliveryAddressTextBox.MaxLength, U6005.DELIVERYADDRESS); string email = EmailTextBox.Text.Trim(); int?promotorId; if (Request.Params.Get("ref") != null) { promotorId = int.Parse(Request.Params.Get("ref")); } else { promotorId = null; } MarketplaceProduct product = new MarketplaceProduct(productId); product.Buy(Member.Current, quantity, deliveryAddress, email, targetBalance); MarketplaceAdd_BannerImage.ImageUrl = null; Response.Redirect("~/user/advert/marketplace.aspx?s=t"); } catch (MsgException ex) { ErrorMessage.Text = ex.Message; ErrorMessagePanel.Visible = true; } catch (Exception ex) { ErrorLogger.Log(ex); } }