예제 #1
0
        public bool DeleteEmployee(Employee emp)
        {
            using (companyEntities db = new companyEntities())
            {
                Employee existingEmployee = db.Employees.Where(temp => temp.EmpID == emp.EmpID).FirstOrDefault();

                if (existingEmployee == null)
                {
                    return(false);
                }
                else
                {
                    db.Employees.Remove(existingEmployee);
                    db.SaveChanges();
                    return(true);
                }
            }
        }
예제 #2
0
        public bool UpdateEmployee(Employee emp)
        {
            using (companyEntities db = new companyEntities())
            {
                Employee existingEmployee = db.Employees.Where(temp => temp.EmpID == emp.EmpID).FirstOrDefault();

                if (existingEmployee == null)
                {
                    return(false);
                }
                else
                {
                    existingEmployee.EmpName = emp.EmpName;
                    existingEmployee.Salary  = emp.Salary;
                    db.SaveChanges();
                    return(true);
                }
            }
        }