Ejemplo n.º 1
0
        private void Income_OnClick(object sender, RoutedEventArgs e)
        {
            Income.IsEnabled = false;
            // Get amount of income
            var income = GetMoneyInput();

            if (income <= 0)
            {
                Income.IsEnabled = true;
                return;
            }

            // Get current total
            _current = _current + income;

            // Update Total list and database
            var currentTotal = new SqlConnect.Bank(_current, DateTime.Now);

            SqlConnect.InsertMoney("total", _userId, _current);
            _total.Add(currentTotal);

            // Show current total
            CurrentMoney.Text = _current.ToString("C");
            //MessageBox.Show(@"You successfully added an income to your bank");
            Income.IsEnabled = true;
        }
Ejemplo n.º 2
0
        private void Delete_OnClick(object sender, RoutedEventArgs e)
        {
            var removeItem = _observableDataBanks.Where(x => x.Selected).ToList();

            if (removeItem.Count == 0)
            {
                MessageBox.Show("Check a box to delete a record.", "Error", MessageBoxButton.OK, MessageBoxImage.Stop);
                return;
            }

            foreach (var item in removeItem)
            {
//                var timestamp = item.Timestamp.ToString("yyyy-MM-dd HH:mm:ss");

                _observableDataBanks.Remove(item);
                _current += item.Money;
                _expense.Remove(item);
                var currentTotal = new SqlConnect.Bank(_current, DateTime.Now);
                SqlConnect.InsertMoney("total", _userId, _current);
                _total.Add(currentTotal);
                SqlConnect.DeleteMoney("expense", item.Id, _userId);
            }

            CurrentMoney.Text = _current.ToString("C");
        }
Ejemplo n.º 3
0
        private void Spend_OnClick(object sender, RoutedEventArgs e)
        {
            Spend.IsEnabled = false;
            // Get amount of expense
            var expense = GetMoneyInput();

            if (expense <= 0)
            {
                Spend.IsEnabled = true;
                return;
            }

            // Get category
            string category;

            if (string.IsNullOrWhiteSpace(Category.Text))
            {
                MessageBox.Show(@"You didn't choose category");
                Spend.IsEnabled = true;
                return;
            }
            else
            {
                category = Category.Text;
            }


            // Get current total
            _current = _current - expense;

            // Update the expense list
            var expenseInput = new SqlConnect.Bank(expense, DateTime.Now, category);

            SqlConnect.InsertMoney("expense", _userId, expense, category);
            _expense.Add(expenseInput);
            _observableDataBanks.Add(expenseInput);

            // Update Total list and database
            var currentTotal = new SqlConnect.Bank(_current, DateTime.Now);

            SqlConnect.InsertMoney("total", _userId, _current);
            _total.Add(currentTotal);

            // Show current total
            CurrentMoney.Text = _current.ToString("C");
            //MessageBox.Show(@"You successfully added an expense to your bank");
            Spend.IsEnabled = true;
        }
Ejemplo n.º 4
0
        private void Spend_Click(object sender, EventArgs e)
        {
            // Get amount of expense
            var expense = GetMoneyInput();

            if (expense <= 0)
            {
                return;
            }


            // Get category
            string category;

            if (string.IsNullOrWhiteSpace(catagoryList.Text))
            {
                MessageBox.Show(@"You didn't choose category");
                return;
            }
            else
            {
                category = catagoryList.Text;
            }

            // Get current total
            _current = _current - expense;

            // Update the expense list
            var expenseInput = new SqlConnect.Bank(expense, DateTime.Now, category);

            sql.InsertMoney("expense", _userId, expense, category);
            _expense.Add(expenseInput);

            // Update Total list and database
            var currentTotal = new SqlConnect.Bank(_current, DateTime.Now);

            sql.InsertMoney("total", _userId, _current);
            _total.Add(currentTotal);

            // Show current total
            CurrentMoney.Text = _current.ToString("C");
        }
Ejemplo n.º 5
0
        private void Income_Click(object sender, EventArgs e)
        {
            // Get amount of income
            var income = GetMoneyInput();

            if (income <= 0)
            {
                return;
            }

            // Get current total
            _current = _current + income;

            // Update Total list and database
            var currentTotal = new SqlConnect.Bank(_current, DateTime.Now);

            sql.InsertMoney("total", _userId, _current);
            _total.Add(currentTotal);

            // Show current total
            CurrentMoney.Text = _current.ToString("C");
        }