예제 #1
0
        private void EmployeeAddForm_Load(object sender, EventArgs e)
        {
            positionComboBox.DataSource = null;
            positionComboBox.Items.Clear();

            departmentComboBox.DataSource = null;
            departmentComboBox.Items.Clear();

            using (var context = new PineappleContext())
            {
                context.Positions.Load();
                context.Departments.Load();
                DbSet <Position>   positions   = context.Positions;
                DbSet <Department> departments = context.Departments;

                foreach (Position position in positions)
                {
                    positionComboBox.Items.Add(position.Name);
                }
                foreach (Department department in departments)
                {
                    departmentComboBox.Items.Add(department.Name);
                }
            }
        }
예제 #2
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++;
                }
            }
        }
예제 #3
0
 private void EmployeeTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     using (var context = new PineappleContext())
     {
         EditEmployeeForm editClientForm = new EditEmployeeForm(Convert.ToInt32(EmployeeTable.SelectedRows[0].Cells[0].Value));
         editClientForm.ShowDialog();
     }
 }
예제 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (var context = new PineappleContext())
            {
                context.Employees.Load();
                var newEmployee = new Employee();

                newEmployee.Name        = nameTextBox.Text;
                newEmployee.Surname     = surnameTextBox.Text;
                newEmployee.DateOfBirth = birthDayDateTimePicker.Value;
                newEmployee.Position    = positionComboBox.Text;
                newEmployee.Department  = departmentComboBox.Text;
                context.Employees.Add(newEmployee);
                context.SaveChanges();

                Close();
            }
        }