示例#1
0
 public void UpdateEmployee(Employee emp)
 {
     using (Model.Entity en = new Model.Entity()) {
         if (emp.GetType() == typeof(Shared.Entities.FullTimeEmployee))
         {
             Model.FullTimeEmployee e  = (Model.FullTimeEmployee)en.Employees.Find(emp.Id);
             FullTimeEmployee       em = (FullTimeEmployee)emp;
             e.EmployeeId = em.Id;
             e.Name       = em.Name;
             e.StartDate  = em.StartDate;
             e.Salary     = em.Salary;
             en.SaveChanges();
         }
         else
         {
             Model.PartTimeEmployee e  = (Model.PartTimeEmployee)en.Employees.Find(emp.Id);
             PartTimeEmployee       em = (PartTimeEmployee)emp;
             e.EmployeeId = em.Id;
             e.Name       = em.Name;
             e.StartDate  = em.StartDate;
             e.HourlyRate = em.HourlyRate;
             en.SaveChanges();
         }
     }
 }
示例#2
0
 public void DeleteEmployee(int id)
 {
     using (Model.Entity en = new Model.Entity())
     {
         en.Employees.Remove(en.Employees.Find(id));
         en.SaveChanges();
     }
 }