private void btnSalvar_Click(object sender, EventArgs e) { try { string nome = txtNome.Text; int id = areaDeAtuacao.ContadorID(); areaDeAtuacaoNova = new AreaDeAtuacao(id, nome); areaDeAtuacao.Adicionar(areaDeAtuacaoNova); areaDeAtuacao.Salvar(); MessageBox.Show(CLRegras.Constantes.salvo, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); txtNome.Clear(); PreencherGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnRemover_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(dgvListar.CurrentRow.Cells[0].Value.ToString()); var area = areaDeAtuacao.BuscarAreaPorId(id); areaDeAtuacao.Remover(area); areaDeAtuacao.Salvar(); PreencherGrid(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }