Exemplo n.º 1
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (grvDados.RowCount > 0)
     {
         try
         {
             contatosRepository = new ContatosRepository();
             Contatos model = contatosRepository.RetornarPorId(Convert.ToInt32(grvDados.CurrentRow.Cells[0].Value));
             contatosRepository.Excluir(model);
             CarregarRegistros();
             MessageBox.Show("Registro excluído com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception ex)
         {
             MessageBox.Show("Erro ao excluir contato: " + ex.Message, "Excluir", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }