private void EditStaff(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) return; if (dgvStaff.SelectedRows.Count == Constant.CONSTANT_ZERO) return; DataGridViewRow selectedRow = dgvStaff.SelectedRows[Constant.CONSTANT_ZERO]; string staffID = selectedRow.Cells[Constant.OPERATION_INDEX_ONE].Value == null ? string.Empty : selectedRow.Cells[Constant.OPERATION_INDEX_ONE].Value.ToString(); string name = selectedRow.Cells[Constant.OPERATION_INDEX_TWO].Value == null ? string.Empty : selectedRow.Cells[Constant.OPERATION_INDEX_TWO].Value.ToString(); string gender = selectedRow.Cells[Constant.OPERATION_INDEX_THREE].Value == null ? string.Empty : selectedRow.Cells[Constant.OPERATION_INDEX_THREE].Value.ToString(); DateTime joinDate = (DateTime)selectedRow.Cells[Constant.OPERATION_INDEX_FOUR].Value; string position = selectedRow.Cells[Constant.OPERATION_INDEX_FIVE].Value == null ? string.Empty : selectedRow.Cells[Constant.OPERATION_INDEX_FIVE].Value.ToString(); string email = selectedRow.Cells[Constant.OPERATION_INDEX_SIX].Value == null ? string.Empty : selectedRow.Cells[Constant.OPERATION_INDEX_SIX].Value.ToString(); string contact = selectedRow.Cells[Constant.OPERATION_INDEX_SEVEN].Value == null ? string.Empty : selectedRow.Cells[Constant.OPERATION_INDEX_SEVEN].Value.ToString(); DateTime passwordExpireDate = (DateTime)selectedRow.Cells[Constant.OPERATION_INDEX_EIGHT].Value; DateTime birthDate = (DateTime)selectedRow.Cells[Constant.OPERATION_INDEX_NINE].Value; bool defaultPassword = (bool)selectedRow.Cells[Constant.OPERATION_INDEX_TEN].Value; bool blocked = (bool)selectedRow.Cells[Constant.OPERATION_INDEX_ELEVEN].Value; AddEditStaff frmEditStaff = new AddEditStaff(name, staffID, email, passwordExpireDate, birthDate, joinDate, gender, position, contact, defaultPassword, blocked); frmEditStaff.ShowDialog(); }
private void btnAddStaff_Click(object sender, EventArgs e) { AddEditStaff frmAddStaff = new AddEditStaff(); frmAddStaff.ShowDialog(); ColorAndSortStaff(); }