Ejemplo n.º 1
0
        public AccountViewForm(MoneyDataSet.AccountsRow account)
        {
            InitializeComponent();
            this.account = account;

            tbTitle.Text       = account.FullTitle;
            tbBalance.Text     = account.Balance.ToString(Consts.UI.CurrencyFormat, account.CurrenciesRow.CurrencyCultureInfo);
            tbDescription.Text = account.Description;
            ttbTags.Tags       = keeper.GetAccountTagStrings(account);
            DialogResult       = DialogResult.Cancel;
        }
Ejemplo n.º 2
0
        private void AccountEditForm_Load(object sender, EventArgs e)
        {
            tbTitle.AutoCompleteCustomSource.AddRange(keeper.GetTextHistory(Consts.Keeper.AccountTitleHistoryID));
            cbAccountType.DisplayMember = keeper.DataSet.AccountTypes.TitleColumn.ColumnName;
            cbAccountType.ValueMember   = keeper.DataSet.AccountTypes.IDColumn.ColumnName;
            // cbAccountType.DataSource = keeper.GetAccountTypes(isDebit);
            foreach (var accountTtype in keeper.GetAccountTypes(isDebit))
            {
                cbAccountType.Items.Add(accountTtype);
            }
            cbAccountType.SelectedIndex = 0;

            cbCurrency.DisplayMember = keeper.DataSet.Currencies.TitleColumn.ColumnName;
            cbCurrency.ValueMember   = keeper.DataSet.Currencies.IDColumn.ColumnName;

            // cbCurrency.DataSource = keeper.Currencies;
            foreach (var currency in keeper.Currencies)
            {
                cbCurrency.Items.Add(currency);
            }
            cbCurrency.SelectedIndex = 0;

            ttbTags.SetAvailableTags(keeper.Tags);

            if (account != null)
            {
                cbAccountType.SelectedItem = account.AccountTypesRow;
                cbCurrency.SelectedItem    = account.CurrenciesRow;
                cbAccountType.Enabled      = false;
                cbCurrency.Enabled         = false;
                tbTitle.Text          = account.Title;
                lblBalance.Text       = String.Format(account.CurrenciesRow.CurrencyCultureInfo, Resources.Labels.BalanceFormat, account.Balance);
                tbDescription.Text    = account.Description;
                cbHideAccount.Checked = account.IsHidden;
                ttbTags.Tags          = keeper.GetAccountTagStrings(account);
            }
            else
            {
                if (accountType != null)
                {
                    cbAccountType.SelectedItem = accountType;
                }
                lblBalance.Text       = Resources.Labels.BalanceLaterHint;
                cbHideAccount.Enabled = false;
            }
        }
Ejemplo n.º 3
0
        private void showResults(String tag = null)
        {
            dgvSearchResults.Rows.Clear();

            IEnumerable <MoneyDataSet.AccountsRow>            accounts     = null;
            IEnumerable <MoneyDataSet.TransactionsRow>        transactions = null;
            IEnumerable <MoneyDataSet.PlannedTransactionsRow> plans        = null;

            if (String.IsNullOrEmpty(tag))
            {
                keeper.AddTextHistory(Consts.Keeper.HistorySearchID, tsstbSearchText.Text);
                updateSearchSuggestions();

                String searchString = tsstbSearchText.Text.ToLower().Trim();

                accounts     = keeper.Accounts;
                transactions = keeper.Transactions;
                plans        = keeper.PlannedTransactions;

                foreach (String word in searchString.Split(Consts.UI.WordDividers, StringSplitOptions.RemoveEmptyEntries))
                {
                    if (String.IsNullOrEmpty(word))
                    {
                        continue;
                    }

                    accounts = accounts.Where(a => ((a.Title.ToLower().Contains(word)) ||
                                                    (a.Description.ToLower().Contains(word)) || (a.AccountTypesRow.Title.ToLower().Contains(word)) ||
                                                    (a.GetAccountTagsRows().Where(at => (at.TagRow.Title.ToLower().Contains(word))).Any())
                                                    ));

                    transactions = transactions.Where(t => ((t.Title.ToLower().Contains(word)) ||
                                                            (t.Description.ToLower().Contains(word)) || (t.TransactionTypesRow.Title.ToLower().Contains(word)) ||
                                                            (t.GetTransactionTagsRows().Where(tt => (tt.TagRow.Title.ToLower().Contains(word))).Any())
                                                            ));

                    plans = plans.Where(p => ((p.Title.ToLower().Contains(word)) ||
                                              (p.Description.ToLower().Contains(word)) || (p.TransactionTypeRow.Title.ToLower().Contains(word)) ||
                                              (p.AccountTypeRow.Title.ToLower().Contains(word)) ||
                                              (p.GetPlannedTransactionTagsRows().Where(pt => (pt.TagRow.Title.ToLower().Contains(word))).Any())
                                              ));

                    if (!((accounts.Any()) || (transactions.Any()) || (plans.Any())))
                    {
                        // nothing found, no need to look further
                        break;
                    }
                }
            }
            else
            {
                accounts = keeper.Accounts.Where(a =>
                                                 (a.GetAccountTagsRows().Where(at => (at.TagRow.Title.Equals(tag))).Any()));

                transactions = keeper.Transactions.Where(t =>
                                                         (t.GetTransactionTagsRows().Where(tt => (tt.TagRow.Title.Equals(tag))).Any()));

                plans = keeper.PlannedTransactions.Where(p =>
                                                         (p.GetPlannedTransactionTagsRows().Where(pt => (pt.TagRow.Title.Equals(tag))).Any()));
            }

            // accounts
            foreach (MoneyDataSet.AccountsRow a in accounts)
            {
                int i = dgvSearchResults.Rows.Add(Properties.Resources.book_open, a.FullTitle, a.EntryTime,
                                                  a.Balance.ToString(Consts.UI.CurrencyFormat, a.CurrenciesRow.CurrencyCultureInfo),
                                                  String.Join(Consts.UI.EnumerableSeparator, keeper.GetAccountTagStrings(a)));

                dgvSearchResults.Rows[i].Tag = a;
            }

            // transactions
            foreach (MoneyDataSet.TransactionsRow t in transactions)
            {
                int i = dgvSearchResults.Rows.Add(Properties.Resources.application_form, t.FullTitle, t.TransactionTime,
                                                  t.Amount.ToString(Consts.UI.CurrencyFormat, t.AccountRow.CurrenciesRow.CurrencyCultureInfo),
                                                  String.Join(Consts.UI.EnumerableSeparator, keeper.GetTransactionTagStrings(t)));

                dgvSearchResults.Rows[i].Tag = t;
            }

            // plans
            foreach (MoneyDataSet.PlannedTransactionsRow p in plans)
            {
                DateTime?startTime = null;
                if (!p.IsStartTimeNull())
                {
                    startTime = p.StartTime;
                }
                int i = dgvSearchResults.Rows.Add(Properties.Resources.date, p.FullTitle, startTime,
                                                  p.Amount.ToString(Consts.UI.CurrencyFormat, p.CurrenciesRow.CurrencyCultureInfo),
                                                  String.Join(Consts.UI.EnumerableSeparator, keeper.GetPlannedTransactionTagStrings(p)));

                dgvSearchResults.Rows[i].Tag = p;
            }

            dgvcSearchResultsAmount.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            dgvcSearchResultsTitle.AutoSizeMode  = DataGridViewAutoSizeColumnMode.AllCells;
            dgvcSearchResultsDate.AutoSizeMode   = DataGridViewAutoSizeColumnMode.AllCells;
            dgvSearchResults.Sort(dgvcSearchResultsDate, ListSortDirection.Descending);
        }