Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region TabAimer
        int SelectedTab = (Request.Params["SelectedTab"] != null) ? Int32.Parse(Request.Params["SelectedTab"]) : -1;
        if (SelectedTab >= 0)
        {
            MenuMultiView.ActiveViewIndex = SelectedTab;
            int Counter = MenuButtonPlaceHolder.Controls.Count - 1;
            foreach (Button b in MenuButtonPlaceHolder.Controls)
            {
                if (Counter == SelectedTab)
                {
                    b.CssClass = "ViewSelected";
                }
                else
                {
                    b.CssClass = "";
                }
                Counter--;
            }
        }
        #endregion

        #region OpenOfferDetails
        if ((!IsPostBack) && Request.Params.Get("oid") != null)
        {
            try
            {
                MenuMultiView.ActiveViewIndex = 4;

                CryptocurrencyAmount = String.Empty;
                int ProductId = Convert.ToInt32(Request.Params.Get("oid"));

                CryptocurrencyTradeOffer SelectedOffer = new CryptocurrencyTradeOffer(ProductId);

                var OfferCreator        = new Member(SelectedOffer.CreatorId);
                var OfferCreatorBalance = OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC);

                //If creator of offer don't have enaugh currency in balance
                if (OfferCreatorBalance < SelectedOffer.AmountLeft)
                {
                    //If Offer AmountLeft is bigger than creator's balance, set max limit of buy to creator's balacne value
                    SelectedOffer.AmountLeft = OfferCreatorBalance;

                    if (OfferCreatorBalance == CryptocurrencyMoney.Zero)
                    {
                        SelectedOffer.Status = CryptocurrencyOfferStatus.Paused;
                        SelectedOffer.Save();
                        throw new MsgException(U6010.NOCREATORBALANCETOBUYOFFER);
                    }
                    SelectedOffer.Save();
                }

                SelectedOfferId = SelectedOffer.Id;

                decimal CountedMinCurrency, CountedMaxCurrency;

                CountedMinCurrency = decimal.Parse((SelectedOffer.MinOfferValue / SelectedOffer.MinPrice).ToClearString());
                CountedMaxCurrency = decimal.Parse((SelectedOffer.MaxOfferValue / SelectedOffer.MinPrice).ToClearString());
                if (SelectedOffer.AmountLeft < CryptocurrencyMoney.Parse(CountedMaxCurrency.ToString()))
                {
                    CountedMaxCurrency = decimal.Parse(SelectedOffer.AmountLeft.ToClearString());
                }


                Member User = new Member(SelectedOffer.CreatorId);
                CreatorNameLabel.Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                      HtmlCreator.CreateAvatarPlusUsername(User),
                                                      CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

                MinOfferLabel.Text = SelectedOffer.MinOfferValue.ToString();
                MaxOfferLabel.Text = SelectedOffer.MaxOfferValue.ToString();
                CurrencyAvailableToBuyLabel.Text = SelectedOffer.AmountLeft.ToString();

                MinCryptocurrencyAmount = CountedMinCurrency;
                MaxCryptocurrencyAmount = CountedMaxCurrency;
                MinCurrencyLabel.Text   = CryptocurrencyMoney.Parse(CountedMinCurrency.ToString()).ToString();
                MaxCurrencyLabel.Text   = CryptocurrencyMoney.Parse(CountedMaxCurrency.ToString()).ToString();


                PricePerCurrencyLabel.Text = SelectedOffer.MinPrice.ToString();
                PricePerCryptocurrency     = decimal.Parse(SelectedOffer.MinPrice.ToClearString());

                AmountToBuyTextBox.Text = CountedMinCurrency.ToString();

                //Updating Total Price label after every change of Cryptocurrency Amount
                AmountToBuyTextBox.Attributes.Add("onkeyup", "updatePrice();");

                CashToPayLabel.Text = decimal.Round(PricePerCryptocurrency * MinCryptocurrencyAmount, CoreSettings.GetMaxDecimalPlaces()).ToString();

                testerTB.Text       = SelectedOffer.Description;
                Description         = SelectedOffer.Description;
                BuyOfferButton.Text = L1.BUY;
            }
            catch (MsgException ex)
            {
                AllOffersErrorPanel.Visible = true;
                AllOffersErrorLiteral.Text  = ex.Message;
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex.Message);
                throw ex;
            }
        }
        #endregion

        #region OpenAddCommentView
        if ((!IsPostBack) && Request.Params.Get("foid") != null)
        {
            MenuMultiView.ActiveViewIndex = 5;
        }
        #endregion

        if (!IsPostBack)
        {
            AddLang();
        }

        //Constraint DataBind for second ManageTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 2)
        {
            ManageTabDataBind();
        }

        //Constraint DataBind for second HistoryTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 3)
        {
            OfferHistoryGridView.DataBind();
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        CryptocurrencyAmount = String.Empty;

        #region TabAimer
        int SelectedTab = (Request.Params["SelectedTab"] != null) ? Int32.Parse(Request.Params["SelectedTab"]) : -1;
        if (SelectedTab >= 0)
        {
            MenuMultiView.ActiveViewIndex = SelectedTab;
            int Counter = MenuButtonPlaceHolder.Controls.Count - 1;
            foreach (Button b in MenuButtonPlaceHolder.Controls)
            {
                if (Counter == SelectedTab)
                {
                    b.CssClass = "ViewSelected";
                }
                else
                {
                    b.CssClass = "";
                }
                Counter--;
            }
        }
        #endregion

        #region OpenDetailsInfoView
        if ((!IsPostBack) && Request.Params.Get("oid") != null)
        {
            int ProductId = Convert.ToInt32(Request.Params.Get("oid"));

            CryptocurrencyTradeOffer SelectedOffer = new CryptocurrencyTradeOffer(ProductId);
            MenuMultiView.ActiveViewIndex = 4;
            SelectedOfferId = SelectedOffer.Id;

            //Counting min-max currency amount limits to sell
            CryptocurrencyMoney CountedMinCurrency, CountedMaxCurrency;
            CountedMinCurrency = CryptocurrencyMoney.Parse((SelectedOffer.MinOfferValue / SelectedOffer.MaxPrice).ToClearString(), CryptocurrencyType.BTC);
            CountedMaxCurrency = CryptocurrencyMoney.Parse((SelectedOffer.MaxOfferValue / SelectedOffer.MaxPrice).ToClearString(), CryptocurrencyType.BTC);

            if (SelectedOffer.AmountLeft < CountedMaxCurrency)
            {
                CountedMaxCurrency = SelectedOffer.AmountLeft;
            }

            //Creator info
            Member User = new Member(SelectedOffer.CreatorId);
            CreatorNameLabel.Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                  HtmlCreator.CreateAvatarPlusUsername(User),
                                                  CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

            //Other info
            MinOfferLabel.Text = SelectedOffer.MinOfferValue.ToString();
            MaxOfferLabel.Text = SelectedOffer.MaxOfferValue.ToString();
            CurrencyAvailableToBuyLabel.Text = SelectedOffer.AmountLeft.ToString();

            MinCurrencyLabel.Text   = CountedMinCurrency.ToString();
            MaxCurrencyLabel.Text   = CountedMaxCurrency.ToString();
            MinCryptocurrencyAmount = decimal.Parse(CountedMinCurrency.ToClearString());
            MaxCryptocurrencyAmount = decimal.Parse(CountedMaxCurrency.ToClearString());

            PricePerCurrencyLabel.Text = SelectedOffer.MaxPrice.ToClearString();
            PricePerCryptocurrency     = decimal.Parse(SelectedOffer.MaxPrice.ToClearString());

            AmountToSellTextBox.Text = CountedMinCurrency.ToClearString();

            InfoForBuyerForOnClickSellTextBox.Text = String.Empty;
            Description = SelectedOffer.Description;

            //Updating Total Price label after every change of Cryptocurrency Amount
            AmountToSellTextBox.Attributes.Add("onkeyup", "updatePrice();");

            CashToPayLabel.Text = String.Format("{0}", decimal.Round(PricePerCryptocurrency * MinCryptocurrencyAmount, CoreSettings.GetMaxDecimalPlaces()).ToString());
        }
        #endregion

        #region OpenAddCommentView
        if ((!IsPostBack) && Request.Params.Get("foid") != null)
        {
            MenuMultiView.ActiveViewIndex = 5;
        }
        #endregion

        if (!IsPostBack)
        {
            AddLang();
        }

        //Constraint DataBind for second ManageTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 2)
        {
            ManageTabDataBind();
        }

        //Constraint DataBind for second HistoryTab load
        if (IsPostBack && MenuMultiView.ActiveViewIndex == 3)
        {
            OfferHistoryGridView.DataBind();
        }
    }