private void btnAddLevel_Click(object sender, EventArgs e) { if (!LoggedInUser.IsSuperAdmin) { Base.ShowError("Access Denied", "You do not have the required permission"); return; } var levelForm = new FrmLevel(); levelForm.ShowDialog(); LoadLevel(); }
private void dataGridLevel_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 = dataGridLevel.Rows[e.RowIndex].Cells["id"].Value.ToString(); var item = _levelRepo.GetLevel(id); if (item != null) { var updateForm = new FrmLevel(item.Id); updateForm.ShowDialog(); LoadLevel(); } } //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 = dataGridLevel.Rows[e.RowIndex].Cells["id"].Value.ToString(); var response = _levelRepo.DeleteLevel(id); if (response == string.Empty) { Base.ShowInfo("Success", "Level deleted successfully"); LoadLevel(); } else { Base.ShowError("Failed", response); } } } } catch (Exception ex) { Base.ShowError("Error occured", ex.Message); } }