public static bool DeletePlannedTransaction(MoneyDataSet.PlannedTransactionsRow plan) { String message = plan.IsPairReferenceIDNull() ? String.Format(Resources.Labels.DeletePlannedTransactionFormat, plan.FullTitle) : String.Format(Resources.Labels.DeletePairedPlannedTransactionFormat, plan.FullTitle); if (MessageBox.Show(message, Resources.Labels.DeletePlannedTransactionTitle, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { MoneyDataKeeper.Instance.DeletePlannedTransaction(plan.ID); return(true); } return(false); }
public PlanViewForm(MoneyDataSet.PlannedTransactionsRow plan) { InitializeComponent(); // locate source and destination plans if ((!plan.IsPairReferenceIDNull()) && (plan.PairReferenceID != 0)) { foreach (MoneyDataSet.PlannedTransactionsRow p in keeper.PlannedTransactions.Where(p => ((!p.IsPairReferenceIDNull()) && (p.PairReferenceID == plan.PairReferenceID)))) { // setting source and destination if (p.TransactionTypeID.Equals(plan.TransactionTemplatesRow.SourceTransactionTypeID)) { sourcePlan = p; } else if (p.TransactionTypeID.Equals(plan.TransactionTemplatesRow.DestinationTransactionTypeID)) { destinationPlan = p; } } if ((sourcePlan == null) || (destinationPlan == null)) { ErrorHelper.ShowErrorBox(ErrorHelper.Errors.InvalidTransaction); return; } tbDestinationAccountType.Text = destinationPlan.AccountTypeRow.Title; tbDestinationAmount.Text = destinationPlan.Amount.ToString(Consts.UI.CurrencyFormat, destinationPlan.CurrenciesRow.CurrencyCultureInfo); } else { sourcePlan = plan; // only one planned transaction, removing second column tlpTemplatePlan.Controls.Remove(gbDestination); tlpTemplatePlan.SetColumnSpan(gbSource, 2); } tbTitle.Text = sourcePlan.FullTitle; tbSourceAccountType.Text = sourcePlan.AccountTypeRow.Title; tbSourceAmount.Text = sourcePlan.Amount.ToString(Consts.UI.CurrencyFormat, sourcePlan.CurrenciesRow.CurrencyCultureInfo); tbDescription.Text = sourcePlan.Description; ttbTags.Tags = keeper.GetPlannedTransactionTagStrings(sourcePlan); this.DialogResult = DialogResult.Cancel; }