private void dgvStudents_CellClick(object sender, DataGridViewCellEventArgs e) { int columnIndex = e.ColumnIndex; int rowIndex = e.RowIndex; DataGridViewRow row = dgvStudents.Rows[rowIndex]; int studentID = Convert.ToInt32(row.Cells["colID"].Value.ToString()); Student student = students.FirstOrDefault(s => s.ID == studentID); switch (columnIndex) { case 5: StudentUpdate updateView = new StudentUpdate(_studentViewModel, student); updateView.ShowDialog(); if (updateView.Success) { LoadData(); } break; case 6: StudentDelete deleteView = new StudentDelete(_studentViewModel, student); deleteView.ShowDialog(); if (deleteView.Success) { LoadData(); } break; default: break; } }
// Delete studen public static StudentDelete.Response Handle(IRepository repository, StudentDelete.Request request) { var container = StudentFactory .CreatePartial(request.CommandModel.StudentId) .Delete(); var validationDetails = repository.Save(container); return new StudentDelete.Response(validationDetails); }
public void Delete(int id) { IStudentDelete studentDelete = new StudentDelete(conn); studentDelete.Delete(id); }