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); }
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); }
/// <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; }
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); }
/// <summary> /// Deprecated Method for adding a new object to the HistorySet EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToHistorySet(History history) { base.AddObject("HistorySet", history); }