private void btnDelete_Click(object sender, EventArgs e) { try { DialogResult sure; sure = MessageBox.Show("¿Estas seguro que desea anular los registros?", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (sure == DialogResult.OK) { string IdItem; string res = ""; foreach (DataGridViewRow row in dataList.Rows) { if (Convert.ToBoolean(row.Cells[0].Value)) { IdItem = Convert.ToString(row.Cells[1].Value); res = EntryController.Cancel(Convert.ToInt32(IdItem)); if (res.Equals("Correcto")) { this.MessageOK("¡Se ha anulado el registro correctamente!"); } else { this.MessageError(res); } } } this.ShowData(); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }