コード例 #1
0
        public static ObservableCollection<EmployeeDepartmentHistory> GetEmployeeDepartmentHistory()
        {
            using (AdventureWorksContext db = new AdventureWorksContext())
            {

                List<EmployeeDepartmentHistory> query = (from h in db.EmployeeDepartmentHistories
                                                         select h).ToList();

                //foreach (EmployeeDepartmentHistory item in query)
                //{
                //    List<Department> departments = (from d in db.Departments
                //                                    where item.DepartmentID == d.DepartmentID
                //                                    select d).ToList();
                //    List<Employee> employees = (from e in db.Employees
                //                                where item.BusinessEntityID == e.BusinessEntityID
                //                                select e).ToList();
                //    List<Shift> shifts = (from s in db.Shifts
                //                          where item.ShiftID == s.ShiftID
                //                          select s).ToList();
                //    item.Department = departments.First();
                //    item.Shift = shifts.First();
                //    item.Employee = employees.First();

                //}

                return new ObservableCollection<EmployeeDepartmentHistory>(query);
            }
        }
コード例 #2
0
 public static void DeleteEmployeeDepartmentHistoryEntity(EmployeeDepartmentHistory selectedRecord)
 {
     using (AdventureWorksContext db = new AdventureWorksContext())
     {
         db.Entry(selectedRecord).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }
コード例 #3
0
        public static ObservableCollection<Shift> GetShifts(EmployeeDepartmentHistory selectedItem)
        {
            using (AdventureWorksContext db = new AdventureWorksContext())
            {
                if (selectedItem != null)
                {
                    List<Shift> query = (from s in db.Shifts
                                         where selectedItem.ShiftID == s.ShiftID
                                         select s).ToList();

                    return new ObservableCollection<Shift>(query);
                }
                else return null;
            }
        }
コード例 #4
0
        public static ObservableCollection<Employee> GetEmployees(EmployeeDepartmentHistory selectedItem)
        {
            using (AdventureWorksContext db = new AdventureWorksContext())
            {
                if (selectedItem != null)
                {
                    List<Employee> query = (from e in db.Employees
                                            where selectedItem.BusinessEntityID == e.BusinessEntityID
                                            select e).ToList();

                    return new ObservableCollection<Employee>(query);
                }
                else return null;
            }
        }
コード例 #5
0
        public static void EditEmployeeDepartmentHistoryEntity(EmployeeDepartmentHistory employeeDepartmentHistory)
        {
            using (AdventureWorksContext db = new AdventureWorksContext())
            {
                db.Entry(employeeDepartmentHistory).State = System.Data.Entity.EntityState.Modified;
                try
                {
                    db.SaveChanges();

                }
                catch (Exception e)
                {
                    db.Dispose();
                    throw new Exception("Błędne dane obiektu!!");
                }
            }
        }
コード例 #6
0
        public static void AddEmployeeDepartmentHistoryEntity(EmployeeDepartmentHistory employeeDepartmentHistory)
        {
            using (AdventureWorksContext db = new AdventureWorksContext())
            {
                db.EmployeeDepartmentHistories.Add(employeeDepartmentHistory);
                try
                {
                    db.SaveChanges();

                }
                catch (Exception e)
                {
                    db.Dispose();
                    throw new Exception("Błędne dane obiektu!!");
                }
            }
        }