private string GetPlaceOfferResponse(InternalExchangeOfferResponse response, bool isAsk)
    {
        string message = string.Empty;

        if (response.AmountTransferd != decimal.Zero)
        {
            string amountTransferd = InternalExchangeManager.RecognizeCurrencyAndReturnString(true, FormatDecimal(response.AmountTransferd));
            string valueTransferd  = InternalExchangeManager.RecognizeCurrencyAndReturnString(false, FormatDecimal(response.ValueTransferd));

            if (isAsk)
            {
                message += String.Format(U6012.SOLDSTOCKS, amountTransferd, valueTransferd);
            }
            else
            {
                message += String.Format(U6012.BOUGHTSTOCKS, amountTransferd, valueTransferd);
            }

            message += "<br />";
        }

        if (response.AmountPlaced != decimal.Zero)
        {
            string amountPlaced = InternalExchangeManager.RecognizeCurrencyAndReturnString(true, FormatDecimal(response.AmountPlaced));
            string valuePlaced  = InternalExchangeManager.RecognizeCurrencyAndReturnString(false, FormatDecimal(response.ValuePlaced));

            message += String.Format(U6012.NEWEXCHANGEOFFER, amountPlaced, valuePlaced);
        }

        return(message);
    }
Beispiel #2
0
 protected void OfferHeaderRowBound(GridViewRow row)
 {
     row.Cells[2].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(true));
     row.Cells[3].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(false));
     row.Cells[4].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(false));
     row.Cells[5].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(true));
 }
Beispiel #3
0
    protected void TransactionHistoryGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            Label TransactionValue = new Label();

            TransactionValue.Text = InternalExchangeManager.RecognizeCurrencyAndReturnString(false, (Decimal.Parse(e.Row.Cells[2].Text) * Decimal.Parse(e.Row.Cells[3].Text)));

            e.Row.Cells[2].Text = InternalExchangeManager.RecognizeCurrencyAndReturnString(true, e.Row.Cells[2].Text);
            e.Row.Cells[3].Text = InternalExchangeManager.RecognizeCurrencyAndReturnString(false, e.Row.Cells[3].Text);

            bool   isAsk     = !e.Row.Cells[6].Text.Equals(Member.CurrentId.ToString());
            String SignA     = isAsk ? "-" : "+";
            String SignB     = isAsk ? "+" : "-";
            String Color     = isAsk ? "red" : "green";
            String OfferType = isAsk ? U6009.SELL : L1.BUY;

            e.Row.Style.Add("color", Color);
            TransactionValue.Text = String.Format("{0} {1}", SignB, TransactionValue.Text);

            e.Row.Cells[1].Text = OfferType.ToUpper();
            e.Row.Cells[2].Text = String.Format("{0} {1}", SignA, e.Row.Cells[2].Text);
            e.Row.Cells[4].Controls.Add(TransactionValue);
        }
    }
Beispiel #4
0
 protected void DetailHeaderRowBound(GridViewRow row, bool isAsk)
 {
     row.Cells[0].Text += " #";
     row.Cells[2].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(true));
     row.Cells[3].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(false));
     row.Cells[4].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(true));
     row.Cells[5].Text += String.Format("({0})", InternalExchangeManager.GetBalanceSign(false));
 }
Beispiel #5
0
 public void Withdraw(bool forceAdmin = false)
 {
     if (forceAdmin)
     {
         InternalExchangeManager.WithdrawOffer(Id, AskUserId, forceAdmin, true);
     }
     else
     {
         InternalExchangeManager.WithdrawOffer(Id, true);
     }
 }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.InternalExchangeTradingHistoryEnabled);

        if (!IsPostBack)
        {
            SignOfStock           = InternalExchangeManager.GetBalanceSign(true);
            SignOfPurchaseBalance = InternalExchangeManager.GetBalanceSign(false);

            LangAdders();
            DataBind();
        }
    }
    protected void AllAskOffersGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            e.Row.Cells[0].Text += String.Format("({0})", InternalExchangeManager.GetBalanceCode(true));
            e.Row.Cells[1].Text += String.Format("({0})", InternalExchangeManager.GetBalanceCode(false));
            e.Row.Cells[2].Text += String.Format("({0})", InternalExchangeManager.GetBalanceCode(false));
        }

        if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)
        {
            if (e.Row.RowIndex == 0)
            {
                e.Row.Style.Add("font-weight", "bold");
            }

            e.Row.Cells[0].Style.Add("text-align", "right");
            e.Row.Cells[1].Style.Add("text-align", "right");
            e.Row.Cells[2].Style.Add("text-align", "right");

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (BalanceTypeHelper.IsCryptoBalance(AppSettings.InternalExchange.InternalExchangeStockType))
                {
                    e.Row.Cells[0].Text = new CryptocurrencyMoney(CryptocurrencyType.BTC, Decimal.Parse(e.Row.Cells[0].Text)).ToClearString();
                }
                else
                {
                    e.Row.Cells[0].Text = new Money(Decimal.Parse(e.Row.Cells[0].Text)).ToClearString();
                }

                if (BalanceTypeHelper.IsCryptoBalance(AppSettings.InternalExchange.InternalExchangePurchaseVia))
                {
                    e.Row.Cells[2].Text = new CryptocurrencyMoney(CryptocurrencyType.BTC, Decimal.Parse(e.Row.Cells[2].Text)).ToClearString();
                    e.Row.Cells[1].Text = new CryptocurrencyMoney(CryptocurrencyType.BTC, Decimal.Parse(e.Row.Cells[1].Text)).ToClearString();
                }
                else
                {
                    e.Row.Cells[2].Text = new Money(Decimal.Parse(e.Row.Cells[2].Text)).ToClearString();
                    e.Row.Cells[1].Text = new Money(Decimal.Parse(e.Row.Cells[1].Text)).ToClearString();
                }

                e.Row.Cells[0].CssClass = "paramAskAmount";
                e.Row.Cells[1].CssClass = "paramAskValue";
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        AccessManager.RedirectIfDisabled(AppSettings.TitanFeatures.InternalExchangeEnabled);

        SignOfStock           = InternalExchangeManager.GetBalanceSign(true);
        SignOfPurchaseBalance = InternalExchangeManager.GetBalanceSign(false);

        if (!IsPostBack)
        {
            NotVisibleChartData.Text = AppSettings.IsDemo ? InternalExchangeManager.GetTestChartData() : new InternalExchangeCache().Get().ToString();

            HideMessagges();
            FillData();
            LangAdders();

            NumberOfStockTextBox.Attributes.Add("onkeyup", "updatePrice();");
            ValueOfStockTextBox.Attributes.Add("onkeyup", "updatePrice();");
            TotalValueTextBox.Attributes.Add("onkeyup", "updatePriceFromTotal();");

            MinimalPriceLabel.Visible = AppSettings.InternalExchange.ICOInternalExchangeMinimalStockPrice == Decimal.Zero ? false : true;
        }
    }
Beispiel #9
0
    protected void UserCurrentAsksAndBids_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var commands = new[] { "finishBid", "finishAsk", "tradeBid", "tradeAsk" };

        if (commands.Contains(e.CommandName))
        {
            GridView gridView = (GridView)sender;

            var index = e.GetSelectedRowIndex() % gridView.PageSize;
            var row   = gridView.Rows[index];

            switch (e.CommandName)
            {
            case "finishAsk":
                try
                {
                    var askId = Int32.Parse(row.Cells[0].Text.Trim());

                    var currentAsk = new InternalExchangeAsk(askId);

                    if (currentAsk != null)
                    {
                        currentAsk.Withdraw();
                        SuccessMessageLiteral.Text  = String.Format("{0}{1} {2}", InternalExchangeManager.GetBalanceSign(true), FormatDecimal(currentAsk.AskAmount), U6012.RETURNEDTOYOURBALANCE.ToLower());
                        SuccessMessagePanel.Visible = true;
                    }
                    else
                    {
                        throw new MsgException("Unexpected error: current offer not exist anymore");
                    }
                }
                catch (MsgException ex)
                {
                    ErrorMessagePanel.Visible = true;
                    ErrorMessageLiteral.Text  = ex.Message;
                }
                catch (DbException ex)
                {
                    ErrorMessagePanel.Visible = true;
                    ErrorMessageLiteral.Text  = ex.Message;
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex.Message);
                    throw ex;
                }
                finally
                {
                    DataBind();
                }

                break;

            case "finishBid":
                try
                {
                    var bidId = Int32.Parse(row.Cells[0].Text.Trim());

                    var currentBid = new InternalExchangeBid(bidId);

                    if (currentBid != null)
                    {
                        currentBid.Withdraw();
                        SuccessMessageLiteral.Text  = String.Format("{0}{1} {2}", InternalExchangeManager.GetBalanceSign(false), FormatDecimal(currentBid.BidAmount * currentBid.BidValue), U6012.RETURNEDTOYOURBALANCE.ToLower());
                        SuccessMessagePanel.Visible = true;
                    }
                    else
                    {
                        throw new MsgException("Unexpected error: current offer not exist anymore");
                    }
                }
                catch (MsgException ex)
                {
                    ErrorMessagePanel.Visible = true;
                    ErrorMessageLiteral.Text  = ex.Message;
                }
                catch (DbException ex)
                {
                    ErrorMessagePanel.Visible = true;
                    ErrorMessageLiteral.Text  = ex.Message;
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex.Message);
                    throw ex;
                }
                finally
                {
                    DataBind();
                }

                break;

            case "tradeAsk":
            case "tradeBid":
                int    tradeDetailIndex = (int)ViewState[tradeDetailIndexString];
                string tradeDetailGrid  = ViewState[tradeDetailGridString].ToString();

                if (tradeDetailIndex == index && tradeDetailGrid == gridView.ID)
                {
                    ViewState[tradeDetailIndexString] = -1;
                    ViewState[tradeDetailGridString]  = String.Empty;
                }
                else
                {
                    ViewState[tradeDetailIndexString] = index;
                    ViewState[tradeDetailGridString]  = gridView.ID;
                }
                DataBind();

                break;
            }
        }
    }
Beispiel #10
0
 public decimal GetInternalExchangeDayAskAmount()
 {
     return(InternalExchangeManager.GetUserInternalExchangeAskAmount(this.Id));
 }
Beispiel #11
0
 public static decimal GetCurrentUserInternalExchangeAskAmount()
 {
     return(InternalExchangeManager.GetUserInternalExchangeAskAmount(Member.CurrentId));
 }
Beispiel #12
0
    protected void AskButton_Click(object sender, EventArgs e)
    {
        decimal CurrentMultiplier = AppSettings.InternalExchange.InternalExchangeAskCommissionPercent / 100m;

        currentMultiplier.Text = CurrentMultiplier.ToString();

        decimal dailySellLimit = AppSettings.InternalExchange.InternalExchangePeriodMaxSellAmount;

        dailySellLimit -= Member.Current.GetInternalExchangeDayAskAmount();

        if (dailySellLimit <= 0)
        {
            dailySellLimit = 0.0m;
            SellAmountLimitDescriptionTextBox.Text = U6013.STOCKSELLLIMITREACHED;
            Amount_RangeValidator.MinimumValue     = FormatDecimal(dailySellLimit);
        }
        else
        {
            SellAmountLimitDescriptionTextBox.Text    = U6013.STOCKSELLLIMIT + " " + FormatDecimal(dailySellLimit) + InternalExchangeManager.GetBalanceSign(true);
            SellAmountLimitDescriptionTextBox.Visible = true;
        }

        Decimal CurrentStockWallet = Decimal.Parse(Member.CurrentInCache.GetClearStringBalance(AppSettings.InternalExchange.InternalExchangeStockType));

        if (CurrentStockWallet > AppSettings.InternalExchange.InternalExchangeMinimalSellAmount)
        {
            Amount_RangeValidator.MaximumValue = CurrentStockWallet < dailySellLimit?FormatDecimal(CurrentStockWallet) : FormatDecimal(dailySellLimit);
        }
        else
        {
            Amount_RangeValidator.MaximumValue = FormatDecimal(dailySellLimit);
        }
        Amount_RangeValidator.Text = "<br/>" + U6013.STOCKSELLERROR;

        BidButton.CssClass = "TabButton IeOfferNotSelected";
        AskButton.CssClass = "TabButton IeOfferSelected";

        PricePerStockLabel.Text = String.Format("{0} {1}:", U6012.ASK, String.Format("({0} {1})", Member.CurrentInCache.GetClearStringBalance(AppSettings.InternalExchange.InternalExchangePurchaseVia), U4200.AVAILABLE.ToLower()));
    }
Beispiel #13
0
 private void UpdateGridViewTitles()
 {
     RightTitleBidOffersLabel.Text = String.Format("{0}: <b>{1}</b>", U5001.TOTAL, InternalExchangeManager.RecognizeCurrencyAndReturnString(true, InternalExchangeTransaction.GetSumOfStockForOffers(true)));
     RightTitleAskOffersLabel.Text = String.Format("{0}: <b>{1}</b>", U5001.TOTAL, InternalExchangeManager.RecognizeCurrencyAndReturnString(false, InternalExchangeTransaction.GetValueOfOffers(false)));
 }
Beispiel #14
0
    private void UpdateStatistics()
    {
        UpdateStatisticsData();

        SetStatisticForLabel(LastStockValue, tmpLastStockValue, tmpCurrentStockValue, String.Format("<b>{0}:</b> {1}", U6012.LAST.ToUpper(), InternalExchangeManager.RecognizeCurrencyAndReturnString(false, tmpLastStockValue)));
        SetStatisticForLabel(LastAskValue, tmpLastAskValue, tmpCurrentLastAskValue, String.Format("<b>{0} {1}:</b> {2}", U6012.LAST.ToUpper(), U6012.ASK.ToUpper(), InternalExchangeManager.RecognizeCurrencyAndReturnString(false, tmpLastStockValue)));
        SetStatisticForLabel(LastBidValue, tmpLastBidValue, tmpCurrentLastBidValue, String.Format("<b>{0} {1}:</b> {2}", U6012.LAST.ToUpper(), U6012.BID.ToUpper(), InternalExchangeManager.RecognizeCurrencyAndReturnString(false, tmpLastBidValue)));
        SetStatisticForLabel(Last24HighValue, tmpLast24HighValue, tmpCurrentLast24HighValue, String.Format("<b>24H {0}:</b> {1}", U6013.HIGH, InternalExchangeManager.RecognizeCurrencyAndReturnString(false, tmpLast24HighValue)));
        SetStatisticForLabel(Last24LowValue, tmpLast24LowValue, tmpCurrentLast24LowValue, String.Format("<b>24H {0}:</b> {1}", U6013.LOW, InternalExchangeManager.RecognizeCurrencyAndReturnString(false, tmpLast24LowValue)));
        SetStatisticForLabel(Last24Volume, tmpLast24Volume, tmpCurrentLast24Volume, String.Format("<b>24H</b> {0} %", Math.Round(tmpLast24Volume, 2)));
    }
Beispiel #15
0
    protected void PlaceOrderButton_Click(object sender, EventArgs e)
    {
        HideMessagges();

        if (Member.CurrentInCache.IsAnyBalanceIsNegative())
        {
            ErrorMessagePanel.Visible = true;
            ErrorMessageLiteral.Text  = U6013.YOUCANTPROCEED;
        }
        else
        {
            if (Page.IsValid)
            {
                try
                {
                    bool    isAsk = IsCurrentlyAsk();
                    decimal numberOfStockToBuy = Decimal.Parse(NumberOfStockTextBox.Text);
                    decimal valueOfStock       = Decimal.Parse(ValueOfStockTextBox.Text);
                    decimal totalValue         = Decimal.Parse(TotalValueTextBox.Text);

                    if (valueOfStock < AppSettings.InternalExchange.ICOInternalExchangeMinimalStockPrice)
                    {
                        throw new MsgException("Value of stock lower than allowed.");
                    }

                    if (numberOfStockToBuy <= Decimal.Zero || valueOfStock <= Decimal.Zero || totalValue <= Decimal.Zero)
                    {
                        ErrorLogger.Log(String.Format("INTERNAL EXCHANGE | Unexpected error | User: {0}({1}) | Size({2}) | Price({3}) | Total({4}) | IsAsk({5})", Member.CurrentName, Member.CurrentId, numberOfStockToBuy, valueOfStock, totalValue, isAsk));
                        throw new MsgException("Unexpected error. Value less than or equals to 0.");
                    }

                    InternalExchangeOfferResponse response = InternalExchangeManager.TryPlaceOrder(Member.CurrentId, numberOfStockToBuy, valueOfStock, isAsk);

                    if (response != null)
                    {
                        SuccessMessageLiteral.Text  = GetPlaceOfferResponse(response, isAsk);
                        SuccessMessagePanel.Visible = true;
                    }
                    else
                    {
                        ErrorMessagePanel.Visible = true;
                        ErrorMessageLiteral.Text  = L1.ERROR_INFO;
                    }

                    DataBind();
                }
                catch (MsgException ex)
                {
                    ErrorMessagePanel.Visible = true;
                    ErrorMessageLiteral.Text  = ex.Message;
                }
                catch (Exception ex)
                {
                    ErrorLogger.Log(ex.Message);
                    throw ex;
                }
            }
            else
            {
                ErrorMessagePanel.Visible = true;
                ErrorMessageLiteral.Text  = "Unexpected Error - page is not valid";
            }
        }
    }