/// <summary>
        /// Display the account transactions and balance
        /// </summary>
        public void displayCurrentAccountBalanceAndTransactions()
        {
            textBoxFilter.Text = "";
            listViewTransactions.Items.Clear();

            Database database    = Database.getInstance();
            string   accountName = database.session["current_account"].ToString();

            Account account = database.accounts[accountName];
            decimal balance = 0;

            account.transactions.Sort();

            // Display each transaction in a transaction user control
            for (int i = account.transactions.Count - 1; i >= 0; i--)
            {
                Transaction transaction = account.transactions[i];
                balance += transaction.amount;

                UserControlTransaction transactionUserControl = new UserControlTransaction(this, transaction);
                listViewTransactions.Items.Add(transactionUserControl);
            }


            textBlockBalance.Text = balance.ToString("N2");
        }
        /// <summary>
        /// Display the transactions of the current account that is related to the filter search
        /// </summary>
        private void textBoxFilter_TextChanged(object sender, TextChangedEventArgs e)
        {
            listViewTransactions.Items.Clear();

            Database database = Database.getInstance();
            Account  account  = database.accounts[database.session["current_account"].ToString()];

            string keyword = textBoxFilter.Text.Trim().ToLower();

            if (keyword == string.Empty)
            {
                // Empty keyword simply display everything
                for (int i = account.transactions.Count - 1; i >= 0; i--)
                {
                    Transaction            transaction            = account.transactions[i];
                    UserControlTransaction transactionUserControl = new UserControlTransaction(this, transaction);
                    listViewTransactions.Items.Add(transactionUserControl);
                }

                return;
            }

            // Break the keyword into tokens and perform an "AND" search
            HashSet <string> keys = new HashSet <string>();

            foreach (string key in keyword.Split(' '))
            {
                if (key != string.Empty)
                {
                    keys.Add(key.ToLower());
                }
            }

            // Add only transaction that has all the keys
            for (int i = account.transactions.Count - 1; i >= 0; i--)
            {
                Transaction transaction = account.transactions[i];
                bool        hasAllKeys  = true;

                foreach (string key in keys)
                {
                    if (transaction.date.ToString("MMMM dd, yyyy").ToLower().Contains(key) ||
                        transaction.description.ToLower().Contains(keyword) ||
                        transaction.category.ToLower().Contains(keyword))
                    {
                        continue;
                    }

                    hasAllKeys = false;
                    break;
                }

                if (hasAllKeys)
                {
                    UserControlTransaction transactionUserControl = new UserControlTransaction(this, transaction);
                    listViewTransactions.Items.Add(transactionUserControl);
                }
            }
        }
        /// <summary>
        /// Show the menu of the pressed item, hide the menu of the previous item
        /// </summary>
        private void listViewTransactions_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (clickedTransactionUserControl != null)
            {
                clickedTransactionUserControl.hideMenu();
            }

            if (listViewTransactions.SelectedIndex >= 0)
            {
                clickedTransactionUserControl = listViewTransactions.SelectedItem as UserControlTransaction;
                clickedTransactionUserControl.showMenu();
            }
        }