private void btnAddTitle_Click(object sender, EventArgs e) { if (!LoggedInUser.IsSuperAdmin) { Base.ShowError("Access Denied", "You do not have the required permission"); return; } var titleForm = new FrmTitle(); titleForm.ShowDialog(); LoadTitle(); }
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); } }