private void BtnDelete_Click(object sender, EventArgs e) { try { DialogResult result = MessageBoxEx.Show(DataPais, "Deseja excluir registros!", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; for (int i = 0; i < DataPais.Rows.Count; i++) { if (DataPais.Rows[i].Selected) { Pais pais = paisDAO.FindByLand(DataPais.Rows[i].Cells[0].Value.ToString()); if (pais != null) { paisDAO.Delete(pais); } } } PopulaData(); this.Cursor = Cursors.Default; if (splitPais.Panel1Collapsed) { splitPais.Panel1Collapsed = false; splitPais.Panel2Collapsed = true; } MessageBoxEx.Show(DataPais, "Pais(s) excluido(s) com sucesso!", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Warning); DataPais.Focus(); } } catch (Exception ex) { this.Cursor = Cursors.Default; MessageBoxEx.Show(this, ex.Message, "Erro Paises", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void ExcluirPais(Pais pais) { dao.Delete(pais); }