Esempio n. 1
0
        private void Loans_listView_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get selected item value
            Loan loan = Loans_listView.SelectedItems.Count > 0 ? (Loan)Loans_listView.SelectedItems[0].Tag : null;

            if (loan == null)
            {
                return;
            }                             // to handle listView idiot 2 step item selection process

            // search DB for loan and update textBoxes
            var rdr = DB_API.SelectLoan(account_id, loan.Name);

            while (rdr.Read())
            {
                Name_textBox.Text               = rdr[DB_API.LoanEnt.name.ToString()].ToString();
                Name_textBox.ForeColor          = Color.Black;
                InitialAmount_textBox.Text      = DB_API.Moneyfy(rdr[DB_API.LoanEnt.initial_amount.ToString()].ToString());
                InitialAmount_textBox.ForeColor = Color.Black;
                CurrentDebt_textBox.Text        = DB_API.Moneyfy(rdr[DB_API.LoanEnt.current_debt.ToString()].ToString());
                CurrentDebt_textBox.ForeColor   = Color.Black;
                Enddate_dateTimePicker.Value    = DateTime.Parse(rdr[DB_API.LoanEnt.term.ToString()].ToString());
                Interest_textBox.Text           = Double.Parse(rdr[DB_API.LoanEnt.interest.ToString()].ToString()).ToString() + "%";
                Interest_textBox.ForeColor      = Color.Black;
            }
        }
Esempio n. 2
0
        private void Accounts_listbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get selected item value
            string account_name = (string)accounts_listbox.SelectedItem;
            int    account_id   = CURRENT_USER_ACCOUNTS[account_name];

            // set account_name label
            account_textbox.Text      = account_name;
            account_textbox.ForeColor = Color.Black;

            // get account complete info
            var rdr = DB_API.SelectMoneyAccountById(account_id);

            while (rdr.Read())
            {
                balance_textbox.Text   = DB_API.Moneyfy(Double.Parse(rdr[DB_API.MoneyAccountEnt.balance.ToString()].ToString()));
                patrimony_textbox.Text = DB_API.Moneyfy(Double.Parse(rdr[DB_API.MoneyAccountEnt.patrimony.ToString()].ToString()));
            }

            // get associated user of selected account
            rdr = DB_API.SelectMoneyAccountUsers(account_id);
            List <String> res = new List <string>();

            while (rdr.Read())
            {
                res.Add(rdr["user_email"].ToString());
            }
            associatedusers_listbox.DataSource = res;
        }
        private void Transactions_listView_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get selected item value
            Transaction tr = Transactions_listView.SelectedItems.Count > 0 ?
                             (Transaction)Transactions_listView.SelectedItems[0].Tag : null;

            if (tr == null)
            {
                return;
            }                           // to handle listView idiot 2 step item selection process

            // update TextBoxes
            // category and subcategory
            int category_id = (int)tr.CategoryID;

            if (category_id % 100 == 0) // is category
            {
                category_comboBox.Text    = categoriesIntStr[category_id];
                subcategory_comboBox.Text = this.none;
            }
            else
            {
                category_comboBox.Text    = categoriesIntStr[category_id / 100 * 100];
                subcategory_comboBox.Text = categoriesIntStr[category_id];
            }

            // transaction type
            type_comboBox.Text = DB_API.SelectTransactionTypeNameById((int)tr.TransactionTypeID);

            // wallet
            var rdr = DB_API.SelectWallet((int)tr.WalletID);

            while (rdr.Read())
            {
                wallet_comboBox.Text = rdr[DB_API.WalletEnt.name.ToString()].ToString();
                break;
            }
            if ((int)tr.TransactionTypeID == 0)
            {
                rdr = DB_API.SelectWallet((int)tr.RecipientWalletID);
                while (rdr.Read())
                {
                    wallet2_comboBox.Text = rdr[DB_API.WalletEnt.name.ToString()].ToString();
                    break;
                }
            }


            // amount
            amount_textBox.Text      = DB_API.Moneyfy(tr.Amount);
            amount_textBox.ForeColor = Color.Black;
            // date
            dateTimePicker.Value = (DateTime)tr.Date;
            // notes and location
            notes_textBox.Text         = tr.Notes;
            notes_textBox.ForeColor    = Color.Black;
            location_textBox.Text      = tr.Location;
            location_textBox.ForeColor = Color.Black;
        }
        private void Filtermaxamount_textBox_Leave(object sender, EventArgs e)
        {
            filtermaxamount_textBox.Text = DB_API.Moneyfy(filtermaxamount_textBox.Text);

            if (filtermaxamount_textBox.Text.Equals(""))
            {
                filtermaxamount_textBox.Text      = "max amount";
                filtermaxamount_textBox.ForeColor = Color.Gray;
            }
        }
        private void Amount_textBox_Leave(object sender, EventArgs e)
        {
            amount_textBox.Text = DB_API.Moneyfy(amount_textBox.Text);

            if (amount_textBox.Text.Equals(""))
            {
                amount_textBox.Text      = "amount";
                amount_textBox.ForeColor = Color.Gray;
            }
        }
        private void Goalamount_textBox_Leave(object sender, EventArgs e)
        {
            goalamount_textBox.Text = DB_API.Moneyfy(goalamount_textBox.Text);

            if (goalamount_textBox.Text.Equals(""))
            {
                goalamount_textBox.Text      = "goal value";
                goalamount_textBox.ForeColor = Color.Gray;
            }
        }
Esempio n. 7
0
        private void Pay_textBox_Leave(object sender, EventArgs e)
        {
            Pay_textBox.Text = DB_API.Moneyfy(Pay_textBox.Text);

            if (Pay_textBox.Text.Equals(""))
            {
                Pay_textBox.Text      = "payment";
                Pay_textBox.ForeColor = Color.Gray;
            }
        }
Esempio n. 8
0
        private void CurrentDebt_textBox_Leave(object sender, EventArgs e)
        {
            CurrentDebt_textBox.Text = DB_API.Moneyfy(CurrentDebt_textBox.Text);

            if (CurrentDebt_textBox.Text.Equals(""))
            {
                CurrentDebt_textBox.Text      = "current debt";
                CurrentDebt_textBox.ForeColor = Color.Gray;
            }
        }
        private void Budgets_listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get selected item value
            string budget    = (string)Budgets_listBox.SelectedItem;
            int    budget_id = this.budgetsDict[budget];

            // search DB for budgets
            var rdr = DB_API.SelectBudget(budget_id);
            var res = new Dictionary <string, int>();

            while (rdr.Read())
            {
                StartMonth_comboBox.Text   = months[DateTime.Parse(rdr[DB_API.BudgetEnt.start_date.ToString()].ToString()).Month];
                StartYear_numericBox.Value = DateTime.Parse(rdr[DB_API.BudgetEnt.start_date.ToString()].ToString()).Year;
                EndMonth_comboBox.Text     = months[DateTime.Parse(rdr[DB_API.BudgetEnt.start_date.ToString()].ToString()).Month];
                EndYear_numericBox.Value   = DateTime.Parse(rdr[DB_API.BudgetEnt.start_date.ToString()].ToString()).Year;
                Budget_textBox.Text        = DB_API.Moneyfy(rdr[DB_API.BudgetEnt.amount.ToString()].ToString());
            }
        }
Esempio n. 10
0
        // -------------------------------------------------------------------
        // LIST BOXES --------------------------------------------------------
        // -------------------------------------------------------------------

        private void PopulateLoansListView()
        {
            // clear listView items
            Loans_listView.Items.Clear();

            // get loans from DB
            var rdr = DB_API.SelectAccountLoans(account_id);

            // populate listView
            while (rdr.Read())
            {
                string name = rdr[DB_API.LoanEnt.name.ToString()].ToString();
                //double account_id = (double)(int)rdr[DB_API.LoanEnt.account_id.ToString()];
                DateTime term           = (DateTime)rdr[DB_API.LoanEnt.term.ToString()];
                double   initial_amount = Double.Parse(rdr[DB_API.LoanEnt.initial_amount.ToString()].ToString());
                double   current_debt   = Double.Parse(rdr[DB_API.LoanEnt.current_debt.ToString()].ToString());
                double   interest       = Double.Parse(rdr[DB_API.LoanEnt.interest.ToString()].ToString());

                var row  = new string[] { name, term.ToString("dd/MM/yyyy"), DB_API.Moneyfy(current_debt) };
                var item = new ListViewItem(row);
                item.Tag = new Loan(name, null, initial_amount, current_debt, term, interest);
                Loans_listView.Items.Add(item);
            }
        }
 private void Budget_textBox_Leave(object sender, EventArgs e)
 {
     Budget_textBox.Text = DB_API.Moneyfy(Budget_textBox.Text);
 }
        private void PrivatePopulateTransactionsListView(DataTableReader rdr)
        {
            // clear Transactions listView
            Transactions_listView.Items.Clear();

            while (rdr.Read())
            {
                int      transaction_id      = (int)rdr[DB_API.TransactionEnt.transaction_id.ToString()];
                int      category_id         = (int)rdr[DB_API.TransactionEnt.category_id.ToString()];
                int      account_id          = (int)rdr[DB_API.TransactionEnt.account_id.ToString()];
                int      transaction_type_id = (int)rdr[DB_API.TransactionEnt.transaction_type_id.ToString()];
                int      wallet_id           = (int)rdr[DB_API.TransactionEnt.wallet_id.ToString()];
                DateTime date     = (DateTime)rdr[DB_API.TransactionEnt.date.ToString()];
                string   category = categoriesIntStr[category_id];
                double   amount   = Double.Parse(rdr[DB_API.TransactionEnt.amount.ToString()].ToString());
                string   notes    = rdr[DB_API.TransactionEnt.notes.ToString()].ToString();
                string   location = rdr[DB_API.TransactionEnt.location.ToString()].ToString();

                // correct amount for negative or positive if expense or income
                amount = transaction_type_id >= 0 ? amount : -amount;

                if (transaction_type_id == 0)
                {
                    int recipient_wallet_id = (int)rdr[DB_API.TransactionEnt.recipient_wallet_id.ToString()];
                    var row1  = new string[] { transaction_id.ToString(), date.ToString("dd/MM/yyyy"), "Transfer", DB_API.Moneyfy(-amount) };
                    var row2  = new string[] { transaction_id.ToString(), date.ToString("dd/MM/yyyy"), "Transfer", DB_API.Moneyfy(amount) };
                    var item1 = new ListViewItem(row1);
                    var item2 = new ListViewItem(row2);
                    item1.Tag = new Transaction(transaction_id, -amount, date, notes, location, category_id, account_id, transaction_type_id, wallet_id, recipient_wallet_id);
                    item2.Tag = new Transaction(transaction_id, amount, date, notes, location, category_id, account_id, transaction_type_id, wallet_id, recipient_wallet_id);
                    Transactions_listView.Items.Add(item1);
                    Transactions_listView.Items.Add(item2);
                }
                else
                {
                    var row  = new string[] { transaction_id.ToString(), date.ToString("dd/MM/yyyy"), category, DB_API.Moneyfy(amount) };
                    var item = new ListViewItem(row);
                    item.Tag = new Transaction(transaction_id, amount, date, notes, location, category_id, account_id, transaction_type_id, wallet_id, null);
                    Transactions_listView.Items.Add(item);
                }
            }
        }
        private void Goals_listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get selected item value
            string goal_name = Goals_listBox.SelectedItem.ToString();

            var rdr = DB_API.SelectGoal(account_id, goal_name);

            while (rdr.Read())
            {
                int    category_id  = (int)rdr[DB_API.GoalEnt.category_id.ToString()];
                string cat_name     = "";
                string sub_cat_name = "";
                if (category_id % 100 == 0)
                {
                    foreach (KeyValuePair <string, int> entry in this.categories)
                    {
                        if (entry.Value == category_id)
                        {
                            cat_name     = entry.Key;
                            sub_cat_name = this.none;
                            break;
                        }
                    }
                }
                else
                {
                    int cat_id = -1;
                    foreach (KeyValuePair <string, int> entry in this.categories)
                    {
                        if (entry.Value == category_id)
                        {
                            sub_cat_name = entry.Key;
                            cat_id       = category_id / 100 * 100;
                            break;
                        }
                    }
                    foreach (KeyValuePair <string, int> entry in this.categories)
                    {
                        if (entry.Value == cat_id)
                        {
                            cat_name = entry.Key;
                            break;
                        }
                    }
                }

                // update TextBoxes
                Categories_comboBox.Text    = cat_name;
                Subcategories_comboBox.Text = sub_cat_name;
                goalname_textBox.Text       = goal_name;
                goalname_textBox.ForeColor  = Color.Black;
                double goal_amount = Double.Parse(rdr[DB_API.GoalEnt.amount.ToString()].ToString());
                goalamount_textBox.Text      = DB_API.Moneyfy(goal_amount);
                goalamount_textBox.ForeColor = Color.Black;
                term_dateTimePicker.Value    = DateTime.Parse(rdr[DB_API.GoalEnt.term.ToString()].ToString());

                // change GoalState Label
                rdr = DB_API.SelectWalletByName(account_id, goal_name);
                double balance = 0.0;
                while (rdr.Read())
                {
                    balance = Double.Parse(rdr[DB_API.WalletEnt.balance.ToString()].ToString());
                }

                if (balance < goal_amount)
                {
                    Goalstate_label2.Text = "Keep going!\r\n" + (balance / goal_amount * 100) + "% complete!\r\n" + (goal_amount - balance) + "$ to go!";
                }
                if (balance >= goal_amount)
                {
                    Goalstate_label2.Text = "Congratulations!\r\nGoal reached!\r\nSaved " + balance + "!";
                }
            }
        }