private void refreshPlans() { dgvPlans.Rows.Clear(); IEnumerable<MoneyDataSet.PlannedTransactionsRow> plans = keeper.PlannedTransactions.OrderBy(o => (o.TransactionTypeRow.Title)); if (!tsbShowAll.Checked) { plans = keeper.GetRelevantPlannedTransactions().OrderBy(o => (o.TransactionTypeRow.Title));; } foreach (MoneyDataSet.PlannedTransactionsRow plan in plans) { int rowID = dgvPlans.Rows.Add(plan.DateRecurrency, plan.TransactionTypeRow.Title, plan.Title, plan.Amount.ToString(Consts.UI.CurrencyFormat, plan.CurrenciesRow.CurrencyCultureInfo), plan.AccountTypeRow.Title); dgvPlans.Rows[rowID].Tag = plan; } //dgvPlans.Sort(dgvPlans.Columns[0], ListSortDirection.Ascending); if (dgvPlans.Rows.Count == 0) { tsbEdit.Enabled = false; tsbCopy.Enabled = false; tsbImplement.Enabled = false; tsbDelete.Enabled = false; } else { tsbEdit.Enabled = true; tsbCopy.Enabled = true; tsbImplement.Enabled = true; tsbDelete.Enabled = true; } }
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); }