private void button1_Click(object sender, EventArgs e) { try { CarregaAluno(aluno); switch (tranzacao) { case Tranz.Alterar: alunoDAO.AtualizarAluno(aluno); MessageBox.Show("alterado com Sucesso"); break; case Tranz.Cadastrar: string msg = alunoDAO.InserirNovoAluno(aluno); tranzacao = Tranz.Alterar; MessageBox.Show(msg == "" ? "cadastrado com sucesso" : msg); txtCA.Text = aluno.id_aluno.ToString(); aluno.filhos++; break; } } catch (Exception erro) { MessageBox.Show(erro.Message); } }
//================================== public frmAluno(Tranz tra) { aluno = new AlunoEnt(); alunoDAO = new AlunosDAO(); tranzacao = tra; InitializeComponent(); }
public frmAluno(AlunoEnt al, Tranz tra) { alunoDAO = new AlunosDAO(); InitializeComponent(); tranzacao = tra; aluno = al; CarregaControles(aluno); if (tra == Tranz.Cadastrar) { cb.SelectedIndex = 0; cbIntegral.SelectedIndex = 0; } else if (tra == Tranz.Alterar) { cb.SelectedIndex = (int)Enum.Parse(typeof(Sexo), aluno.sexo); cbIntegral.SelectedIndex = (int)Enum.Parse(typeof(Integral), aluno.integral); } }