Пример #1
0
    protected void CurrentUserBuyOfferGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var commands = new[] { "start", "stop", "remove" };

        if (commands.Contains(e.CommandName))
        {
            var index   = e.GetSelectedRowIndex() % CurrentUserBuyOfferGridView.PageSize;
            var row     = CurrentUserBuyOfferGridView.Rows[index];
            var OfferId = (row.Cells[0].Text.Trim());
            var Offer   = new CryptocurrencyTradeOffer(Convert.ToInt32(OfferId));

            switch (e.CommandName)
            {
            case "start":
                if (Offer.Status == CryptocurrencyOfferStatus.Paused)
                {
                    Offer.Activate();
                }
                break;

            case "stop":
                if (Offer.Status == CryptocurrencyOfferStatus.Active)
                {
                    Offer.Pause();
                }
                break;

            case "remove":
                Offer.Delete();
                break;
            }

            CurrentUserBuyOfferGridView.DataBind();
        }
    }
Пример #2
0
    protected void CurrentUserBuyOfferGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[1].Text = L1.DATEADDED;
            e.Row.Cells[2].Text = L1.PRICE;
            e.Row.Cells[3].Text = U6010.TRANSACTIONVALUE;
            e.Row.Cells[4].Text = U6010.AMOUNTTOBUY;
            e.Row.Cells[5].Text = U6010.AMOUNTLEFT;
            e.Row.Cells[6].Text = L1.STATUS;
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var CurrentOffer = new CryptocurrencyTradeOffer(Int32.Parse(e.Row.Cells[0].Text));

            CryptocurrencyOfferStatus Status = (CryptocurrencyOfferStatus)Convert.ToInt32(e.Row.Cells[6].Text);

            e.Row.Cells[2].Text = String.Format("{0} / {1}", Money.Parse(e.Row.Cells[2].Text).ToString(), AppSettings.CryptocurrencyTrading.CryptocurrencyCode);
            e.Row.Cells[3].Text = String.Format("{0} - {1}", CurrentOffer.MinOfferValue, CurrentOffer.MaxOfferValue);
            e.Row.Cells[4].Text = CryptocurrencyMoney.Parse(e.Row.Cells[4].Text).ToString();
            e.Row.Cells[5].Text = CryptocurrencyMoney.Parse(e.Row.Cells[5].Text).ToString();
            e.Row.Cells[6].Text = HtmlCreator.GetColoredStatus(Status);

            if (Status != CryptocurrencyOfferStatus.Paused)
            {
                e.Row.Cells[7].Text = " ";
            }

            if (Status != CryptocurrencyOfferStatus.Active)
            {
                e.Row.Cells[8].Text = " ";
            }
        }
    }
Пример #3
0
    protected void CurrentUserTransactionsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[1].Text = L1.AMOUNT;
            e.Row.Cells[2].Text = U6010.EXECUTIONTIME;
            e.Row.Cells[3].Text = L1.STATUS;
            e.Row.Cells[5].Text = U4200.TIMELEFT;
            e.Row.Cells[6].Text = L1.DESCRIPTION;
        }

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //Loading data for addiotional info
            var CurrentTransaction = new CryptocurrencyTradeTransaction(Int32.Parse(e.Row.Cells[0].Text));
            var CurrentOffer       = new CryptocurrencyTradeOffer(CurrentTransaction.OfferId);

            e.Row.Cells[1].Text = CryptocurrencyMoney.Parse(e.Row.Cells[1].Text).ToString();

            if ((CryptocurrencyTransactionStatus)Int32.Parse(e.Row.Cells[3].Text) == CryptocurrencyTransactionStatus.AwaitingPaymentConfirmation)
            {
                e.Row.Cells[6].Visible = true;
            }
            else
            {
                e.Row.Cells[6].Visible = false;
            }
            e.Row.Cells[3].Text = HtmlCreator.GetColoredTransactionStatus((CryptocurrencyTransactionStatus)Int32.Parse(e.Row.Cells[3].Text));

            //Count Time Left in Escrow
            DateTime ExecutionTime   = DateTime.Parse(e.Row.Cells[2].Text);
            TimeSpan TimeLeft        = AppSettings.ServerTime - ExecutionTime;
            int      TimeLeftMinutes = CurrentOffer.EscrowTime - (int)TimeLeft.TotalMinutes;
            if (TimeLeftMinutes < 0)
            {
                TimeLeftMinutes = 0;
            }

            Label OfferTimeLeftToPayTextBox = new Label();
            OfferTimeLeftToPayTextBox.Text = HtmlCreator.GetColoredTime(TimeLeftMinutes);
            e.Row.Cells[5].Controls.Add(OfferTimeLeftToPayTextBox);

            //Load Description for this offerAddToCryptocurrencyBalance
            Label OfferDescriptionTextBox = new Label();

            //If seller description have data, that means that it is 100% buy offer and tehre is no desc, we have to load seller's description
            if (String.IsNullOrEmpty(CurrentTransaction.SellerDescription) || String.IsNullOrWhiteSpace(CurrentTransaction.SellerDescription))
            {
                OfferDescriptionTextBox.Text = CurrentOffer.Description;
            }
            else
            {
                OfferDescriptionTextBox.Text = CurrentTransaction.SellerDescription;
            }

            OfferDescriptionTextBox.CssClass = "description-column displaynone";
            e.Row.Cells[4].Controls.Add(OfferDescriptionTextBox);
        }
    }
Пример #4
0
    protected void AddSellOfferButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (String.IsNullOrEmpty(SellAmountTextBox.Text) || decimal.Parse(SellAmountTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.AMOUNTTOBUY, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MinPriceTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.PRICEPER, AppSettings.CryptocurrencyTrading.CryptocurrencyCode, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MaxOfferValueTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.CCMAXOFFERVALUE, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MinOfferValueTextBox.Text) > decimal.Parse(MaxOfferValueTextBox.Text))
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.CCMINOFFERVALUE, U6010.CANTBEHIGHER, U6010.CCMAXOFFERVALUE, "<br />"));
            }

            var User        = Member.CurrentInCache;
            var UserBalance = User.GetCryptocurrencyBalance(CryptocurrencyType.BTC);

            if (CryptocurrencyMoney.Parse(SellAmountTextBox.Text) > UserBalance)
            {
                throw new MsgException(String.Format(U6010.NOCREDITS_CRYPTOCURRENCYBALANCE, UserBalance));
            }

            CryptocurrencyTradeOffer.CreateNewOffer(CryptocurrencyOfferType.Sell,
                                                    Member.CurrentId,
                                                    Money.Parse(MinPriceTextBox.Text),
                                                    Money.Zero,
                                                    Money.Parse(MinOfferValueTextBox.Text),
                                                    Money.Parse(MaxOfferValueTextBox.Text),
                                                    Int32.Parse(EscrowTimeTextBox.Text),
                                                    Description = DescriptionTextBox.Text,
                                                    CryptocurrencyMoney.Parse(SellAmountTextBox.Text, CryptocurrencyType.BTC));

            Response.Redirect("~/user/cctrading/sell.aspx?SelectedTab=2");
        }
        catch (MsgException ex)
        {
            CreateSellErrorPanel.Visible = true;
            CreateSellErrorLiteral.Text  = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
Пример #5
0
    protected void AllSellOffersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var    CurrentOffer = new CryptocurrencyTradeOffer(Int32.Parse(e.Row.Cells[0].Text));
            Member User         = new Member(Int32.Parse(e.Row.Cells[1].Text));

            e.Row.Cells[1].Text = String.Format("<span style=\"float:left; margin-right: 10px\">{0}</span>{1}",
                                                HtmlCreator.CreateAvatarPlusUsername(User),
                                                CryptocurrencyPlatformManager.GetHtmlRatingStringForUser(User.Id));

            e.Row.Cells[3].Text = String.Format("<b>{0}</b>/{1}", Money.Parse(e.Row.Cells[3].Text).ToString(), AppSettings.CryptocurrencyTrading.CryptocurrencyCode);
            e.Row.Cells[4].Text = CurrentOffer.MinOfferValue + " - " + CurrentOffer.MaxOfferValue;
            e.Row.Cells[5].Text = CryptocurrencyMoney.Parse(e.Row.Cells[5].Text).ToString();
        }
    }
Пример #6
0
    protected void AddBuyOfferButton_Click(object sender, EventArgs e)
    {
        try
        {
            if (decimal.Parse(BuyAmountTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.AMOUNTTOBUY, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MaxPriceTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.PRICEPER, AppSettings.CryptocurrencyTrading.CryptocurrencyCode, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MaxOfferValueTextBox.Text) == decimal.Zero)
            {
                throw new MsgException(String.Format("{0}{1}{2}", U6010.CCMAXOFFERVALUE, U6010.NOZERO, "<br />"));
            }
            if (decimal.Parse(MinOfferValueTextBox.Text) > decimal.Parse(MaxOfferValueTextBox.Text))
            {
                throw new MsgException(String.Format("{0} {1}{2}{3}", U6010.CCMINOFFERVALUE, U6010.CANTBEHIGHER, U6010.CCMAXOFFERVALUE, "<br />"));
            }

            CryptocurrencyTradeOffer.CreateNewOffer(
                CryptocurrencyOfferType.Buy,
                Member.CurrentId,
                Money.Zero,
                Money.Parse(MaxPriceTextBox.Text),
                Money.Parse(MinOfferValueTextBox.Text),
                Money.Parse(MaxOfferValueTextBox.Text),
                Int32.Parse(EscrowTimeTextBox.Text),
                Description = String.Empty,
                CryptocurrencyMoney.Parse(BuyAmountTextBox.Text, CryptocurrencyType.BTC));

            Response.Redirect("~/user/cctrading/buy.aspx?SelectedTab=2");
        }
        catch (MsgException ex)
        {
            CreateBuyErrorPanel.Visible = true;
            CreateBuyErrorLiteral.Text  = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
Пример #7
0
    protected void SellOfferButton_OnClick(object sender, EventArgs e)
    {
        try
        {
            if (Request.Params.Get("oid") != null)
            {
                var SelectedOffer = new CryptocurrencyTradeOffer(Convert.ToInt32(Request.Params.Get("oid")));

                //Because when creating buy offer you don't create description, seller have to provide necessary info for buyer
                String AdditionalDescription = InfoForBuyerForOnClickSellTextBox.Text;

                if (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) == CryptocurrencyMoney.Zero)
                {
                    throw new MsgException(U6011.CANTSELLZEROCRYPTOCURRENCY);
                }

                //Check if seller don't try sell more than expected
                if ((CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) > SelectedOffer.AmountLeft) ||
                    (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) * SelectedOffer.MaxPrice > SelectedOffer.MaxOfferValue))
                {
                    throw new MsgException(U6010.ERRORTRYSELLMORE);
                }

                if (CryptocurrencyMoney.Parse(AmountToSellTextBox.Text) * SelectedOffer.MaxPrice < SelectedOffer.MinOfferValue)
                {
                    throw new MsgException(U6010.ERRORTRYSELLLESS);
                }

                CryptocurrencyPlatformManager.TryPlaceOrder(SelectedOffer.Id, CryptocurrencyMoney.Parse(AmountToSellTextBox.Text, CryptocurrencyType.BTC), AdditionalDescription);

                Response.Redirect("~/user/cctrading/sell.aspx?SelectedTab=2");
            }
        }
        catch (MsgException ex)
        {
            SellErrorPanel.Visible = true;
            SellError.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
Пример #8
0
    protected void BuyOfferButton_OnClick(object sender, EventArgs e)
    {
        try
        {
            if (Request.Params.Get("oid") != null)
            {
                int ProductId     = Convert.ToInt32(Request.Params.Get("oid"));
                var SelectedOffer = new CryptocurrencyTradeOffer(ProductId);

                if (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) == CryptocurrencyMoney.Zero)
                {
                    throw new MsgException(U6011.CANTBUYZEROCRYPTOCURRENCY);
                }

                if ((CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) > SelectedOffer.AmountLeft) ||
                    (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) * SelectedOffer.MinPrice > SelectedOffer.MaxOfferValue))
                {
                    throw new MsgException(U6010.ERRORTRYBUYMORE);
                }

                if (CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text) * SelectedOffer.MinPrice < SelectedOffer.MinOfferValue)
                {
                    throw new MsgException(U6010.ERRORTRYBUYLESS);
                }

                CryptocurrencyPlatformManager.TryPlaceOrder(ProductId, CryptocurrencyMoney.Parse(AmountToBuyTextBox.Text, CryptocurrencyType.BTC), String.Empty);

                Response.Redirect("~/user/cctrading/buy.aspx?SelectedTab=2");
            }
        }
        catch (MsgException ex)
        {
            BuyErrorPanel.Visible = true;
            BuyError.Text         = ex.Message;
        }
        catch (Exception ex)
        {
            ErrorLogger.Log(ex.Message);
            throw ex;
        }
    }
Пример #9
0
    public static void CreateNewOffer(CryptocurrencyOfferType OfferType, int CreatorId, Money MinPrice, Money MaxPrice, Money MinOfferValue, Money MaxOfferValue, int EscrowTime, String Description, CryptocurrencyMoney CryptocurrencyAmount)
    {
        CryptocurrencyTradeOffer NewTradeOffer = new CryptocurrencyTradeOffer();

        NewTradeOffer.Status       = CryptocurrencyOfferStatus.Active;
        NewTradeOffer.DateAdded    = DateTime.Now;
        NewTradeOffer.DateFinished = DateTime.Now.AddDays(365);

        NewTradeOffer.OfferKind     = OfferType;
        NewTradeOffer.CreatorId     = CreatorId;
        NewTradeOffer.MinPrice      = MinPrice;
        NewTradeOffer.MaxPrice      = MaxPrice;
        NewTradeOffer.MinOfferValue = MinOfferValue;
        NewTradeOffer.MaxOfferValue = MaxOfferValue;
        NewTradeOffer.Description   = Description;
        NewTradeOffer.EscrowTime    = EscrowTime;
        NewTradeOffer.Amount        = CryptocurrencyAmount;
        NewTradeOffer.AmountLeft    = CryptocurrencyAmount;

        NewTradeOffer.Save(true);
    }
Пример #10
0
    protected void CurrentUserTransactionsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var commands = new[] { "ConfirmReceived" };

        if (commands.Contains(e.CommandName))
        {
            var index             = e.GetSelectedRowIndex() % CurrentUserTransactionsGridView.PageSize;
            var row               = CurrentUserTransactionsGridView.Rows[index];
            var TransactionId     = (row.Cells[0].Text.Trim());
            var Transaction       = new CryptocurrencyTradeTransaction(Convert.ToInt32(TransactionId));
            var CurrentTradeOffer = new CryptocurrencyTradeOffer(Transaction.OfferId);

            switch (e.CommandName)
            {
            case "ConfirmReceived":
                int ClientWithCash = -1;
                if (Transaction.ClientId != Member.CurrentId)
                {
                    ClientWithCash = Transaction.ClientId;
                }
                else
                {
                    ClientWithCash = CurrentTradeOffer.CreatorId;
                }

                var BuyerWithCash = new Member(ClientWithCash);
                BuyerWithCash.AddToCryptocurrencyBalance(CryptocurrencyType.BTC, Transaction.CCAmount.ToDecimal(), "Cryptocurrency trade", BalanceLogType.CryptocurrencyTrade);

                Transaction.PaymentStatus = CryptocurrencyTransactionStatus.Finished;
                Transaction.Save();

                CryptocurrencyFinishedTradeOffer.CreateNewTemplate(Transaction.OfferId, ClientWithCash, Member.CurrentId, Transaction.CCAmount);
                break;
            }

            CurrentUserTransactionsGridView.DataBind();
        }
    }
Пример #11
0
    public static void TryPlaceOrder(int OfferId, CryptocurrencyMoney CCAmount, String SellerDescription)
    {
        //Loading selected offer
        var SelectedOffer = new CryptocurrencyTradeOffer(OfferId);
        var OfferCreator  = new Member(SelectedOffer.CreatorId);

        //Checking Creator's Balance
        if (SelectedOffer.OfferKind == CryptocurrencyOfferType.Buy)
        {
            if (SelectedOffer.CreatorId != Member.CurrentId)
            {
                if (OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC) < CCAmount)
                {
                    throw new MsgException(U6010.ORDER_CREATORNOBALANCE);
                }
            }
        }
        else
        {
            if (SelectedOffer.CreatorId == Member.CurrentId)
            {
                if (OfferCreator.GetCryptocurrencyBalance(CryptocurrencyType.BTC) < CCAmount)
                {
                    throw new MsgException(U6010.ORDER_YOUNOBALANCE);
                }
            }
        }

        //If everything is good, creating transaction
        CryptocurrencyTradeTransaction NewTransaction = new CryptocurrencyTradeTransaction()
        {
            OfferId           = OfferId,
            ClientId          = Member.CurrentId,
            ExecutionTime     = AppSettings.ServerTime,
            PaymentStatus     = CryptocurrencyTransactionStatus.AwaitingPayment,
            CCAmount          = CCAmount,
            SellerDescription = SellerDescription
        };

        //Freezing cryptocurrency for transaction time
        //Current user clicked sell
        if (SelectedOffer.OfferKind == CryptocurrencyOfferType.Buy)
        {
            Member.Current.SubtractFromCryptocurrencyBalance(CryptocurrencyType.BTC, CCAmount.ToDecimal(), "Cryptocurrency trade", BalanceLogType.CryptocurrencyTrade);
        }
        //Current user clicked buy
        else
        {
            OfferCreator.SubtractFromCryptocurrencyBalance(CryptocurrencyType.BTC, CCAmount.ToDecimal(), "Cryptocurrency trade", BalanceLogType.CryptocurrencyTrade);
        }

        //Descreasing existing offer CC amount left
        SelectedOffer.AmountLeft = SelectedOffer.AmountLeft - CCAmount;
        if (SelectedOffer.AmountLeft <= CryptocurrencyMoney.Zero)
        {
            SelectedOffer.Status = CryptocurrencyOfferStatus.Finished;
        }
        SelectedOffer.Save();

        //Saving transaction, ESCROW starts here
        NewTransaction.Save(true);
    }
Пример #12
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();
        }
    }
Пример #13
0
 //Active offers
 protected void CurrentUserBuyOfferGridView_DataSource_Init(object sender, EventArgs e)
 {
     CurrentUserBuyOfferGridView_DataSource.SelectCommand = CryptocurrencyTradeOffer.GetGridViewStringForUserActualOffers(Member.CurrentId, CryptocurrencyOfferType.Buy);
 }
Пример #14
0
 protected void AllSellOffersGridView_DataSource_Init(object sender, EventArgs e)
 {
     AllSellOffersGridView_DataSource.SelectCommand = CryptocurrencyTradeOffer.GetGridViewStringForAllActiveOffersForUser(Member.CurrentId, CryptocurrencyOfferType.Sell);
 }
Пример #15
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();
        }
    }