예제 #1
0
 public Employee GetEmployeeByEmployeeID(int EmpID)
 {
     using (companyEntities db = new companyEntities())
     {
         Employee emp = db.Employees.Where(e => e.EmpID == EmpID).FirstOrDefault();
         return(emp);
     }
 }
예제 #2
0
 public List <Employee> GetEmployees()
 {
     using (companyEntities db = new companyEntities())
     {
         List <Employee> emps = db.Employees.ToList();
         return(emps);
     }
 }
예제 #3
0
        public (bool, Guid) InsertEmployee(Employee emp)
        {
            using (companyEntities db = new companyEntities())
            {
                emp.EmpID = Guid.NewGuid();
                //db.Employees.Add(emp);
                //db.SaveChanges();
                int n = db.InsertEmployee(emp.EmpID, emp.EmpName, emp.Salary);
            }

            return(true, emp.EmpID);
        }
예제 #4
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);
                }
            }
        }
예제 #5
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);
                }
            }
        }