private void btnExcluirProfessor_Click(object sender, EventArgs e) { DialogResult d = MessageBox.Show("Realmente deseja Excluir?", "AVISO", MessageBoxButtons.YesNo); if (d.ToString() == "Yes") { Professor professor = new Professor(); ProfessoresController professoresController = new ProfessoresController(); professor = professoresController.BuscarPorID(int.Parse(txtIDProfessor.Text)); professoresController.Excluir(professor.ProfessorID); this.LimparCampos(); MessageBox.Show("Professor excluído do sistema!", "AVISO"); } }
private void btnLocalizarProfessor_Click(object sender, EventArgs e) { frmListaProfessores f = new frmListaProfessores(); f.ShowDialog(); if (f.ID != 0) { Professor professor = new Professor(); ProfessoresController professoresController = new ProfessoresController(); professor = professoresController.BuscarPorID(f.ID); txtNomeProfessor.Text = professor.NomeProfessor; txtCPF.Text = professor.CPF.ToString(); txtIDProfessor.Text = professor.ProfessorID.ToString(); txtEmailProfessor.Text = professor.EmailProfessor.ToString(); cmbFormacao.Text = professor.Formacao.ToString(); txtFoneProfessor.Text = professor.FoneProfessor.ToString(); this.AlterarBotoes(2); } }
private void btnAlterarProfessor_Click(object sender, EventArgs e) { if (txtNomeProfessor.Text != "" && txtCPF.Text != "") { Professor professor = new Professor(); ProfessoresController professoresController = new ProfessoresController(); professor = professoresController.BuscarPorID(int.Parse(txtIDProfessor.Text)); professor.NomeProfessor = txtNomeProfessor.Text; professor.CPF = txtCPF.Text; professor.EmailProfessor = txtEmailProfessor.Text; professor.Formacao = cmbFormacao.Text; professor.FoneProfessor = txtFoneProfessor.Text; professoresController.Atualizar(professor); this.LimparCampos(); MessageBox.Show("Dados do Professor Alterados com sucesso", "AVISO"); } else { MessageBox.Show("Obrigatório digitar um nome e um CPF", "AVISO"); } }