private void dataGridTitle_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (!LoggedInUser.IsSuperAdmin) { Base.ShowError("Access Denied", "You do not have the required permission"); return; } //edit column if (e.ColumnIndex == 0) { var id = dataGridTitle.Rows[e.RowIndex].Cells["id"].Value.ToString(); var item = _titleRepo.GetTitle(id); if (item != null) { var updateForm = new FrmTitle(item.Id); updateForm.ShowDialog(); LoadTitle(); } } //delete column if (e.ColumnIndex == 1) { var result = Base.ShowDialog(MessageBoxButtons.YesNo, "Confirm Delete", "Are you sure you want to delete this record?"); if (result == DialogResult.Yes) { var id = dataGridTitle.Rows[e.RowIndex].Cells["id"].Value.ToString(); var response = _titleRepo.DeleteTitle(id); if (response == string.Empty) { Base.ShowInfo("Success", "Title deleted successfully"); LoadTitle(); } else { Base.ShowError("Failed", response); } } } } catch (Exception ex) { Base.ShowError("Error occured", ex.Message); } }
private void GetItem(string id) { var item = _repo.GetTitle(id); if (item == null) { Base.ShowError("Not Found", "Not Found"); this.Close(); } else { txtTitle.Text = item.Title; } }