コード例 #1
0
        private void btnCadastrarProfessor_Click(object sender, EventArgs e)
        {
            if (tbProfessor.Text != null && tbProfessor.Text != "")
            {
                Professor professor = new Professor(Convert.ToDateTime(dtNascimentoProfessor.Text), tbProfessor.Text);

                ProfessorRepositorio professorRepositorio = new ProfessorRepositorio();

                string matricula = professorRepositorio.cadastraProfessor(professor);

                if (matricula != null && matricula != "")
                {
                    if (formAreaPesquisa != null && formAreaPesquisa.listaSelecionada != null && formAreaPesquisa.listaSelecionada.Count > 0)
                    {
                        ProfessorAreaPesquisaRepositorio professorAreaPesquisaRepositorio = new ProfessorAreaPesquisaRepositorio();
                        professorAreaPesquisaRepositorio.ligaProfessorAreaPesquisa(matricula, formAreaPesquisa.listaSelecionada);
                    }

                    if (formCurso != null && formCurso.listaSelecionada != null && formCurso.listaSelecionada.Count > 0)
                    {
                        ProfessorCursoRepositorio professorCursoRepositorio = new ProfessorCursoRepositorio();
                        professorCursoRepositorio.ligaProfessorCurso(matricula, formCurso.listaSelecionada);
                    }
                }
                btnBuscarProfessor_Click(null, null);
                MessageBox.Show("Professor cadastrado com sucesso");
            }
            else
            {
                MessageBox.Show("Os dados para cadastro de um professor estão incompletos. Por favor preencha todos os campos e tente novamente.");
            }
        }
コード例 #2
0
        public async Task Carregar()
        {
            await ProfessorRepositorio.GetProfessoresSqlAzureAsync()
            .ContinueWith(retorno => { ListaProfessores = retorno.Result.ToList(); });

            AplicarFiltro();
        }
コード例 #3
0
        public ActionResult Cadastrar(ProfessorViewModel professorViewModel)
        {
            ProfessorRepositorio repositorio = new ProfessorRepositorio();

            if (repositorio.BuscarProfessor(professorViewModel.Cpf) is var retorno && retorno.EstaValido)
            {
                ModelState.AddModelError("", $"O CPF {professorViewModel.Cpf} já está cadastrado");
                return(View());
            }
コード例 #4
0
        private void btnBuscarProfessor_Click(object sender, EventArgs e)
        {
            ProfessorRepositorio professorRepositorio = new ProfessorRepositorio();
            List <Professor>     listaProfessor       = new List <Professor>();

            if (tbProfessor.Text != null && tbProfessor.Text != "")
            {
                listaProfessor = professorRepositorio.listaProfessorPorNome(tbProfessor.Text);
                montaGridProfessor(listaProfessor);
            }
        }
コード例 #5
0
 public async void Adicionar(Professor professor)
 {
     if (ValidarProfessor(professor))
     {
         if (await ProfessorRepositorio.PostProfessorSqlAzureAsync(professor))
         {
             await App.Current.MainPage.Navigation.PopAsync();
         }
         else
         {
             await App.Current.MainPage.DisplayAlert("Erro", "Erro ao adicionar professor!", "OK");
         }
     }
 }
コード例 #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (dtvProfessor != null)
            {
                DataGridViewSelectedCellCollection selectedCells = dtvProfessor.SelectedCells;

                string matricula = selectedCells[0].FormattedValue.ToString();

                ProfessorRepositorio professorRepositorio = new ProfessorRepositorio();
                if (professorRepositorio.excluiProfessor(matricula) == 1)
                {
                    MessageBox.Show("Professor excluído com sucesso!");
                    btnBuscarProfessor_Click(sender, e);
                }
            }
        }
コード例 #7
0
 public async void Remover()
 {
     if (await App.Current.MainPage.DisplayAlert("Exclusão",
                                                 string.Format("Deseja remover o professor {0}?", Selecionado.Nome), "Sim", "Não"))
     {
         if (await ProfessorRepositorio.DeleteProfessorSqlAzureAsync(Selecionado.Id.ToString()))
         {
             ListaProfessores.Remove(Selecionado);
             await Carregar();
         }
         else
         {
             await App.Current.MainPage
             .DisplayAlert("Erro", "Erro ao remover professor!", "OK");
         }
     }
 }
コード例 #8
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (dtvProfessor != null)
            {
                DataGridViewSelectedCellCollection selectedCells = dtvProfessor.SelectedCells;

                if (selectedCells.Count != 3)
                {
                    return;
                }
                string matricula = selectedCells[0].FormattedValue.ToString();

                string nome = selectedCells[1].FormattedValue.ToString();

                string dataNascimento = selectedCells[2].FormattedValue.ToString();

                Professor professor = new Professor(Convert.ToInt32(matricula), Convert.ToDateTime(dataNascimento), nome);

                if (matricula != null && matricula != "")
                {
                    if (formAreaPesquisa != null && formAreaPesquisa.listaSelecionada != null && formAreaPesquisa.listaSelecionada.Count > 0)
                    {
                        ProfessorAreaPesquisaRepositorio professorAreaPesquisaRepositorio = new ProfessorAreaPesquisaRepositorio();
                        professorAreaPesquisaRepositorio.ligaProfessorAreaPesquisa(matricula, formAreaPesquisa.listaSelecionada);
                    }

                    if (formCurso != null && formCurso.listaSelecionada != null && formCurso.listaSelecionada.Count > 0)
                    {
                        ProfessorCursoRepositorio professorCursoRepositorio = new ProfessorCursoRepositorio();
                        professorCursoRepositorio.ligaProfessorCurso(matricula, formCurso.listaSelecionada);
                    }
                }

                ProfessorRepositorio professorRepositorio = new ProfessorRepositorio();

                if (professorRepositorio.editaProfessor(professor) == 1)
                {
                    MessageBox.Show("Os dados do professor foram alterados com sucesso!");
                    tbProfessor.Text = nome;
                    btnBuscarProfessor_Click(sender, e);
                }
            }
        }
コード例 #9
0
        public ActionResult Entrar(UsuarioViewModel usuarioViewModel)
        {
            UsuarioRepositorio repositorio = new UsuarioRepositorio();
            var usuarioCadastrado          = repositorio.ValidarUsuario(usuarioViewModel.Codigo,
                                                                        Base64.ParaBase64(usuarioViewModel.Senha));

            if (usuarioCadastrado == null)
            {
                ModelState.AddModelError("", "Senha ou código(s) incorreto(s).");
                return(View("Index"));
            }
            else
            {
                //isso poderia ser validado com um container assim como aluno
                var professorUsuario = new ProfessorRepositorio().BuscarProfessorPorIdDeUsuario(usuarioCadastrado.Id);
                if (professorUsuario == null)
                {
                    var alunoUsuario = new AlunoRepositorio().BuscarAlunoPorIdDeUsuario(usuarioCadastrado.Id);
                    if (alunoUsuario == null)
                    {
                        ModelState.AddModelError("", "Erro interno. O código do usuário está cadastrado mas não existe nenhum professor ou aluno com este código.");
                        return(View("Index"));
                    }
                    else
                    {
                        alunoUsuario.Codigo = usuarioViewModel.Codigo;
                        Session["TreinamentoTurmaUsuarioAtual"] = alunoUsuario;
                        //return Content($"O email do aluno é: {alunoUsuario.Email}");
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    professorUsuario.Codigo = usuarioViewModel.Codigo;
                    Session["TreinamentoTurmaUsuarioAtual"] = professorUsuario;
                    //return Content($"O CPF do professor é: {professorUsuario.Cpf}");
                    return(RedirectToAction("Index", "Home"));
                }
            }
        }