Exemplo n.º 1
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;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Update list of text suggestions on search boxes
 /// </summary>
 private void refreshSearchSuggestions()
 {
     tsstbSearch.AutoCompleteCustomSource.Clear();
     tsstbSearch.AutoCompleteCustomSource.AddRange(keeper.GetTextHistory(Consts.Keeper.HistorySearchID));
 }
Exemplo n.º 3
0
        private void PlanFromTemplateForm_Load(object sender, EventArgs e)
        {
            // some pre-checks
            if (template == null)
            {
                ErrorHelper.ShowErrorBox(ErrorHelper.Errors.PlanTemplateIsNull);
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            if ((sourcePlan != null) && (template.HasDestinationAccount) && (destinationPlan == null))
            {
                ErrorHelper.ShowErrorBox(ErrorHelper.Errors.PlanDestinationAccountIsNull);
                Log.Write("Source plan", sourcePlan);
                Log.Write("Template", template);
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }

            this.Text = String.Format(Resources.Labels.PlannedTemplateFormat, template.Title);
            lblTransactionMessage.Text = template.Message;

            tbTitle.AutoCompleteCustomSource.AddRange(keeper.GetTextHistory(String.Format(Consts.Keeper.TransactionTitleHistoryIDFormat, template.ID)));

            if (sourcePlan != null)
            {
                if (isCopy)
                {
                    tbTitle.Text = String.Format(Resources.Labels.CopyFormat, sourcePlan.Title);
                }
                else
                {
                    tbTitle.Text = sourcePlan.Title;
                }

                cbIsAggregated.Checked = sourcePlan.IsAggregated;
            }
            else
            {
                tbTitle.Text = template.TransactionDefaultTitle;
            }
            ttbTags.SetAvailableTags(keeper.Tags);


            cbSourceAccountType.DisplayMember = keeper.DataSet.AccountTypes.TitleColumn.ColumnName;
            cbSourceAccountType.ValueMember   = keeper.DataSet.AccountTypes.IDColumn.ColumnName;
            // cbSourceAccountType.DataSource = keeper.GetAccountTypes(template.AccountTypesRowByFK_AccountTypes_Source_TransactionTemplates,
            //    template.ExactSourceAccountType);
            foreach (var accountType in keeper.GetAccountTypes(template.AccountTypesRowByFK_AccountTypes_Source_TransactionTemplates, template.ExactSourceAccountType))
            {
                cbSourceAccountType.Items.Add(accountType);
            }
            cbSourceAccountType.SelectedIndex = 0;

            cbSourceCurrency.DisplayMember = keeper.DataSet.Currencies.TitleColumn.ColumnName;
            cbSourceCurrency.ValueMember   = keeper.DataSet.Currencies.IDColumn.ColumnName;
            //cbSourceCurrency.DataSource = keeper.Currencies;
            cbDestinationCurrency.DisplayMember = keeper.DataSet.Currencies.TitleColumn.ColumnName;
            cbDestinationCurrency.ValueMember   = keeper.DataSet.Currencies.IDColumn.ColumnName;
            //cbDestinationCurrency.DataSource = keeper.Currencies;

            foreach (MoneyDataSet.CurrenciesRow currency in keeper.Currencies)
            {
                cbSourceCurrency.Items.Add(currency);
                cbDestinationCurrency.Items.Add(currency);
            }
            cbSourceCurrency.SelectedIndex      = 0;
            cbDestinationCurrency.SelectedIndex = 0;

            cbRecurrency.DisplayMember = keeper.DataSet.Recurrencies.TitleColumn.ColumnName;
            cbRecurrency.ValueMember   = keeper.DataSet.Recurrencies.IDColumn.ColumnName;
            // cbRecurrency.DataSource = keeper.Recurrencies;
            foreach (var recurrency in keeper.Recurrencies)
            {
                cbRecurrency.Items.Add(recurrency);
            }
            cbRecurrency.SelectedIndex = 0;

            cbRecurrency_SelectionChangeCommitted(null, null);

            if (template.HasDestinationAccount)
            {
                cbDestinationAccountType.DisplayMember = keeper.DataSet.AccountTypes.TitleColumn.ColumnName;
                cbDestinationAccountType.ValueMember   = keeper.DataSet.AccountTypes.IDColumn.ColumnName;
                //cbDestinationAccountType.DataSource = keeper.GetAccountTypes(template.AccountTypesRowByFK_AccountTypes_Destination_TransactionTemplates,
                //    template.ExactDestinationAccountType);
                foreach (var accountType in keeper.GetAccountTypes(template.AccountTypesRowByFK_AccountTypes_Destination_TransactionTemplates, template.ExactDestinationAccountType))
                {
                    cbDestinationAccountType.Items.Add(accountType);
                }
                cbDestinationAccountType.SelectedIndex = 0;

                if (template.IsAmountIdentical)
                {
                    numDestinationAmount.Enabled = false;
                }
                updateDestinationAmount();
            }
            else
            {
                tlpTemplatePlan.Controls.Remove(gbDestination);
                tlpTemplatePlan.SetColumnSpan(gbSource, 2);

                // renaming Source to Account
                gbSource.Text = Resources.Labels.AccountAmountGroupBoxLabel;
            }

            if (sourcePlan != null)
            {
                cbSourceAccountType.SelectedItem = sourcePlan.AccountTypeRow;
                cbSourceCurrency.SelectedItem    = sourcePlan.CurrenciesRow;
                cbRecurrency.SelectedItem        = sourcePlan.RecurrenciesRow;
                ttbTags.Tags          = keeper.GetPlannedTransactionTagStrings(sourcePlan);
                numSourceAmount.Value = (decimal)sourcePlan.Amount;

                if (sourcePlan.IsStartTimeNull())
                {
                    dtpStartDate.Checked = false;
                }
                else
                {
                    dtpStartDate.Checked = true;
                    dtpStartDate.Value   = sourcePlan.StartTime;
                }
                dtpStartDate_ValueChanged(null, null);

                if (destinationPlan != null)
                {
                    cbDestinationAccountType.SelectedItem = destinationPlan.AccountTypeRow;
                    cbDestinationCurrency.SelectedItem    = destinationPlan.CurrenciesRow;
                    numDestinationAmount.Value            = (decimal)destinationPlan.Amount;
                }
            }
            else
            {
                dtpStartDate.Checked = true;
            }

            if ((sourcePlan != null) && (!sourcePlan.RecurrencyID.Equals(MoneyDataSet.IDs.Recurrencies.None)) && (!sourcePlan.IsEndTimeNull()))
            {
                dtpEndDate.Value   = sourcePlan.EndTime;
                dtpEndDate.Enabled = true;
                lblEndDate.Enabled = true;
            }
            else
            {
                // default end date - next month, unchecked
                dtpEndDate.Value   = DateTime.Now.AddMonths(1);
                dtpEndDate.Checked = false;
                lblEndDate.Enabled = false;
            }

            if (isCopy)
            {
                // clearing info, so submit will create new entries
                sourcePlan      = null;
                destinationPlan = null;
            }
            numSourceAmount.Select(0, Int32.MaxValue);
            numDestinationAmount.Select(0, Int32.MaxValue);
        }
Exemplo n.º 4
0
        private void TransactionFromTemplateForm_Load(object sender, EventArgs e)
        {
            if (!PreCheck())
            {
                this.DialogResult = DialogResult.Abort;
                this.Close();
                return;
            }

            this.Text = template.Title;

            tbTitle.AutoCompleteCustomSource.AddRange(keeper.GetTextHistory(String.Format(Consts.Keeper.TransactionTitleHistoryIDFormat, template.ID)));

            lblTransactionMessage.Text = template.Message;

            tbTitle.Text = template.TransactionDefaultTitle;
            ttbTags.SetAvailableTags(keeper.Tags);

            cbSourceAccount.DisplayMember = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName;
            cbSourceAccount.ValueMember   = keeper.DataSet.Accounts.IDColumn.ColumnName;
            // cbSourceAccount.DataSource = sourceAccounts;
            foreach (var account in sourceAccounts)
            {
                cbSourceAccount.Items.Add(account);
            }
            cbSourceAccount.SelectedIndex = 0;

            updateSourceCurrency();

            cbSourcePlan.DisplayMember = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName;
            cbSourcePlan.ValueMember   = keeper.DataSet.PlannedTransactions.IDColumn.ColumnName;
            sourcePlans = keeper.GetRelevantPlannedTransactions(template.SourceTransactionTypeID);
            if (sourcePlans.Any())
            {
                cbSourceImplementsPlan.Enabled = true;
                //cbSourcePlan.DataSource = sourcePlans;
                foreach (var srcPlan in sourcePlans)
                {
                    cbSourcePlan.Items.Add(srcPlan);
                }
                cbSourcePlan.SelectedIndex = 0;
            }

            IEnumerable <MoneyDataSet.PlannedTransactionsRow> destinationPlans = null;

            if (template.HasDestinationAccount)
            {
                cbDestinationAccount.DisplayMember = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName;
                cbDestinationAccount.ValueMember   = keeper.DataSet.Accounts.IDColumn.ColumnName;
                cbDestinationAccount.DataSource    = destinationAccounts;

                if (template.IsAmountIdentical)
                {
                    numDestinationAmount.Enabled = false;
                }
                updateDestinationCurrency();
                updateDestinationAmount();

                destinationPlans = keeper.GetRelevantPlannedTransactions(template.DestinationTransactionTypeID);
                if (destinationPlans.Any())
                {
                    cbDestinationImplementsPlan.Enabled = true;
                    cbDestinationPlan.DisplayMember     = MoneyDataSet.IDs.SpecialColumns.FullTitleColumnName;
                    cbDestinationPlan.ValueMember       = keeper.DataSet.PlannedTransactions.IDColumn.ColumnName;
                    // cbDestinationPlan.DataSource = destinationPlans;
                    foreach (var destPlan in destinationPlans)
                    {
                        cbDestinationPlan.Items.Add(destPlan);
                    }
                    cbDestinationPlan.SelectedIndex = 0;
                }
            }
            else
            {
                tlpTemplateTransaction.Controls.Remove(gbDestination);
                tlpTemplateTransaction.SetColumnSpan(gbSource, 2);

                // renaming Source to Account
                gbSource.Text = Resources.Labels.AccountAmountGroupBoxLabel;
            }

            if ((sourcePlan != null) && (sourcePlans.Contains(sourcePlan)))
            {
                cbSourceImplementsPlan.Checked = true;
                cbSourcePlan.SelectedItem      = sourcePlan;
                cbSourcePlan_SelectionChangeCommitted(null, null);
            }

            if ((template.HasDestinationAccount) && (destinationPlan != null) && ((destinationPlans != null) && (destinationPlans.Contains(destinationPlan))))
            {
                cbDestinationImplementsPlan.Checked = true;
                cbDestinationPlan.SelectedItem      = sourcePlan;
                cbDestinationPlan_SelectionChangeCommitted(null, null);
            }
            numSourceAmount.Select(0, Int32.MaxValue);
            numDestinationAmount.Select(0, Int32.MaxValue);
        }