private void btnCadastrar_Click(object sender, RoutedEventArgs e) { Professor busca = new Professor(); busca.matricula = Convert.ToInt32(cboProfessor.SelectedValue); List <Aluno> alunosaqui = new List <Aluno>(); Turma turma = new Turma(); if (!string.IsNullOrWhiteSpace(txtNome.Text)) { //para cada aluno selecionado foreach (Aluno a in lbxAlunos.SelectedItems) { alunosaqui.Add(a); } turma.Nome_turma = txtNome.Text; turma.professor = ProfessorDAO.BuscarProfessorPorMatricula(busca); turma.alunos = alunosaqui; if (TurmaDAO.AdicionarTurma(turma) == true) { MessageBox.Show("Turma Gravada com Sucesso!"); this.Close(); } else { MessageBox.Show("Erro ao cadastrar turma!"); } } else { MessageBox.Show("Favor preencher todos os campos!!"); } }
private void btnDeletar_Click(object sender, RoutedEventArgs e) { Professor professore = new Professor(); professore.matricula = Convert.ToInt32(txtPesquisar.Text); var professor = ProfessorDAO.BuscarProfessorPorMatricula(professore); if (ProfessorDAO.DeletarProfessor(professor)) { MessageBox.Show("Professor deletado com sucesso!!"); } else { MessageBox.Show("Erro ao deletar professor!!"); } }
private void btnBuscar_Click(object sender, RoutedEventArgs e) { Professor professor = new Professor(); professor.matricula = Convert.ToInt32(txtPesquisar.Text); var professorE = ProfessorDAO.BuscarProfessorPorMatricula(professor); if (professorE != null) { txtDisci.Text = professorE.disciplina; txtNome.Text = professorE.nome; } else { MessageBox.Show("Professor não encontrado!!"); } }