Пример #1
0
        private async void BtnRedefinir(object sender, EventArgs e)
        {
            try{
                List <Models.Cadastro> cadastros = await ds.GetCadastroAsync(); //Lista com todos os cadastros

                string result;                                                  //Mensagem a ser exibida
                //Recebe os dados
                string senha     = txtSenha.Text.Trim();
                string confsenha = txtConfirmarSenha.Text.Trim();

                result = controller.RedefinirSenha(login, senha, confsenha, cadastros);

                var msg = System.Text.RegularExpressions.Regex.Split(result, ";"); //Faz a separação da mensagem em 3 strings

                if (!msg[0].Equals("Erro"))
                {
                    await Navigation.PushAsync(new MainPage());

                    Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
                }
                await DisplayAlert(msg[0], msg[1], msg[2]);
            }
            catch (Exception ex)
            {
                await DisplayAlert("Erro:", "Campos vazios", "OK");
            }
        }
Пример #2
0
        private async void SetCadastros(string login)
        {
            cadastros = await ds.GetCadastroAsync();

            cadastro = controller.GetCadastro(login, cadastros);
            InitializeComponent();
        }
Пример #3
0
        private async void BtnFinalizarCadastro_ClickedAsync(object sender, EventArgs e)
        {
            try
            {
                List <Models.Cadastro> cadastros = await ds.GetCadastroAsync(); //Lista com todos os cadastros

                try
                {
                    string result; //Mensagem a ser exibida

                    //Recebe informações
                    Models.Cadastro cadastro = new Models.Cadastro
                    {
                        login = txtCadLogin.Text.Trim(),
                        senha = txtCadSenha.Text.Trim(),
                        nome  = txtCadNome.Text.Trim(),
                        email = txtCadEmail.Text.Trim(),
                        cpf   = txtCadCpf.Text.Trim()
                    };
                    string confsenha = txtConfSenha.Text.Trim();

                    result = controller.Cadastro(cadastro, confsenha, cadastros);

                    var msg = System.Text.RegularExpressions.Regex.Split(result, ";"); //Faz a separação da mensagem em 3 strings
                    await DisplayAlert(msg[0], msg[1], msg[2]);

                    if (msg[0].Equals("Sucesso"))
                    {
                        await ds.AddCadastroAsync(cadastro);

                        //Adiciona os lembretes padrão ao criar um novo perfil
                        LembreteController lc = new LembreteController();
                        lc.CriarLembretes(cadastro);

                        Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 1]);
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Erro:", "Preencha todos os campos", "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Erro:", "Sem conexão com a internet", "OK");
            }
        }
Пример #4
0
        private async void BtnLogin_ClickedAsync(object sender, EventArgs e)
        {
            try
            {
                List <Models.Cadastro> cadastros = await ds.GetCadastroAsync(); //Lista com todos os cadastros

                try
                {
                    string result; //Mensagem a ser exibida
                                   //Recebe os dados
                    string login = txtUsuario.Text.Trim();
                    string senha = txtSenha.Text.Trim();

                    result = controller.Login(login, senha, cadastros);

                    var msg = System.Text.RegularExpressions.Regex.Split(result, ";"); //Faz a separação da mensagem em 3 strings
                    if (!msg[0].Equals("Erro"))
                    {
                        LembreteDataService ds = new LembreteDataService();
                        //Carrega todos os lembretes
                        List <Models.Lembrete> lembretes = await ds.GetLembreteAsync();

                        LembreteController lc = new LembreteController();
                        //Retorna um lembrete aleatório, se houver
                        string lembrete = lc.GetLembrete(login, lembretes);

                        await Navigation.PushAsync(new Inicial(login));

                        Limpar();
                        await DisplayAlert(msg[0], lembrete, msg[2]); //Exibe um lembrete aleatório ao usuário, além da mensagem padrão
                    }
                    else
                    {
                        await DisplayAlert(msg[0], msg[1], msg[2]);
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Erro:", "Preencha todos os campos", "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Erro:", "Sem conexão com a internet", "OK");
            }
        }
Пример #5
0
        private async void BtnConfirmar(object sender, EventArgs e)
        {
            try
            {
                List <Models.Cadastro> cadastros = await ds.GetCadastroAsync(); //Lista com todos os cadastros

                try
                {
                    string result; //Mensagem a ser exibida através do controller
                                   //Recebe os dados
                    string email = txtEmail.Text.Trim();
                    string cpf   = txtCpf.Text.Trim();

                    result = controller.RecuperarLogin(email, cpf, cadastros);

                    var msg = System.Text.RegularExpressions.Regex.Split(result, ";"); //Faz a separação da mensagem em 3 strings
                    if (!msg[0].Equals("Erro"))
                    {
                        string login = msg[0].Trim();
                        await Navigation.PushAsync(new RedefinirSenha(login));

                        Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
                    }
                    else
                    {
                        await DisplayAlert(msg[0], msg[1], msg[2]);
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Erro:", "Campos vazios", "OK");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Erro:", "Sem conexão com a internet", "OK");
            }
        }