// Save transaction from the user
        // (Requirement 1.1.0)

        private void BtnAddTransaction_Click(object sender, RoutedEventArgs e)
        {
            if (viewModel.NewTransaction.Date.CompareTo(System.DateTime.Now) > 0)
            {
                viewModel.NewTransaction.Date = System.DateTime.Now;
                errorContent.Content          = "No future dates!";
                return;
            }
            if (viewModel.NewTransaction.Payee == "Payee")
            {
                errorContent.Content = "Must provide Payee!";
                return;
            }
            if (viewModel.NewTransaction.Amount == 0)
            {
                errorContent.Content = "Must provide Amount!";
                return;
            }
            if (viewModel.NewTransaction.Category == "Category")
            {
                viewModel.NewTransaction.Category = "";
            }
            if (viewModel.NewTransaction.Custom_notes == "Notes")
            {
                viewModel.NewTransaction.Custom_notes = "";
            }

            viewModel.AddTrans(cbDirectionTransaction.Text);

            // refresh current balance label
            BalanceLabel.GetBindingExpression(Label.ContentProperty).UpdateTarget();
            viewModel.NewTransaction.DefaultAll();
            errorContent.Content = "";
        }
        void ReleaseDesignerOutlets()
        {
            if (AccountNameLabel != null)
            {
                AccountNameLabel.Dispose();
                AccountNameLabel = null;
            }

            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BalanceLabel != null)
            {
                BalanceLabel.Dispose();
                BalanceLabel = null;
            }

            if (DepositButton != null)
            {
                DepositButton.Dispose();
                DepositButton = null;
            }

            if (QuickDepositButton != null)
            {
                QuickDepositButton.Dispose();
                QuickDepositButton = null;
            }

            if (TransactionTableView != null)
            {
                TransactionTableView.Dispose();
                TransactionTableView = null;
            }

            if (WithdrawlButton != null)
            {
                WithdrawlButton.Dispose();
                WithdrawlButton = null;
            }
        }
Example #3
0
        void ReleaseDesignerOutlets()
        {
            if (BadgeText != null)
            {
                BadgeText.Dispose();
                BadgeText = null;
            }

            if (BalanceLabel != null)
            {
                BalanceLabel.Dispose();
                BalanceLabel = null;
            }

            if (LastUpdateLabel != null)
            {
                LastUpdateLabel.Dispose();
                LastUpdateLabel = null;
            }
        }
Example #4
0
        void ReleaseDesignerOutlets()
        {
            if (AccountNumberLabel != null)
            {
                AccountNumberLabel.Dispose();
                AccountNumberLabel = null;
            }

            if (BalanceLabel != null)
            {
                BalanceLabel.Dispose();
                BalanceLabel = null;
            }

            if (ProductLabel != null)
            {
                ProductLabel.Dispose();
                ProductLabel = null;
            }
        }
Example #5
0
        void ReleaseDesignerOutlets()
        {
            if (BalanceLabel != null)
            {
                BalanceLabel.Dispose();
                BalanceLabel = null;
            }

            if (RevealButton != null)
            {
                RevealButton.Dispose();
                RevealButton = null;
            }

            if (TransactionsTableView != null)
            {
                TransactionsTableView.Dispose();
                TransactionsTableView = null;
            }
        }
        private void ConfirmImportClick(object sender, RoutedEventArgs e)
        {
            if (!viewModel.Importing)
            {
                return;
            }

            CsvImportStatus.Content = $"Status: Processing {viewModel.Imported.Count} new transactions...";

            foreach (TransactionModel t in viewModel.Imported)
            {
                SqliteDataAccess.SaveTransaction(t);
            }
            viewModel.RefreshData();
            BalanceLabel.GetBindingExpression(Label.ContentProperty).UpdateTarget();

            CsvDatePreview.Content   = "";
            CsvAmountPreview.Content = "";
            CsvPayeePreview.Content  = "";
            CsvNumberPreview.Content = "";
            CsvImportStatus.Content  = $"Status: {viewModel.Imported.Count} transactions added";
            viewModel.Imported       = null;
            viewModel.Importing      = false;
        }
        void ReleaseDesignerOutlets()
        {
            if (AmountLabel != null)
            {
                AmountLabel.Dispose();
                AmountLabel = null;
            }

            if (AmountValueLabel != null)
            {
                AmountValueLabel.Dispose();
                AmountValueLabel = null;
            }

            if (BalanceLabel != null)
            {
                BalanceLabel.Dispose();
                BalanceLabel = null;
            }

            if (BalanceValueLabel != null)
            {
                BalanceValueLabel.Dispose();
                BalanceValueLabel = null;
            }

            if (DateLabel != null)
            {
                DateLabel.Dispose();
                DateLabel = null;
            }

            if (DateValueLabel != null)
            {
                DateValueLabel.Dispose();
                DateValueLabel = null;
            }

            if (IdLabel != null)
            {
                IdLabel.Dispose();
                IdLabel = null;
            }

            if (IdValueLabel != null)
            {
                IdValueLabel.Dispose();
                IdValueLabel = null;
            }

            if (NameLabel != null)
            {
                NameLabel.Dispose();
                NameLabel = null;
            }

            if (NameValueLabel != null)
            {
                NameValueLabel.Dispose();
                NameValueLabel = null;
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (BalanceLabel != null)
            {
                BalanceLabel.Dispose();
                BalanceLabel = null;
            }

            if (DatePayment != null)
            {
                DatePayment.Dispose();
                DatePayment = null;
            }

            if (ErorrPayment != null)
            {
                ErorrPayment.Dispose();
                ErorrPayment = null;
            }

            if (InfoPaymentLabel != null)
            {
                InfoPaymentLabel.Dispose();
                InfoPaymentLabel = null;
            }

            if (MapCloseButton != null)
            {
                MapCloseButton.Dispose();
                MapCloseButton = null;
            }

            if (MapShow != null)
            {
                MapShow.Dispose();
                MapShow = null;
            }

            if (MapsViewusr != null)
            {
                MapsViewusr.Dispose();
                MapsViewusr = null;
            }

            if (ResultView != null)
            {
                ResultView.Dispose();
                ResultView = null;
            }

            if (SuccessPayment != null)
            {
                SuccessPayment.Dispose();
                SuccessPayment = null;
            }

            if (SummPayment != null)
            {
                SummPayment.Dispose();
                SummPayment = null;
            }

            if (TkName != null)
            {
                TkName.Dispose();
                TkName = null;
            }
        }
Example #9
0
        private void FlipBTN_Click(object sender, EventArgs e)
        {
            if (headsTailsComboBox.Text != "Heads" && headsTailsComboBox.Text != "Tails")
            {
                MessageBox.Show("Which site do you think the coin will land on?");
            }
            else
            {
                try
                {
                    bet = int.Parse(BetBox.Text);
                }
                catch
                {
                    MessageBox.Show("Your bet should be a number");
                }
                if (balance - bet < 0)
                {
                    MessageBox.Show("You don't have that much money");
                }
                else if (bet <= 0)
                {
                    MessageBox.Show("Make a bet greater than 0");
                }
                else
                {
                    balance          -= bet;
                    BalanceLabel.Text = "" + balance;
                    BalanceLabel.Refresh();
                    Landing = HeadsTails();
                    if (Landing == true)
                    {
                        animationHeads();
                    }
                    else if (Landing == false)
                    {
                        animationTails();
                    }

                    if (headsTailsComboBox.Text == "Heads" && Landing == true || headsTailsComboBox.Text == "Tails" && Landing == false)
                    {
                        MessageBox.Show("You won " + 2 * bet);
                        balance          += 2 * bet;
                        BalanceLabel.Text = "" + balance;
                        if (HighScore < balance)
                        {
                            HighScore           = balance;
                            HighScoreLabel.Text = "" + balance;
                        }
                    }
                    else
                    {
                        MessageBox.Show("You lost");
                    }
                    if (balance == 0)
                    {
                        MessageBox.Show("You're bankrupt. You can restart the game if you want to :)");
                    }
                }
            }
        }
 private void DeleteTransactionButtonClick(object sender, RoutedEventArgs e)
 {
     viewModel.RemoveTrans();
     // refresh current balance label
     BalanceLabel.GetBindingExpression(Label.ContentProperty).UpdateTarget();
 }
        // Updates DB when transaction cells are edited by user
        private void Transactions_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.EditAction == DataGridEditAction.Commit)
            {
                // Need to get the new user-edited value with a switch statement
                var c = e.Column as DataGridBoundColumn;
                if (c != null)
                {
                    TransactionModel editedTransaction = (TransactionModel)e.Row.DataContext;
                    int rowIndex      = e.Row.GetIndex();
                    var el            = e.EditingElement as TextBox;
                    var changedColumn = (c.Binding as Binding).Path.Path;
                    try
                    {
                        switch (changedColumn)
                        {
                        case "Date":
                            DateTime d;
                            try
                            {
                                d = Convert.ToDateTime(el.Text);
                            }
                            catch
                            {
                                // error parsing
                                this.Recent_Transactions.CancelEdit();
                                return;
                            }
                            if (d.CompareTo(System.DateTime.Now) > 0)
                            {
                                // cannot use a future date
                                this.Recent_Transactions.CancelEdit();
                                return;
                            }
                            editedTransaction.Date = d;
                            break;

                        case "Amount":
                            Decimal a;
                            try
                            {
                                a = Convert.ToDecimal(el.Text.Replace("$", ""));
                            }
                            catch
                            {
                                // error parsing
                                this.Recent_Transactions.CancelEdit();
                                return;
                            }
                            //Created bug; unable to maintain an outflow transaction on edit
                            //if (a <= 0)
                            //{
                            //    // amount cannot be negative
                            //    this.Recent_Transactions.CancelEdit();
                            //    return;
                            //}
                            editedTransaction.Amount = a;
                            break;

                        case "Payee":
                            editedTransaction.Payee = el.Text;
                            if (el.Text == "")
                            {
                                // payee cannot be blank
                                this.Recent_Transactions.CancelEdit();
                                return;
                            }
                            break;

                        case "Category":
                            editedTransaction.Category = el.Text;
                            break;

                        case "Custom_notes":
                            editedTransaction.Custom_notes = el.Text;
                            break;

                        default:
                            // not allowed to change balance, return now
                            return;
                        }
                        // save edited transaction to DB and refresh UI
                        viewModel.UpdateTransaction(editedTransaction);
                        BalanceLabel.GetBindingExpression(Label.ContentProperty).UpdateTarget();
                    }
                    catch
                    {
                        return;
                    }
                }
            }
        }