public void DoMonthlyClosing(int branchID, int month, int year) { MonthlyClosing monthlyClosing = ctx.MonthlyClosings.SingleOrDefault( closing => closing.BranchID == branchID && closing.ClosingMonth == month && closing.ClosingYear == year); if (monthlyClosing == null) { monthlyClosing = new MonthlyClosing(); monthlyClosing.BranchID = branchID; monthlyClosing.ClosingMonth = month; monthlyClosing.ClosingYear = year; monthlyClosing.IsClosed = true; EntityHelper.SetAuditFieldForInsert(monthlyClosing, HttpContext.Current.User.Identity.Name); ctx.MonthlyClosings.InsertOnSubmit(monthlyClosing); } else { monthlyClosing.IsClosed = true; EntityHelper.SetAuditFieldForUpdate(monthlyClosing, HttpContext.Current.User.Identity.Name); } MonthlyClosingHistory closingHist = new MonthlyClosingHistory(); closingHist.BranchID = branchID; closingHist.IsClosing = true; closingHist.UserName = HttpContext.Current.User.Identity.Name; closingHist.CreatedWhen = DateTime.Now; ctx.SubmitChanges(); }
public void UndoMonthlyClosing(int branchID, int month, int year, string reason) { MonthlyClosing monthlyClosing = ctx.MonthlyClosings.SingleOrDefault( closing => closing.BranchID == branchID && closing.ClosingMonth == month && closing.ClosingYear == year); if (monthlyClosing != null) { monthlyClosing.IsClosed = false; EntityHelper.SetAuditFieldForInsert(monthlyClosing, HttpContext.Current.User.Identity.Name); } MonthlyClosingHistory closingHist = new MonthlyClosingHistory(); closingHist.BranchID = branchID; closingHist.IsClosing = false; closingHist.Notes = reason; closingHist.UserName = HttpContext.Current.User.Identity.Name; closingHist.CreatedWhen = DateTime.Now; ctx.SubmitChanges(); }