Example #1
0
 public static void ChangeDepartment(int departmentId, string name)
 {
     using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
     {
         if (db.Departments.Find(departmentId) != null)
         {
             db.Departments.Find(departmentId).Name = name;
             db.SaveChanges();
         }
     }
 }
 public static void ChangeDepartment(int id, int departmentId)
 {
     using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
     {
         if (db.Employees.Find(id) != null)
         {
             db.Employees.Find(id).Department = db.Departments.Find(departmentId);
             db.SaveChanges();
         }
     }
 }
 public static void ChangePosition(int id, int positionId)
 {
     using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
     {
         if (db.Employees.Find(id) != null)
         {
             db.Employees.Find(id).Position = db.Positions.Find(positionId);
             db.SaveChanges();
         }
     }
 }
 public static void ChangeAccountNumber(int id, int accountNummber)
 {
     using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
     {
         if (db.Employees.Find(id) != null)
         {
             db.Employees.Find(id).AccountNumber = accountNummber;
             db.SaveChanges();
         }
     }
 }
 public static void ChangeExperience(int id, int experience)
 {
     using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
     {
         if (db.Employees.Find(id) != null)
         {
             db.Employees.Find(id).Experience = experience;
             db.SaveChanges();
         }
     }
 }
 public static void ChangeSurname(int id, string surname)
 {
     using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
     {
         if (db.Employees.Find(id) != null)
         {
             db.Employees.Find(id).Surname = surname;
             db.SaveChanges();
         }
     }
 }
Example #7
0
        public static void AddDepartment(string name)
        {
            using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
            {
                Department department = new Department {
                    Name = name
                };

                db.Departments.Add(department);
                db.SaveChanges();
            }
        }
Example #8
0
        public static void AddPosition(string name, double hours, double payment)
        {
            using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
            {
                Position position = new Position {
                    Name = name, Hours = hours, Payment = payment
                };

                db.Positions.Add(position);
                db.SaveChanges();
            }
        }
Example #9
0
        public static void AddProject(string name, int price, int employeeId)
        {
            using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
            {
                Project project = new Project
                {
                    Name     = name,
                    Price    = price,
                    Employee = db.Employees.Find(employeeId)
                };

                db.Projects.Add(project);
                db.SaveChanges();
            }
        }
Example #10
0
        public static bool DeleteDepartments(int departmentId)
        {
            bool flag = false;

            using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
            {
                if (db.Departments.Find(departmentId) != null)
                {
                    db.Departments.Remove(db.Departments.Find(departmentId));
                    db.SaveChanges();

                    flag = true;
                }
            }
            return(flag);
        }
        public static void AddEmployee(string name, string surname, int accountnumber,
                                       int experience, int idDepartment, int idPosition)
        {
            using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
            {
                Employee employee = new Employee
                {
                    Name          = name,
                    Surname       = surname,
                    AccountNumber = accountnumber,
                    Experience    = experience,
                    Department    = db.Departments.Find(idDepartment),
                    Position      = db.Positions.Find(idPosition)
                };

                db.Employees.Add(employee);
                db.SaveChanges();
            }
        }
        public static bool DeleteEmployee(int id)
        {
            bool flag = false;

            using (HumanResourcesDepartmentContext db = new HumanResourcesDepartmentContext())
            {
                if (db.Employees.Find(id) != null)
                {
                    foreach (var item in db.Employees.Find(id).Projects)
                    {
                        item.Employee = null;
                    }
                    db.Employees.Remove(db.Employees.Find(id));
                    db.SaveChanges();

                    flag = true;
                }
            }
            return(flag);
        }