Ejemplo n.º 1
0
        public void Add_TransactionTest()
        {
            User test = new MoneyTransfer657.User("Erik Lomas");

            test.Add_Transaction("bob", "bill", "BTC", "1", "pizza");
            Assert.IsNotNull(test);
        }
Ejemplo n.º 2
0
        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            decimal amount_to_send;
            bool    isNumeric = decimal.TryParse(AmountBox.Text, out amount_to_send);

            if (isNumeric == false)
            {
                MessageBox.Show("Only enter numbers for amount of currency to send");
                return;
            }
            if (CoinBox.SelectedIndex == 0)
            {
                user.Usd = user.Usd - amount_to_send;
                user.Add_Transaction(user.Username, RecipientText.Text, "USD", amount_to_send.ToString(), descrip_box.Text);
            }
            else if (CoinBox.SelectedIndex == 1)
            {
                user.Btc = user.Btc - amount_to_send;
                user.Add_Transaction(user.Username, RecipientText.Text, "BTC", amount_to_send.ToString(), descrip_box.Text);
            }
            else if (CoinBox.SelectedIndex == 2)
            {
                user.Eth = user.Eth - amount_to_send;
                user.Add_Transaction(user.Username, RecipientText.Text, "ETH", amount_to_send.ToString(), descrip_box.Text);
            }
            else if (CoinBox.SelectedIndex == 3)
            {
                user.Xrp = user.Xrp - amount_to_send;
                user.Add_Transaction(user.Username, RecipientText.Text, "XRP", amount_to_send.ToString(), descrip_box.Text);
            }
            else
            {
                MessageBox.Show("Please select a currency before sending.");
                return;
            }
            UpdatePage();
            user.Update_Database();
        }
Ejemplo n.º 3
0
        private void BuyCoinButton_Click(object sender, RoutedEventArgs e)
        {
            decimal amount_to_buy;
            bool    isNumeric = decimal.TryParse(coinBuySellAmountTextBox.Text, out amount_to_buy);

            if (isNumeric == false)
            {
                MessageBox.Show("Only enter numbers for amount of coins to buy/sell");
                return;
            }
            if (selectCoinComboBox.SelectedIndex == 0)
            {
                //BTC
                if ((amount_to_buy * btc_price) > user.Usd)
                {
                    MessageBox.Show("You dont have enough USD to make this purchase");
                    return;
                }
                Thread buy = new Thread(() =>
                {
                    user.Buy_BTC(amount_to_buy);
                    user.Add_Transaction("global", user.Username, "BTC", amount_to_buy.ToString(), "buy crypto");
                });
                buy.Start();
                buy.Join();
            }
            else if (selectCoinComboBox.SelectedIndex == 1)
            {
                //ETH
                if ((amount_to_buy * eth_price) > user.Usd)
                {
                    MessageBox.Show("You dont have enough USD to make this purchase");
                    return;
                }
                Thread buy = new Thread(() =>
                {
                    user.Buy_ETH(amount_to_buy);
                    user.Add_Transaction("global", user.Username, "ETH", amount_to_buy.ToString(), "buy crypto");
                });
                buy.Start();
                buy.Join();
            }
            else if (selectCoinComboBox.SelectedIndex == 2)
            {
                //XRP
                if ((amount_to_buy * xrp_price) > user.Usd)
                {
                    MessageBox.Show("You dont have enough USD to make this purchase");
                    return;
                }
                Thread buy = new Thread(() =>
                {
                    user.Buy_XRP(amount_to_buy);
                    user.Add_Transaction("global", user.Username, "XRP", amount_to_buy.ToString(), "buy crypto");
                });
                buy.Start();
                buy.Join();
            }
            else
            {
                MessageBox.Show("Please select a coin before buying or selling.");
            }

            Update_Owned();
            MessageBox.Show("Purchase Complete");
        }