private void btnEdit_Click(object sender, EventArgs e) { //if datagridview is empty, I do not allow edit item in grid if (dataGridView.CurrentRow != null) { switch (_eFrmType) { case EFrmType.employees: EmployeeModel employee = (EmployeeModel)dataGridView.CurrentRow.DataBoundItem; using (frmEmployee frmEmployee = new frmEmployee(EFrmAction.edit, employee)) { frmEmployee.ShowDialog(); RefreshGrid(); } break; case EFrmType.departments: DepartmentModel department = (DepartmentModel)dataGridView.CurrentRow.DataBoundItem; using (frmDepartment frmDepartment = new frmDepartment(EFrmAction.edit, department)) { frmDepartment.ShowDialog(); RefreshGrid(); } break; } } }
private void btnAdd_Click(object sender, EventArgs e) { switch (_eFrmType) { case EFrmType.employees: using (frmEmployee frmEmployee = new frmEmployee(EFrmAction.add, null)) { frmEmployee.ShowDialog(); RefreshGrid(); } break; case EFrmType.departments: using (frmDepartment frmDepartment = new frmDepartment(EFrmAction.add, null)) { frmDepartment.ShowDialog(); RefreshGrid(); } break; } }