private void btnAlterar_Click(object sender, EventArgs e) { try { AlunosDao alunoBD = new AlunosDao(); Alunos alunoReg = new Alunos(int.Parse(txtID.Text), txtNome.Text, txtEndereco.Text, int.Parse(txtIdade.Text), txtcaminho.Text.Replace(@"\", @"\\")); //replace substitui \ por \\ para salvar alunoBD.AlterarAluno(alunoReg); MessageBox.Show("Registro alterado com sucesso."); btnExibir.PerformClick();//botãoexibir } catch (Exception c) { MessageBox.Show(c.ToString()); } }
private void btnExcluir_Click(object sender, EventArgs e) { try { AlunosDao alunoBD = new AlunosDao(); //exclui pelo ID no banco Alunos alunoReg = new Alunos(int.Parse(txtID.Text)); alunoBD.ExcluirAluno(alunoReg); MessageBox.Show("Registro excluído com sucesso."); btnAlterar.PerformClick(); } catch (Exception c) { MessageBox.Show(c.ToString()); } }
private void button1_Click(object sender, EventArgs e) {//botão salvar if (txtNome.Text.Equals("")) { MessageBox.Show("Informe o nome do aluno."); return; } try { AlunosDao alunoBD = new AlunosDao(); Alunos alunoReg = new Alunos(txtNome.Text, txtEndereco.Text, int.Parse(txtIdade.Text), txtcaminho.Text); alunoBD.IncluirAluno(alunoReg);//chamada do método MessageBox.Show("Registro salvo com sucesso."); } catch (Exception c) { MessageBox.Show(c.ToString()); } }