Пример #1
0
 public bool EndShift() //завершение смены
 {
     using (CashboxDataContext db = new CashboxDataContext())
     {
         try
         {
             db.DBConnectionCheck();
             db.Shifts.Attach(this);
             EndDateTime = DateTime.Now;
             db.SaveChanges();
             CurrentCash   = 0;
             CashReceived  = 0;
             CashAdded     = 0;
             CashWithdrawn = 0;
             CashReturned  = 0;
             IsActive      = false;
             return(true);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
             return(false);
         }
     }
 }
Пример #2
0
 public static Shift ShiftStart(IUser <User> user) //старт смены
 {
     using (CashboxDataContext db = new CashboxDataContext())
     {
         try
         {
             db.DBConnectionCheck();
             Shift   prevShift = db.Shifts.OrderByDescending(sh => sh.SId).FirstOrDefault();
             decimal currCash  = 0;
             currCash = prevShift != null ? prevShift.CurrentCash : 0;
             Shift currShift = new Shift(user, currCash);
             db.Shifts.Add(currShift);
             db.SaveChanges();
             return(currShift);
         }
         catch (Exception e)
         {
             MessageBox.Show(e.Message);
             return(null);
         }
     }
 }