private void LoadStaffDetails(string id) { var staff = _staffRepo.GetStaff(id); if (staff == null) { Base.ShowError("Not found", "Staff cannot be found"); this.Close(); } else { var enrolledFingers = _bioRepo.GetStaffFingers(id).Count; lblName.Text = staff.Fullname; lblNo.Text = staff.StaffNo; lblFingersRequired.Text = _requiredFingers.ToString(); lblFingersEnrolled.Text = enrolledFingers.ToString(); btnDeleteEnrolled.Enabled = enrolledFingers > 0; } }
private void GetItem(string id) { var item = _repo.GetStaff(id); if (item == null) { Base.ShowError("Not Found", "Not Found"); this.Close(); } else { comboDept.SelectedValue = item.DepartmentId; comboTitle.SelectedValue = item.TitleId; txtSurname.Text = item.Lastname; txtFirstname.Text = item.Firstname; txtOthername.Text = item.Othername; txtStaffNo.Text = item.StaffNo; txtEmail.Text = item.Email; txtPhoneNo.Text = item.PhoneNo; checkIsAdmin.Checked = item.IsAdmin; checkIsSystemAdmin.Checked = item.IsSuperAdmin; } }
private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { // var d = (DataGridView)sender; // var df = d.SelectedCells[0].Value.ToString(); // if(df == "Edit") (df == "Delete") //edit column if (e.ColumnIndex == 0) { if (!LoggedInUser.IsSuperAdmin) { Base.ShowError("Access Denied", "You do not have the required permission"); return; } var id = dataGrid.Rows[e.RowIndex].Cells["id"].Value.ToString(); var item = _repo.GetStaff(id); if (item != null) { var updateForm = new FrmStaff(item.Id); updateForm.ShowDialog(); LoadData(); } } //delete column if (e.ColumnIndex == 1) { if (!LoggedInUser.IsSuperAdmin) { Base.ShowError("Access Denied", "You do not have the required permission"); return; } var result = Base.ShowDialog(MessageBoxButtons.YesNo, "Confirm Delete", "Are you sure you want to delete this record?"); if (result == DialogResult.Yes) { var id = dataGrid.Rows[e.RowIndex].Cells["id"].Value.ToString(); var response = _repo.DeleteStaff(id); if (response == string.Empty) { Base.ShowInfo("Success", "Staff deleted successfully"); LoadData(); } else { Base.ShowError("Failed", response); } } } //enroll fingerprint column if (e.ColumnIndex == 2) { var id = dataGrid.Rows[e.RowIndex].Cells["id"].Value.ToString(); if (LoggedInUser.IsSuperAdmin || LoggedInUser.UserId == id) { var enrollForm = new FrmEnrollFinger(id, false); enrollForm.ShowDialog(); } else { Base.ShowError("Denied", "You cannot manage fingerprints for another staff "); } } } catch (Exception ex) { Base.ShowError("Error occured", ex.Message); } }