Esempio n. 1
0
        /* New Buy Order */
        private void button4_Click(object sender, EventArgs e)
        {
            // verificar se o texto é válido, se não for, inserir mensagem de erro
            this.panelNewBuyOrder.Visible = false;
            this.panelBuyProgress.Visible = true;
            String input = this.buyAmount.Text;

            if (!input.Equals(""))
            {
                long amount;
                try {
                    amount = Convert.ToInt64(input);
                    if (amount <= 0)
                    {
                        this.put_message_buy_error("Number of diginotes to buy must be greater than 0");
                        this.panelNewBuyOrder.Visible = true;
                        this.panelBuyProgress.Visible = false;
                        return;
                    }
                    Common.Info status = client.AddOrder(Common.Order.OrderType.Purchase, amount);
                    if (status == Common.Info.OrderParciallyCompleted || status == Common.Info.OrderPending)
                    {
                        double currentQuote = client.GetQuote();


                        this.put_message_buy_error("Not All Diginotes were bought. You must define a new quote (higher or equal) than the current quote (" + currentQuote + ")");
                        this.panelNewBuyOrder.Visible    = false;
                        this.panelBuyProgress.Visible    = false;
                        this.panelDefineQuoteBuy.Visible = true;
                        this.status = Status.BUYING;
                    }
                    else if (status == Common.Info.OrderCompleted)
                    {
                        this.put_message_buy_success("The Order was successufully created");
                        this.panelNewBuyOrder.Visible = true;
                        this.panelBuyProgress.Visible = false;
                    }
                    else
                    {
                        this.put_message_buy_error("Oops, seems like there's not enough money for this transaction");
                        this.panelNewBuyOrder.Visible = true;
                        this.panelBuyProgress.Visible = false;
                    }
                }
                catch (FormatException)
                {
                    this.panelNewBuyOrder.Visible = true;
                    this.panelBuyProgress.Visible = false;
                    this.put_message_buy_error("Insert a valid Amount input");
                }
            }
            else
            {
                this.panelNewBuyOrder.Visible = true;
                this.panelBuyProgress.Visible = false;
                this.put_message_buy_error("Insert a valid Amount input");
            }
        }