示例#1
0
        public static bool DeleteTransaction(MoneyDataSet.TransactionsRow transaction)
        {
            String message = transaction.IsPairReferenceIDNull() ? String.Format(Resources.Labels.DeleteTransactionFormat, transaction.FullTitle) :
                String.Format(Resources.Labels.DeletePairedTransactionFormat, transaction.FullTitle);

            if (MessageBox.Show(message, Resources.Labels.DeleteTransactionTitle, MessageBoxButtons.OKCancel,
                MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
            {
                MoneyDataKeeper.Instance.DeleteTransaction(transaction.ID);
                return true;
            }
            return false;
        }
示例#2
0
        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;
        }
        private bool askDeletePlannedTransaction(MoneyDataSet.PlannedTransactionsRow plan)
        {
            String message = String.Empty;
            if (plan.IsPairReferenceIDNull())
            {
                message = String.Format(Resources.Labels.DeletePlannedTransactionFormat, plan.FullTitle);
            }
            else
            {
                message = String.Format(Resources.Labels.DeletePairedPlannedTransactionFormat, plan.FullTitle);
            }

            if (MessageBox.Show(message, Resources.Labels.DeletePlannedTransactionTitle, MessageBoxButtons.OKCancel,
                MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK)
            {
                deletePlannedTransaction(plan.ID);
                updatePlannedTransactionsTab();
                updateWelcomeTab();
                updateTagCloud();
                return true;
            }
            return false;
        }
示例#4
0
        private MoneyDataSet.PlannedTransactionsRow clonePlannedTransaction(MoneyDataSet.PlannedTransactionsRow source)
        {
            MoneyDataSet.PlannedTransactionsRow newPlan = ds.PlannedTransactions.NewPlannedTransactionsRow();
            newPlan.HistoryReferenceID = source.HistoryReferenceID;
            newPlan.Title = source.Title;
            newPlan.Description = source.Description;
            newPlan.AccountTypeID = source.AccountTypeID;
            newPlan.TransactionTypeID = source.TransactionTypeID;
            newPlan.Amount = source.Amount;
            newPlan.IsActive = source.IsActive;
            if (source.IsStartTimeNull())
            {
                newPlan.SetStartTimeNull();
            }
            else
            {
                newPlan.StartTime = source.StartTime;
            }
            newPlan.CurrencyID = source.CurrencyID;
            newPlan.RecurrencyID = source.RecurrencyID;
            newPlan.IsAggregated = source.IsAggregated;
            newPlan.TransactionTemplatesRow = source.TransactionTemplatesRow;
            if (!source.IsPairReferenceIDNull())
            {
                newPlan.PairReferenceID = source.PairReferenceID;
            }
            if (!source.IsEndTimeNull())
            {
                newPlan.EndTime = source.EndTime;
            }
            newPlan.EntryTime = DateTime.Now;
            ds.PlannedTransactions.AddPlannedTransactionsRow(newPlan);

            foreach (MoneyDataSet.TagsRow tag in source.GetPlannedTransactionTagsRows().Select(ptt => (ptt.TagRow)))
            {
                ds.PlannedTransactionTags.AddPlannedTransactionTagsRow(newPlan, tag);
            }

            return newPlan;
        }