async void Salvar(object sender, EventArgs e)
        {
            //recupera o objeto conta da tela
            ProfessorCadastro prof = new ProfessorCadastro()
            {
                Nome       = nomeProfessor.Text.Trim(),
                Disciplina = disciplina.Text.Trim(),
                CPF        = cpfProfessor.Text.Trim(),
            };
            //chama o service para incluir a conta via API
            ProfessorDAO service = new ProfessorDAO();


            //mostra mensagem de erro caso não foi possível incluir
            if (service.AddProfessorAsync(prof) == null)
            {
                await DisplayAlert("Erro", "Ocorreu um erro ao incluir a Conta", "Ok");
            }
            else
            {
                string mensagem = "Professor cadastrado com sucesso";
                await PopupNavigation.Instance.PushAsync(new PopPupSucesso());

                Atualizar();
            }
        }
Пример #2
0
        public async Task AddProfessorAsync(ProfessorCadastro profcadastro)
        {
            string url = "http://localhost:8085/WebServiceDiarioTom";
            //converte o objeto para uma string no formato json
            string json = JsonConvert.SerializeObject(profcadastro);
            //converte a string para um conteúdo a ser enviado
            StringContent conteudo = new StringContent(
                json, Encoding.UTF8, "application/json");

            try
            {
                HttpClient client = new HttpClient();
                //envia o conteúdo para a url informada
                HttpResponseMessage response =
                    await client.PostAsync(url + "/webresources/generic/ProfessorCadastro/inserir", conteudo);

                //se foi com sucesso
                if (!response.IsSuccessStatusCode)
                {
                    throw new Exception("Erro ao incluir produto");
                }
            }
            catch (Exception ex)
            {
                //caso ocorra algum erro.
                throw ex;
            }
        }
Пример #3
0
        public async Task <List <ProfessorCadastro> > GetProfessoresAsync()
        {
            string url = "http://localhost:8085/WebServiceDiarioTom";

            //string json = JsonConvert.SerializeObject(user);

            //converte a string para um conteúdo a ser enviado
            //StringContent conteudo = new StringContent(
            // json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.GetAsync(
                url + "/webresources/generic/listarTododProfessores");

            if (response.IsSuccessStatusCode)
            {
                var respstring = await response.Content.ReadAsStringAsync();

                ProfessorCadastro teste1 = new ProfessorCadastro();

                List <ProfessorCadastro> retorno = JsonConvert.DeserializeObject <List <ProfessorCadastro> >(respstring.ToString());
                return(retorno);
            }
            else
            {
                return(null);
            }
        }
        private async void Picker_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            var Professorprofis  = Picker.Items[Picker.SelectedIndex];
            ProfessorCadastro pc = new ProfessorCadastro();

            pc.Nome = Professorprofis;

            ProfessorCadastro t = await dataService.GetId_ProfessorAsync(pc);

            await DisplayAlert(Professorprofis, $"Foi o item Selecionado e o Id foi{t.Id_Professor} ", "OK");

            Id_Professor = t.Id_Professor;
        }
        private async void salvarCadastroProfessor_Clicked(object sender, EventArgs e)
        {
            ProfessorDAO service = new ProfessorDAO();



            Usuario t = new Usuario();

            t.Login = loginProfessor.Text.Trim();
            t.Senha = senhaProfessor.Text.Trim();
            ProfessorCadastro p = new ProfessorCadastro();

            p.CPF = cpfProfessor.Text.Trim();
            Professor pp = new Professor();

            if (await service.GetAutenticarCpfAsync(p))
            {
                //chama o service para incluir a conta via API
                datasource services = new datasource();


                //mostra mensagem de erro caso não foi possível incluir

                RetornoUsuario           oo  = new RetornoUsuario();
                int                      i   = 0;
                List <ProfessorCadastro> pc  = new List <ProfessorCadastro>();
                RetornoUsuario           pc1 = new RetornoUsuario();
                ProfessorCadastro        odk = new ProfessorCadastro();
                odk.CPF = cpfProfessor.Text.Trim();
                pc      = await service.GetCpfCadstro(odk);

                await services.AddChamadaAsync(t);

                oo.Id_Professor = pc[i].Id_Professor;

                Usuario user = new Usuario();
                user.Login = t.Login;

                user.Senha = t.Senha;
                pc1        = await services.GetProdutosAsync(user);

                oo.Id_Usuario = pc1.Id_Usuario;
                await service.AddProfessorUsuarioAsync(oo);

                await PopupNavigation.Instance.PushAsync(new PopPupSucesso());
            }
            else
            {
                await DisplayAlert("Não cadstrado", "Não castrado pela escola", "ok");
            }
        }
        protected async void Salvar(object sender, EventArgs e)
        {
            dataService = new ProfessorDAO();
            List <ProfessorCadastro> u          = new List <ProfessorCadastro>();
            List <ProfessorCadastro> professor  = new List <ProfessorCadastro>();
            List <Turma>             listaTurma = new List <Turma>();
            ProfessorCadastro        p          = new ProfessorCadastro();

            u = await dataService.GetProfessoresAsync();

            int               z            = u.Count();
            Turma             t            = new Turma();
            TurmaProfessorDao tpd          = new TurmaProfessorDao();
            ProfessorTurma    prturma      = null;
            var               checkedItems = urna.Where(x => x.IsChecked == true).ToList();

            foreach (var item in checkedItems)
            {
                int k = checkedItems.Count();
                // await DisplayAlert(bixa, "Foi o item Selecionado ", "OK");

                //chama o service para incluir a conta via API
                TurmaDao service = new TurmaDao();
                int      c       = 0;

                string bixa = item.Serie;
                t.Serie    = bixa;
                listaTurma = await servicao.GetId_TurmaAsync(t);

                item.Id_Turma = listaTurma[c].Id_Turma;
                Id_Turma      = item.Id_Turma;
                c++;
                prturma = new ProfessorTurma();
                prturma.Id_Professor = Id_Professor;
                prturma.Id_Turma     = Id_Turma;
                prturma.Serie        = bixa;

                await tpd.AddTurmaProfessorAsync(prturma);

                item.IsChecked = false;
            }
            ;



            await PopupNavigation.Instance.PushAsync(new PopPupSucesso());

            Combobox();
        }
        public async void Combobox()
        {
            dataService = new ProfessorDAO();
            List <ProfessorCadastro> u         = new List <ProfessorCadastro>();
            List <ProfessorCadastro> professor = new List <ProfessorCadastro>();
            ProfessorCadastro        p         = new ProfessorCadastro();

            u = await dataService.GetProfessoresAsync();

            int z = u.Count();

            for (int i = 0; i < z; i++)
            {
                string t = u[i].Nome.ToString();

                Picker.Items.Add(t);
            }
        }
Пример #8
0
        public async Task <bool> GetAutenticarCpfAsync(ProfessorCadastro user)
        {
            string url = "http://localhost:8085/WebServiceDiarioTom";

            //string json = JsonConvert.SerializeObject(user);

            //converte a string para um conteúdo a ser enviado
            //StringContent conteudo = new StringContent(
            // json, Encoding.UTF8, "application/json");
            HttpResponseMessage response = await client.GetAsync(
                url + "/webresources/generic/SelecionarCpfs/" + user.CPF);

            if (response.IsSuccessStatusCode)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async void ConsultarMediaLista()
        {
            List <Media> alun    = new List <Media>();
            Media        avaliar = new Media()
            {
                Id_Aluno    = TelaLoginAluno.Id_AlunoUsuarioAluno,
                Id_Bimestre = Id_BimestreNotas,
                Id_Turma    = Id_TurmaNotas,
            };



            int a        = 0;
            int finality = 0;

            alun = await servicao2.GetMediaBimestre(avaliar);

            int contar = alun.Count();

            if (alun.Count().Equals(0))
            {
                await DisplayAlert($"Turma{Turma} ", "Voce não possui nenhuma média cadastrada", "OK");

                listView.ItemsSource = null;
            }
            else
            {
                int    cont = 0;
                string DisciplinaMonstruosa         = "";
                List <RetornoUsuarioAluno> retornar = new List <RetornoUsuarioAluno>();
                RetornoUsuarioAluno        ru;
                ProfessorDAO           pd  = new ProfessorDAO();
                ProfessorCadastro      pc  = new ProfessorCadastro();
                ProfessorCadastro      pc2 = new ProfessorCadastro();
                Frequencia             f;
                Frequencia             fre   = new Frequencia();
                FrequenciaDAO          fd    = new FrequenciaDAO();
                RetornoUsuarioAluno [] teste = new RetornoUsuarioAluno[contar];
                double media = 0;
                for (int i = 0; i < contar; i++)
                {
                    finality        = alun[i].Id_Professor;
                    pc.Id_Professor = finality;
                    pc2             = await pd.GetDisciplinaAsync(pc);

                    media = alun[i].media;

                    DisciplinaMonstruosa = pc2.Disciplina;
                    f = new Frequencia()
                    {
                        falta        = "F",
                        Id_Aluno     = TelaLoginAluno.Id_AlunoUsuarioAluno,
                        Id_Bimestre  = Id_BimestreNotas,
                        Id_Turma     = Id_TurmaNotas,
                        Id_Professor = finality
                    };
                    fre = await fd.GetFrequenciaBimestreAsync(f);

                    int TotalFalta = 0;
                    if (fre.Total_Falta == 0)
                    {
                        TotalFalta = 0;
                    }
                    else
                    {
                        TotalFalta = fre.Total_Falta;
                    }

                    ru = new RetornoUsuarioAluno()
                    {
                        Disciplina = DisciplinaMonstruosa,
                        Media      = media,
                        Falta      = TotalFalta
                    };

                    retornar.Add(ru);
                }

                listView.ItemsSource = retornar;
            }
        }