private void btnAdicionar_Click(object sender, RoutedEventArgs e) { //if (cboNiveis.SelectedValue ?? null && cboAlunos.SelectedValue ?? null) //{ //int idmentor = (int)cboNiveis.SelectedValue; //int iddisciplina = (int)cboAlunos.SelectedValue; //MessageBox.Show($"ID mentor: {id} - ID disciplina: {iddisc}"); historicoaluno = new HistoricoAluno(); Nivel n = new Nivel(); Aluno a = new Aluno(); //colocar throw exception aqui para quando nao vir informado dados na combobox n.Id = (int)cboNiveis.SelectedValue; a.Id = (int)cboAlunos.SelectedValue; n = NivelDAO.BuscarNivelPorId(n.Id); if (n != null) { historicoaluno.Nivel = n; a = AlunoDAO.BuscarAlunoPorId(a.Id); if (a != null) { historicoaluno.Aluno = a; if (HistoricoAlunoDAO.Cadastrar(historicoaluno)) { MessageBox.Show("Atrelamento realizado com sucesso!", "Matricula WPF", MessageBoxButton.OK, MessageBoxImage.Information); LimparFormulario(); } else { MessageBox.Show("Atrelamento já existente!", "Matricula WPF", MessageBoxButton.OK, MessageBoxImage.Information); LimparFormulario(); } } else { MessageBox.Show("Aluno não localizado", "Matricula WPF", MessageBoxButton.OK, MessageBoxImage.Information); LimparFormulario(); } } else { MessageBox.Show("Nivel não localizado!", "Matricula WPF", MessageBoxButton.OK, MessageBoxImage.Information); LimparFormulario(); } }
public HistoricoAlunoController(HistoricoAlunoDAO historicoalunoDAO) => _historicoalunoDAO = historicoalunoDAO;