private void buttonAddEmp_Click(object sender, EventArgs e) { Data.employee = null; Data.departmentsList = departmentController.GetDepartments(); EmployeeForm empForm = new EmployeeForm(); if (empForm.ShowDialog() == DialogResult.OK) { employeeController.Create(Data.employee); UpdateDataGrid(Data.employee.DepartmentID); } Data.employee = null; }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { var emp = (Employee)dataGridView1.CurrentRow.DataBoundItem; Data.employee = emp; Data.departmentsList = departmentController.GetDepartments(); EmployeeForm empForm = new EmployeeForm(); if (empForm.ShowDialog() == DialogResult.OK) { if (Data.employee.FirstName != null) { employeeController.Update(Data.employee); } else { employeeController.Delete(Data.employee.ID); } } UpdateDataGrid(emp.DepartmentID); Data.employee = null; }