private void btnDelete_Click(object sender, EventArgs e) { grdvListEmployee.FocusedRowHandle -= 1; foreach (DataRowView _rowData in m_EmployeeMultiSelect.Selection) { m_EmployeeObject = new CEmployeeDTO(); m_EmployeeObject.maNhanVien = _rowData["MaNV"].ToString(); m_EmployeeExecute.DeleteEmployeeToDatabase(m_EmployeeObject); } m_EmployeeData = m_EmployeeExecute.getEmployeeDataFromDatabase(); grdListEmployee.DataSource = m_EmployeeData; }
private void btnDelete_Click(object sender, EventArgs e) { try { ArrayList _listEmployeeId = new ArrayList(); grdvListEmployee.FocusedRowHandle -= 1; foreach (DataRowView _rowData in m_EmployeeMultiSelect.Selection) { m_EmployeeObject = new CEmployeeDTO(); m_EmployeeObject.maNhanVien = _rowData["MaNV"].ToString(); if (m_EmployeeExecute.DeleteEmployeeToDatabase(m_EmployeeObject)) { _listEmployeeId.Add(_rowData["MaNV"]); } } if (_listEmployeeId.Count != 0) { String _erroContent = "Không thể xóa các nhân viên có mã: \n"; foreach (var item in _listEmployeeId) { _erroContent += item.ToString() + "\n"; } XtraCustomMessageBox.Show(_erroContent, "Lỗi", true); } else { XtraCustomMessageBox.Show("Xóa dữ liệu thành công!", "Thông báo", true); } } catch (System.Exception) { XtraCustomMessageBox.Show("Xóa dữ liệu thất bại", "Lỗi", true); } finally { updateEnableButtonAndResetValueOfControl(ref btnDelete); } }