Beispiel #1
0
        private void GoLogin()
        {
            MercadoModel UsuarioLogando = new MercadoModel();

            UsuarioLogando = Service.Service.LoginMercadoService(Login.email, Login.senha);

            if (UsuarioLogando.cnpj != null)
            {
                //VARIAVEIS PROPERTIES
                App.Current.Properties["IsLoggedIn"] = Boolean.TrueString;
                App.Current.Properties["UserType"]   = "Mercado";
                App.Current.Properties["Cnpj_user"]  = UsuarioLogando.cnpj;
                Application.Current.SavePropertiesAsync();

                //SALVANDO USUARIO LOGADO NO SQLITE
                ComunicacaoBanco database = new ComunicacaoBanco();
                database.InsereUsuarioMercado(UsuarioLogando);


                //App.Current.MainPage = new PerfilMercadoView();
                //App.Current.MainPage.Navigation.PushAsync(new PerfilMercadoView());
                App.Current.MainPage = new NavigationPage(new PerfilMercadoView());
            }
            else
            {
                App.Current.MainPage.DisplayAlert("ATENCAO", "Falha Login", "OK");
            }
        }
        private async void AddNoCarrinho(Object sender, EventArgs e)
        {
            string           cpf      = App.Current.Properties["Cpf_user"].ToString();
            ComunicacaoBanco database = new ComunicacaoBanco();

            //RETORNA Nº DE PEDIDO  0 OU Nº
            pedido             = database.GetID_Pedido(cpf);
            produto.quantidade = Quantidade.Text;


            //PRIMEIRO PRODUTO DO CARRINHO, AINDA NÃO POSSUI NUM DE PEDIDO;
            if (pedido.id_pedido == "0")
            {
                //RETORNA O N° DE PEDIDO;
                pedido = Service.Service.EnviaItemParacarrinho(cpf, "0", produto);
                await App.Current.MainPage.DisplayAlert("Aviso", "Produto Adicionado", "OK");

                //SALVA Nº DE PEDIDO NO BD;
                database.SetID_Pedido(pedido);
            }
            //2° ATÉ O N° PRODUTO ENVIANDO AGORA N° DE PEDIDO;
            else
            {
                Service.Service.EnviaItemParacarrinho(cpf, pedido.id_pedido, produto);
                await App.Current.MainPage.DisplayAlert("Aviso", "Produto Adicionado", "OK");
            }
        }
Beispiel #3
0
        private void GoLogout()
        {
            App.Current.Properties["IsLoggedIn"] = Boolean.FalseString;
            string cnpj = App.Current.Properties["Cnpj_user"].ToString();

            ComunicacaoBanco conexao = new ComunicacaoBanco();

            conexao.RemoveUsuarioMercado(cnpj);
            App.Current.MainPage = new CarroselLogin();
        }
Beispiel #4
0
        private void GoLogin()
        {
            //VALIDAÇÃO: SE ALGUM CAMPO FOR NULL NOTIFICA USUARIO
            if (Login.email == null || Login.senha == null)
            {
                App.Current.MainPage.DisplayAlert("Atenção", "Preencha todos os campos", "OK");
            }
            //LOGIN
            else
            {
                //TRATAMENTO DE ERROS
                try
                {
                    UsuarioModel UsuarioLogando = new UsuarioModel();
                    UsuarioLogando = Service.Service.LoginService(Login.email, Login.senha);

                    if (UsuarioLogando != null)
                    {
                        //VARIAVEIS PROPERTIES
                        App.Current.Properties["IsLoggedIn"] = Boolean.TrueString;
                        App.Current.Properties["UserType"]   = "Cliente";
                        Application.Current.SavePropertiesAsync();
                        App.Current.Properties["Cpf_user"] = UsuarioLogando.cpf;
                        Application.Current.SavePropertiesAsync();

                        //SALVANDO USUARIO LOGADO NO SQLITE
                        ComunicacaoBanco database = new ComunicacaoBanco();
                        database.InsereUsuario(UsuarioLogando);

                        //GOTO PERFIL CLIENTE
                        //App.Current.MainPage = new PerfilCLienteMaster();
                        App.Current.MainPage = new NavigationPage(new PerfilCLienteMaster());
                    }
                    else
                    {
                        App.Current.MainPage.DisplayAlert("Atenção", "Senha ou email incorretos", "OK");
                    }
                }
                catch (Exception e)
                {
                    App.Current.MainPage.DisplayAlert("Atenção", "Limite de Conexão excedido", "OK");
                }
            }
        }
        private void Finalizarpedido()
        {
            string cpf = App.Current.Properties["Cpf_user"].ToString();

            try
            {
                Service.Service.FinalizaSacola(cpf, _cnpj, TipoPagamento, Troco);
            }
            catch
            {
                App.Current.MainPage.DisplayAlert("Atenção", "Tente Novamente", "ok");
            }


            //APOS FINALIZAR PEDIDO APAGA CACHE DO ID DO PEDIDO
            ComunicacaoBanco database = new ComunicacaoBanco();

            database.RemoveIdPedido(cpf);

            //REDIRECIONAR PARA HOME
            App.Current.MainPage.Navigation.PopToRootAsync();
        }