Пример #1
0
 private void AddEmployee_Click(object sender, EventArgs e)
 {
     try
     {
         using (dbContext db = new dbContext())
         {
             Empoyee emp = new Empoyee
             {
                 FirstName    = employeeName.Text,
                 SurName      = employeeSureName.Text,
                 Patronymic   = employeePatronomyc.Text,
                 DocNumber    = employeeDocNumber.Text,
                 DocSeries    = employeeDocSeries.Text,
                 DateOfBirth  = employeeDoB.Value,
                 Position     = employeePosition.Text,
                 DepartmentID = (employeeDepartment.SelectedItem as Department).ID,
             };
             db.Empoyee.Add(emp);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
 public EmployeeAdapter(Empoyee empoyee)
 {
     ID          = empoyee.ID;
     FirstName   = empoyee.FirstName;
     SurName     = empoyee.SurName;
     Patronymic  = empoyee.Patronymic;
     DateOfBirth = empoyee.DateOfBirth;
     Age         = DateTime.Now.Year - DateOfBirth.Year;
     if (DateOfBirth > DateTime.Now.AddYears(-Age))
     {
         Age--;
     }
     DocSeries    = empoyee.DocSeries;
     DocNumber    = empoyee.DocNumber;
     Position     = empoyee.Position;
     DepartmentID = empoyee.DepartmentID;
     Department   = empoyee.Department;
 }