public static void AddNewTask(Task task, Employee em, frmListTask frmListTask)
        {
            using (var _context = new DBLabManagementEntities())
            {
                var Ids = (from t in _context.Tasks select t.IDTask).ToList();
                for (int i = 1; i <= _context.Tasks.Count() + 1; i++)
                {
                    if (!Ids.Contains(i))
                    {
                        task.IDTask = i;
                        break;
                    }
                }

                var employee = _context.Employees.FirstOrDefault(x => x.IDEmployee == em.IDEmployee);
                if (employee == null)
                {
                    return;
                }
                employee.Tasks.Add(task);
                _context.Employees.AddOrUpdate(employee);
                _context.Tasks.Add(task);
                _context.SaveChanges();
                AddTask(task, frmListTask);
            }
        }
Exemple #2
0
 public static void AddorUpdate(Employee employee)
 {
     using (var _context = new DBLabManagementEntities())
     {
         bool isAdd = false;
         if (SelectID == -1)
         {
             isAdd = true;
             var Ids = (from e in _context.Employees select e.IDEmployee).ToList();
             for (int i = 1; i <= _context.Employees.Count() + 1; i++)
             {
                 if (!Ids.Contains(i))
                 {
                     employee.IDEmployee = i;
                     break;
                 }
             }
         }
         else
         {
             if (urcEmployee != null)
             {
                 urcEmployee.Employee = employee;
             }
         }
         _context.Employees.AddOrUpdate(employee);
         _context.SaveChanges();
         if (isAdd)
         {
             frmEmployees.AddEmployee(employee.IDEmployee);
         }
     }
 }
Exemple #3
0
 public static void UpdateWorkTime(TimeWork timeWork)
 {
     using (var _context = new DBLabManagementEntities())
     {
         _context.TimeWorks.AddOrUpdate(timeWork);
         _context.SaveChanges();
     }
 }
 public static void AddOrUpdateTask(Task task)
 {
     using (var _context = new DBLabManagementEntities())
     {
         _context.Tasks.AddOrUpdate(task);
         _context.SaveChanges();
     }
 }
Exemple #5
0
 public static void Delete(TimeWork timeWork)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var dele = _context.TimeWorks.FirstOrDefault(x => x.IDTimeWork == timeWork.IDTimeWork);
         _context.TimeWorks.Remove(dele);
         _context.SaveChanges();
     }
 }
Exemple #6
0
 public static bool DeleteSalary(Salary salary)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var dbSalary = (from u in _context.Salaries
                         where u.IDEmployee == salary.IDEmployee && u.Month == salary.Month
                         select u).SingleOrDefault();
         _context.Salaries.Remove(dbSalary);
         _context.SaveChanges();
         return(true);
     }
 }
 public static void Update(Project project, frmListProjects frm, urcProject urc)
 {
     using (var _context = new DBLabManagementEntities())
     {
         _context.Projects.AddOrUpdate(project);
         _context.SaveChanges();
         if (urc != null)
         {
             urc.Dispose();
         }
         AddurcProject(project, frm);
     }
 }
Exemple #8
0
 public static void Delete()
 {
     using (var _context = new DBLabManagementEntities())
     {
         var EmployeeDelete = _context.Employees.FirstOrDefault(x => x.IDEmployee == SelectID);
         if (EmployeeDelete != null)
         {
             _context.Employees.Remove(EmployeeDelete);
             _context.SaveChanges();
             urcEmployee.Dispose();
         }
     }
 }
        public static void Delete(Project project)
        {
            using (var _context = new DBLabManagementEntities())
            {
                var del = _context.Projects.FirstOrDefault(x => x.IDProject == project.IDProject);
                foreach (var task in ListTask(del))
                {
                    TaskController.Delete(task);
                }

                _context.Projects.Remove(del);
                _context.SaveChanges();
            }
        }
 public static void AddNewLab(Lab lab, Employee employee)
 {
     using (var _context = new DBLabManagementEntities())
     {
         lab.IDLab           = _context.Labs.Count();
         employee.IDEmployee = _context.Employees.Count();
         lab.IDMangager      = employee.IDEmployee;
         employee.IDLAB      = lab.IDLab;
         employee.Lab        = lab;
         lab.Employees.Add(employee);
         _context.Labs.Add(lab);
         _context.Employees.Add(employee);
         _context.SaveChanges();
     }
 }
Exemple #11
0
 public static bool UpdateSalary(Salary salary)
 {
     try
     {
         using (var _context = new DBLabManagementEntities())
         {
             _context.Salaries.AddOrUpdate(salary);
             _context.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
 public static void Delete(Task t)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var task = _context.Tasks.FirstOrDefault(x => x.IDTask == t.IDTask);
         foreach (var employee in task.Employees)
         {
             var e = _context.Employees.FirstOrDefault(x => x.IDEmployee == employee.IDEmployee);
             if (e != null)
             {
                 e.Tasks.Remove(task);
             }
         }
         _context.Tasks.Remove(task);
         _context.SaveChanges();
     }
 }
 public static void AddOrUpdateTask(Task task, frmInfoProject frmInfoProject, urcTask urcTask)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var t = _context.Tasks.FirstOrDefault(x => x.IDTask == task.IDTask);
         t.Employees.Clear();
         _context.Tasks.AddOrUpdate(t);
         foreach (var em in task.Employees)
         {
             var employee = _context.Employees.FirstOrDefault(x => x.IDEmployee == em.IDEmployee);
             employee.Tasks.Add(t);
         }
         _context.Tasks.AddOrUpdate(task);
         _context.SaveChanges();
         urcTask.Dispose();
         frmInfoProject.AddTask(task);
     }
 }
 public static void AddNewTask(Task task, frmInfoProject frmInfoProject)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var Ids = (from t in _context.Tasks select t.IDTask).ToList();
         for (int i = 1; i <= _context.Tasks.Count() + 1; i++)
         {
             if (!Ids.Contains(i))
             {
                 task.IDTask = i;
                 break;
             }
         }
         _context.Tasks.Add(task);
         _context.SaveChanges();
         frmInfoProject.AddTask(task);
     }
 }
Exemple #15
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);
     }
 }
 public static void Add(Project project, frmListProjects frm)
 {
     using (var _context = new DBLabManagementEntities())
     {
         var Ids = (from t in _context.Projects select t.IDProject).ToList();
         for (int i = 1; i <= _context.Projects.Count() + 1; i++)
         {
             if (!Ids.Contains(i))
             {
                 project.IDProject = i;
                 break;
             }
         }
         project.IDLab = mainController.Lab.IDLab;
         _context.Projects.Add(project);
         _context.SaveChanges();
         _project = _context.Projects.FirstOrDefault(x => x.IDProject == project.IDProject);
         AddurcProject(project, frm);
     }
 }