Ejemplo n.º 1
0
        private void EmployeeForm_Activated(object sender, EventArgs e)
        {
            using (var context = new PineappleContext())
            {
                EmployeeTable.DataSource = null;
                EmployeeTable.Rows.Clear();
                EmployeeTable.Refresh();

                context.Employees.Load();
                DbSet <Employee> employees = context.Employees;
                int i = 0;
                EmployeeTable.RowCount = employees.Count();

                foreach (Employee employee in employees)
                {
                    EmployeeTable[0, i].Value = employee.Id;
                    EmployeeTable[1, i].Value = employee.Name;
                    EmployeeTable[2, i].Value = employee.Surname;
                    EmployeeTable[3, i].Value = employee.DateOfBirth.ToString("dd.MM.yyyy");
                    EmployeeTable[4, i].Value = employee.Position;
                    EmployeeTable[5, i].Value = employee.Department;
                    i++;
                }
            }
        }