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; } }
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); }