예제 #1
0
파일: TxPresenter.cs 프로젝트: qwer/budget
        void Save()
        {
            History history = new History();
            history.Amount = Amount;
            history.Date = DateTime.Now;
            history.AccountDest = Account1;
            history.AccountSrc = Account2 == null || Account2 == nullAccount
                    ? null : Account2;

            db.AddHistory(history);
        }
예제 #2
0
파일: Db.cs 프로젝트: qwer/budget
        public void AddHistory(History history)
        {
            history.AccountDest.Balance += history.Amount;
            if (history.AccountSrc != null)
                history.AccountSrc.Balance -= history.Amount;

            Container.HistorySet.AddObject(history);

            try
            {
                Container.SaveChanges();

            }
            catch (Exception e)
            {
                Error.Show(e);
                Container.Detach(history);
                Undo(history.AccountDest);
                Undo(history.AccountSrc);
                return;
            }

            if (HistoryAdded != null)
                HistoryAdded(history, null);
        }
예제 #3
0
 /// <summary>
 /// Create a new History object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="amount">Initial value of the Amount property.</param>
 /// <param name="date">Initial value of the Date property.</param>
 public static History CreateHistory(global::System.Int32 id, global::System.Decimal amount, global::System.DateTime date)
 {
     History history = new History();
     history.Id = id;
     history.Amount = amount;
     history.Date = date;
     return history;
 }
예제 #4
0
파일: Db.cs 프로젝트: qwer/budget
        public void CreateIncomeTx(Income income, DateTime datetime)
        {
            History h = new History();

            h.AccountDest = income.Account;
            h.AccountSrc = null;
            h.Amount = income.Amount;
            h.Date = datetime;
            h.Description = "";
            h.Income = income;

            AddHistory(h);
        }
예제 #5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the HistorySet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToHistorySet(History history)
 {
     base.AddObject("HistorySet", history);
 }