Example #1
0
 public static void LoadListTime(frmSetTime frmSetTime)
 {
     using (var _context = new DBLabManagementEntities())
     {
         foreach (var time in _context.TimeWorks.Where(x => x.IDEmployee == frmSetTime.Employee.IDEmployee).OrderBy(x => x.StartDate))
         {
             if (time.StartDate.Value.Date == frmSetTime.Day.Date)
             {
                 frmSetTime.AddTime(time);
             }
         }
     }
 }
Example #2
0
 public static void AddWorkTime(Employee employee, TimeWork timeWork, frmSetTime frmSetTime)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var Ids = (from t in _context.TimeWorks select t.IDTimeWork).ToList();
         for (int i = 1; i <= _context.TimeWorks.Count() + 1; i++)
         {
             if (!Ids.Contains(i))
             {
                 timeWork.IDTimeWork = i;
                 break;
             }
         }
         var em = _context.Employees.FirstOrDefault(x => x.IDEmployee == employee.IDEmployee);
         em.TimeWorks.Add(timeWork);
         _context.TimeWorks.Add(timeWork);
         _context.SaveChanges();
         frmSetTime.AddTime(timeWork);
     }
 }