private async void BtnSalvar_Clicked(object sender, EventArgs e)
        {
            if (!ValidaDados())
            {
                return;
            }

            try
            {
                ToastProgress.Show();
                await firebaseHelper.VerificaEmail(txtEmail.Text.Trim());

                await firebaseHelper.AddUser(txtEmail.Text.Trim(), txtSenha.Text.Trim());

                await firebaseHelper.AddPerson(txtNome.Text.Trim(), txtEmail.Text.Trim(), txtTelefone.Value.ToString(), txtCPF.Value.ToString().Replace(',', '.'), txtCNH.Text.Trim(), "service-provider");

                LoginViewModel viewModel = new LoginViewModel();
                await viewModel.Login(txtEmail.Text, txtSenha.Text);

                ToastProgress.Hide();
                UserDialogs.Instance.Toast("Cadastro realizado com sucesso!", TimeSpan.FromSeconds(3));
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                string error = Validations.ErrorValidator.ValidaErrosAuth(ex.Message);
                await DisplayAlert("Ooopss...", error + "\n\nTente novamente!", "OK");
            }
        }
        public frmCheckMap(PedidoModel _pedido)
        {
            InitializeComponent();

            if (Settings.isService)
            {
                btnSalvar.IsVisible = true;
            }
            else
            {
                btnSalvar.IsVisible = false;
            }

            ToastProgress.Show();
            compGPS       = new GPS();
            Registro      = _pedido;
            checkRegistro = CheckHelper.ShowCheckInByPedido(_pedido.ID);

            if (checkRegistro == null)
            {
                lblError.IsVisible = true;
            }
            else
            {
                lblError.IsVisible = false;
            }

            InitializeMap();

            AddInicialLocationCommand = new Command(async() => await AddInicialLocation());
        }
Beispiel #3
0
        private void GrdCheck_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                if (e.SelectedItem == null)
                {
                    return;
                }

                ToastProgress.Show();

                var itemGrid = e.SelectedItem as PedidoModel;
                if (itemGrid == null)
                {
                    return;
                }

                frmCheckMap frmMapa = new frmCheckMap(itemGrid);
                frmMapa.Disappearing += frmPedido_Disappearing;
                Navigation.PushPopupAsync(frmMapa);

                ToastProgress.Hide();
                grdCheck.SelectedItem = null;
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                DisplayAlert("Error", ex.Message + "\n\nTente novamente!", "OK");
                grdCheck.SelectedItem = null;
            }
            finally { }
        }
        private void BuscarLocalizacao()
        {
            try
            {
                if (checkRegistro != null)
                {
                    ToastProgress.Show();

                    var posMarcada = new Pin()
                    {
                        Position = new Position(checkRegistro.LATITUDE, checkRegistro.LONGITUDE),
                        Label    = string.Format("#{0}", Registro.COD_FRETE.ToString().Split('-')[0].ToUpper()),
                        Address  = "POSIÇÃO MARCADA"
                    };
                    map.Pins.Clear();
                    map.Pins.Add(posMarcada);
                    map.MoveToRegion(MapSpan.FromCenterAndRadius(posMarcada.Position, Distance.FromMeters(500)), true);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                ToastProgress.Hide();
            }
        }
Beispiel #5
0
        private async void BtnSalvar_Clicked(object sender, EventArgs e)
        {
            if (!ValidaDados())
            {
                return;
            }

            try
            {
                ToastProgress.Show();
                Registro.NOME     = txtNome.Text.Trim();
                Registro.TELEFONE = txtTelefone.Value.ToString();
                Registro.CNH      = txtCNH.Text.ToString().Trim();
                Settings.UserName = Registro.NOME;

                await firebaseHelper.UpdatePerson(Registro);

                await Navigation.PopAsync();

                ToastProgress.Hide();
                UserDialogs.Instance.Toast("Cadastro atualizado com sucesso!", TimeSpan.FromSeconds(3));
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                string error = Validations.ErrorValidator.ValidaErrosAuth(ex.Message);
                await DisplayAlert("Ooopss...", error + "\n\nTente novamente!", "OK");
            }
        }
Beispiel #6
0
        private async void BtnSalvar_Clicked(object sender, EventArgs e)
        {
            if (!ValidaDados())
            {
                return;
            }

            try
            {
                ToastProgress.Show();

                if (!editando)
                {
                    await FreteHelper.AddFrete(Item);

                    UserDialogs.Instance.Toast("Frete cadastrado com sucesso!", TimeSpan.FromSeconds(3));
                }
                else
                {
                    await FreteHelper.UpdateFrete(Item);

                    UserDialogs.Instance.Toast("Frete atualizado com sucesso!", TimeSpan.FromSeconds(3));
                }

                await Navigation.PopAsync();

                ToastProgress.Hide();
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                await DisplayAlert("Error", ex.Message + "\n\nTente novamente!", "OK");
            }
        }
        private async void OnDelete(object sender, EventArgs e)
        {
            try
            {
                var          mi       = ((MenuItem)sender);
                VeiculoModel itemGrid = mi.CommandParameter as VeiculoModel;

                var answer = await DisplayAlert("Deletar? ", "Deseja realmente deletar: " + itemGrid.NOME, "Sim", "Não");

                ToastProgress.Show();

                if (answer)
                {
                    await VeiculoHelper.DeleteVeiculo(itemGrid.ID);

                    viewModel.LoadItemsCommand.Execute(null);
                    UserDialogs.Instance.Toast("Veículo deletado com sucesso!", TimeSpan.FromSeconds(3));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                ToastProgress.Hide();
            }
        }
Beispiel #8
0
        private async void Deletar_Clicked()
        {
            try
            {
                var answer = await DisplayAlert("Deletar? ", "Deseja realmente deletar este item?", "Sim", "Não");

                ToastProgress.Show();

                if (answer)
                {
                    await FreteHelper.DeleteFrete(Item.ID);

                    UserDialogs.Instance.Toast("Frete deletado com sucesso!", TimeSpan.FromSeconds(3));
                    await Navigation.PopAsync();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                ToastProgress.Hide();
            }
        }
Beispiel #9
0
        private void Lista_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                if (e.SelectedItem == null)
                {
                    return;
                }

                ToastProgress.Show();

                if (Settings.isService)
                {
                    var itemEdit = e.SelectedItem as FreteModel;

                    if (itemEdit == null)
                    {
                        return;
                    }

                    frmFreteCad frm = new frmFreteCad(itemEdit);
                    frm.Disappearing += frmFreteCad_Disappearing;
                    Navigation.PushAsync(frm, true);
                }
                else
                {
                    var itemDetail = e.SelectedItem as vwFrete;

                    if (itemDetail == null)
                    {
                        return;
                    }

                    frmFreteDetail frm = new frmFreteDetail(itemDetail);
                    frm.Disappearing += frmFreteCad_Disappearing;
                    Navigation.PushAsync(frm, true);
                }

                grdFretes.SelectedItem = null;
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                DisplayAlert("Error", ex.Message + "\n\nTente novamente!", "OK");
                grdFretes.SelectedItem = null;
            }
            finally {
                ToastProgress.Hide();
            }
        }
Beispiel #10
0
        private async void GrdPedidosArquivados_ItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            try
            {
                if (e.SelectedItem == null)
                {
                    return;
                }
                var answer = await DisplayAlert("Arquivar? ", "Deseja RESTAURAR este item?", "Sim", "Não");

                if (answer)
                {
                    ToastProgress.Show();

                    var itemGrid = e.SelectedItem as PedidoModel;
                    if (itemGrid == null)
                    {
                        return;
                    }

                    if (Settings.isUser)
                    {
                        itemGrid.INATIVO_USER = false;
                    }

                    if (Settings.isService)
                    {
                        itemGrid.INATIVO_PRESTADOR = false;
                    }

                    await PedidoHelper.UpdatePedido(itemGrid);

                    await Navigation.PopPopupAsync();
                }
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                await DisplayAlert("Error", ex.Message + "\n\nTente novamente!", "OK");

                grdPedidosArquivados.SelectedItem = null;
            }
            finally
            {
                grdPedidosArquivados.SelectedItem = null;
                ToastProgress.Hide();
            }
        }
 private async void btnAtualizar_Clicked(object sender, EventArgs e)
 {
     try
     {
         ToastProgress.Show();
         await AddInicialLocation();
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
     finally
     {
         ToastProgress.Hide();
     }
 }
 private void BtnArquives_Clicked(object sender, EventArgs e)
 {
     try
     {
         ToastProgress.Show();
         frmPedidosArquivados frm = new frmPedidosArquivados();
         frm.Disappearing += ListarTodos;
         Navigation.PushPopupAsync(frm, true);
     }
     catch (Exception ex)
     {
         ToastProgress.Hide();
         MessagingCenter.Send <object, string>(this, "Error", ex.Message);
     }
     finally
     {
         ToastProgress.Hide();
     }
 }
Beispiel #13
0
        private async Task <bool> Login()
        {
            try
            {
                ToastProgress.Show();
                await viewModel.Login(txtUsuario.Text, txtSenha.Text);

                ToastProgress.Hide();
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                string error = Validations.ErrorValidator.ValidaErrosAuth(ex.Message);
                await DisplayAlert("Ooopss...", error + "\n\nTente novamente!", "OK");

                return(false);
            }
            return(true);
        }
        private async void BtnExcluir_Tapped(object sender, EventArgs e)
        {
            try
            {
                var answer = await DisplayAlert("Arquivar? ", "Deseja realmente ARQUIVAR este item?", "Sim", "Não");

                if (answer)
                {
                    ToastProgress.Show();
                    var mi   = (TappedEventArgs)e;
                    var item = mi.Parameter as PedidoModel;
                    if (item == null)
                    {
                        return;
                    }

                    if (Settings.isUser)
                    {
                        item.INATIVO_USER = true;
                    }

                    if (Settings.isService)
                    {
                        item.INATIVO_PRESTADOR = true;
                    }

                    await PedidoHelper.UpdatePedido(item);

                    await viewModel.ExecuteLoadItemsCommand();
                }
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                MessagingCenter.Send <object, string>(this, "Error", ex.Message);
            }
            finally
            {
                ToastProgress.Hide();
            }
        }
        private async Task AddInicialLocation()
        {
            try
            {
                if (checkRegistro != null && checkRegistro.LATITUDE != 0 && checkRegistro.LONGITUDE != 0)
                {
                    Position _position = new Position(checkRegistro.LATITUDE, checkRegistro.LONGITUDE);

                    var posMarcada = new Pin()
                    {
                        Position = _position,
                        Label    = string.Format("#{0}", Registro.COD_FRETE.ToString().Split('-')[0].ToUpper()),
                        Address  = "POSIÇÃO MARCADA"
                    };
                    map.Pins.Clear();
                    map.Pins.Add(posMarcada);
                    map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition(_position, 15D, 0d, 0d));
                    map.MoveToRegion(MapSpan.FromCenterAndRadius(posMarcada.Position, Distance.FromMeters(2000)), true);
                }
                else
                {
                    Plugin.Geolocator.Abstractions.Position pos = await compGPS.GetCurrentLocation();

                    if (pos != null && pos.Latitude != 0 && pos.Longitude != 0)
                    {
                        Position _position = new Position(pos.Latitude, pos.Longitude);
                        map.InitialCameraUpdate = CameraUpdateFactory.NewCameraPosition(new CameraPosition(_position, 15D, 0d, 0d));
                        map.MoveToRegion(MapSpan.FromCenterAndRadius(_position, Distance.FromMeters(2000)), true);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                ToastProgress.Hide();
            }
        }
        private async void btnSalvar_Clicked(object sender, EventArgs e)
        {
            try
            {
                bool result = await DisplayAlert("SALVAR", "Deseja realizar o CHECK-IN?", "SIM", "NÃO");

                if (result)
                {
                    ToastProgress.Show();

                    CheckModal checkin = new CheckModal();
                    Plugin.Geolocator.Abstractions.Position pos = await compGPS.GetCurrentLocation();

                    if (pos == null || pos.Latitude == 0 || pos.Longitude == 0)
                    {
                        UserDialogs.Instance.Toast("Não foi possível encontrar sua localização!", TimeSpan.FromSeconds(3));
                        return;
                    }

                    checkin.COD_PEDIDO = Registro.ID;
                    checkin.LATITUDE   = pos.Latitude;
                    checkin.LONGITUDE  = pos.Longitude;

                    await CheckHelper.AddCheckIn(checkin);

                    UserDialogs.Instance.Toast("Check-in realizado com Sucesso!", TimeSpan.FromSeconds(3));
                    await Navigation.PopPopupAsync();

                    ItemAtualizado?.Invoke(this, true);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                ToastProgress.Hide();
            }
        }
        private void GrdVeiculos_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
        {
            try
            {
                if (e.ItemData == null)
                {
                    return;
                }

                var itemGrid = e.ItemData as PedidoModel;
                if (itemGrid == null)
                {
                    return;
                }

                if (Settings.isService)
                {
                    var             itemGrid2 = e.ItemData as vwPedido;
                    frmPedidoDetail frm       = new frmPedidoDetail(itemGrid2);
                    frm.Disappearing += frmPedido_Disappearing;
                    frm.ListarTodos  += ListarTodos;
                    Navigation.PushAsync(frm, true);
                }
                else
                {
                    switch (itemGrid.STATUS)
                    {
                    case 0:
                    case 1:
                        frmSolicitarReserva frm = new frmSolicitarReserva(itemGrid);
                        frm.Disappearing += frmPedido_Disappearing;
                        frm.ListarTodos  += ListarTodos;
                        Navigation.PushPopupAsync(frm, true);
                        break;

                    case 2:
                    case 3:
                        frmCheckMap frmMapa = new frmCheckMap(itemGrid);
                        frmMapa.Disappearing += frmPedido_Disappearing;
                        Navigation.PushPopupAsync(frmMapa);
                        break;

                    case 4:
                    case 5:
                    default:
                        var             itemGrid2 = e.ItemData as vwPedido;
                        frmPedidoDetail frmDetail = new frmPedidoDetail(itemGrid2);
                        frmDetail.Disappearing += frmPedido_Disappearing;
                        frmDetail.ListarTodos  += ListarTodos;
                        Navigation.PushAsync(frmDetail);
                        break;
                    }
                }

                grdVeiculos.SelectedItems.Clear();
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                DisplayAlert("Error", ex.Message + "\n\nTente novamente!", "OK");
                grdVeiculos.SelectedItems.Clear();
            }
            finally { }
        }
Beispiel #18
0
        private async void BtnSalvar_Clicked(object sender, EventArgs e)
        {
            try
            {
                ToastProgress.Show();

                if (Settings.isService)
                {
                    string _dscStatus = "";
                    switch (Item.STATUS)
                    {
                    case 0:
                        _dscStatus = "Em Aberto";
                        break;

                    case 1:
                        _dscStatus = "Reservado";
                        break;

                    case 2:
                        _dscStatus = "A Caminho";
                        break;

                    case 3:
                        _dscStatus = "Saio para Entrega";
                        break;

                    case 4:
                        _dscStatus = "Concluído";
                        break;

                    case 5:
                        _dscStatus = "Cancelado";
                        break;

                    default:
                        _dscStatus = "";
                        break;
                    }

                    await PedidoHelper.UpdatePedido(Item);

                    UserDialogs.Instance.Toast(string.Format("Solicitação alterada para: '{0}'", _dscStatus), TimeSpan.FromSeconds(3));
                }
                else
                {
                    Item.INATIVO_USER = true;
                    await PedidoHelper.UpdatePedido(Item);

                    UserDialogs.Instance.Toast("Arquivado com Sucesso!", TimeSpan.FromSeconds(3));
                }

                ListarTodos?.Invoke(this, EventArgs.Empty);
                await Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                ToastProgress.Hide();
                await DisplayAlert("Error", ex.Message + "\n\nTente novamente!", "OK");
            }
            finally
            {
                ToastProgress.Hide();
            }
        }