Ejemplo n.º 1
0
        private async void Login(object sender, EventArgs e)
        {
            NavigationLoader.ShowLoading();
            var user = FindViewById <EditText>(Resource.Id.txtUserLogin);
            var pass = FindViewById <EditText>(Resource.Id.txtPassLogin);

            if (string.IsNullOrEmpty(user.Text))
            {
                NavigationLoader.HideLoading();
                this.PresentAlert("Debe ingresar el nombre de usuario");
                return;
            }

            if (string.IsNullOrEmpty(pass.Text))
            {
                NavigationLoader.HideLoading();
                this.PresentAlert("Debe ingresar  la contraseña");
                return;
            }

            var data = new
            {
                Username = user.Text,
                Password = pass.Text
            };

            var response = await this.apiService.Post("Account/Login", data);

            if (response.success)
            {
                var result = JsonConvert.DeserializeObject <LoginResponse>(response.data.ToString());
                Settings.AccessToken     = result.Token;
                Settings.User            = JsonConvert.SerializeObject(result);
                Settings.CantidadEscaneo = "0";
                if (result.TipoUsuario.ToLower() == "calidad" || result.TipoUsuario.ToLower() == "chequeo")
                {
                    if (result.TipoUsuario.ToLower() == "calidad")
                    {
                        Settings.TypeUser = ((int)TipoEscaneo.calidad).ToString();
                    }
                    else
                    {
                        Settings.TypeUser = ((int)TipoEscaneo.chequeo).ToString();
                    }
                    StartActivity(new Intent(Application.Context, typeof(HomeActivity)));
                }
                else
                {
                    StartActivity(new Intent(Application.Context, typeof(SelectedRoleActivity)));
                }
                NavigationLoader.HideLoading();
            }
            else
            {
                NavigationLoader.HideLoading();
                this.PresentAlert("Usuario y/o contraseña incorrecta");
            }
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            NavigationLoader.init(this);
            apiService = new ApiService();

            var buttoLogin = FindViewById <Button>(Resource.Id.btnLogin);

            buttoLogin.Click += Login;
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.infoPallet);
            NavigationLoader.init(this);
            apiService = new ApiService();
            this.InicializeInfo();
            this.codigo = Intent.GetStringExtra("Codigo");
            this.GetInfoPallet(this.codigo);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbarInfoPallets);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Información Pallet";
            SupportActionBar.SetDefaultDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.home);
            NavigationLoader.init(this);
            this.apiService = new ApiService();
            this.user       = JsonConvert.DeserializeObject <LoginResponse>(Settings.User);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbarTabs);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title       = "Perfilación De Pallets";
            this.txtCodebar              = FindViewById <EditText>(Resource.Id.txtcodeBar);
            txtCodebar.AfterTextChanged += changeCodebar;
            imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
            txtCodebar.Touch += onTouchEvent;
        }
Ejemplo n.º 5
0
        private async void aleatorioCaraPallet(object sender, EventArgs e)
        {
            NavigationLoader.ShowLoading();
            Random random = new Random();
            var    cara   = random.Next(1, 6);
            var    data   = new
            {
                ID        = this.idPallet,
                CaraPalet = cara
            };
            var response = await this.apiService.Post("Palet/GuardarCara", data, Settings.AccessToken);

            if (response.success)
            {
                if (response.data != null)
                {
                    this.btnInfoAleatorio.Visibility = Android.Views.ViewStates.Gone;
                    this.txtInfoCara.Text            = cara.ToString();
                    this.PresentAlert("La cara seleccionada es la número: " + cara, false);
                    NavigationLoader.HideLoading();
                }
                else
                {
                    NavigationLoader.HideLoading();
                    this.PresentAlert("Se presentó un error, por favor intente mas tarde", true);
                }
            }
            else
            {
                NavigationLoader.HideLoading();
                if (response.data == null)
                {
                    this.PresentAlert("Se ha presentado un problema interno", true);
                }
                else
                {
                    this.PresentAlert(response.data.ToString(), true);
                }
            }
        }
Ejemplo n.º 6
0
        private async void SelecionarCara(object sender, EventArgs e)
        {
            NavigationLoader.ShowLoading();
            Random random = new Random();
            var    cara   = random.Next(1, 6);
            var    data   = new
            {
                Id      = this.idPallet,
                Cara    = cara,
                Usuario = this.user.NombreCompleto
            };
            var response = await this.apiService.Post("Palet/GuardarCara", data, Settings.AccessToken);

            if (response.success)
            {
                if (response.data != null)
                {
                    this.PresentAlert("La cara seleccionada es la número: " + EnumHelper.GetEnumDescription((CarasPallet)cara), true);
                    NavigationLoader.HideLoading();
                }
                else
                {
                    NavigationLoader.HideLoading();
                    this.PresentAlert("Se presentó un error, por favor intente mas tarde", true);
                }
            }
            else
            {
                NavigationLoader.HideLoading();
                if (response.data == null)
                {
                    this.PresentAlert("Se ha presentado un problema interno", true);
                }
                else
                {
                    this.PresentAlert(response.data.ToString(), true);
                }
            }
        }
Ejemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.seleccion_cara);
            this.apiService = new ApiService();
            NavigationLoader.init(this);
            this.idPallet   = Intent.GetStringExtra("IdPallet");
            this.CaraPallet = Intent.GetIntExtra("CaraPallet", 0);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbarSeleccionCara);

            SetSupportActionBar(toolbar);
            SupportActionBar.Title = "Inspeción Pallet";
            this.user                    = JsonConvert.DeserializeObject <LoginResponse>(Settings.User);
            this.btnSeleccionCara        = FindViewById <Button>(Resource.Id.btnSeleccionCara);
            this.btnSeleccionCara.Click += SelecionarCara;
            if (this.CaraPallet > 0)
            {
                this.PresentAlert("Ya se seleccionó una cara para la inspección de este pallet, la cara seleccionada es: " + EnumHelper.GetEnumDescription((CarasPallet)this.CaraPallet), true);
            }
            // Create your application here
        }
Ejemplo n.º 8
0
        private async void GetInfoPallet(string codigo)
        {
            NavigationLoader.ShowLoading();
            var data = new
            {
                CodigoPalet = codigo
            };
            var response = await this.apiService.Post("Palet/GetByCodigo", data, Settings.AccessToken);

            if (response.success)
            {
                if (response.data != null)
                {
                    var result = JsonConvert.DeserializeObject <InfoPaletResponse>(response.data.ToString());
                    this.idPallet                     = result.idPallet;
                    this.txtInfoCarga.Text            = result.carga;
                    this.txtInfoCajasPallet.Text      = result.cajasPalet.ToString();
                    this.txtInfoPerfilar.Text         = result.perfilar ? "SI" : "NO";
                    this.txtInfoDestino.Text          = result.destino;
                    this.txtInfoExportador.Text       = result.exportador;
                    this.txtInfoBuque.Text            = result.buque;
                    this.txtInfoHLlegadaCamion.Text   = result.llegada.ToString("h:mm tt");
                    this.txtInfoHSalidaFinca.Text     = result.salida.ToString("h:mm tt");
                    this.txtInfoHEstimada.Text        = result.estimado.ToString("h:mm tt");
                    this.txtInfoHLlegadaTerminal.Text = (result.llegadaTerminal == null ? "" : ((DateTime)result.llegadaTerminal).ToString("h:mm tt"));
                    this.txtInfoFruta.Text            = result.fruta;
                    this.txtInfoPoma.Text             = result.poma.ToString();
                    this.txtInfoFinca.Text            = result.finca;
                    this.txtInfoCara.Text             = result.caraPallet != 0 ? result.caraPallet.ToString() : "N/A";
                    this.txtInfoTerminalDestino.Text  = result.terminalDestino;
                    if (result.perfilar)
                    {
                        this.txtInfoPerfilar.SetTextColor(Android.Graphics.Color.Rgb(95, 154, 53));
                    }
                    else
                    {
                        this.txtInfoPerfilar.SetTextColor(Android.Graphics.Color.Orange);
                    }
                    var visibleButton = result.caraPallet != 0 ? Android.Views.ViewStates.Invisible : result.perfilar ? Android.Views.ViewStates.Visible : Android.Views.ViewStates.Invisible;
                    this.btnInfoAleatorio.Visibility = visibleButton;
                    NavigationLoader.HideLoading();
                }
                else
                {
                    NavigationLoader.HideLoading();
                    this.PresentAlert("No hay información del pallet escaneado. Código del pallet: " + this.codigo, true);
                }
            }
            else
            {
                NavigationLoader.HideLoading();
                if (response.data == null)
                {
                    this.PresentAlert("Se ha presentado un problema interno", true);
                }
                else
                {
                    this.PresentAlert(response.data.ToString(), true);
                }
            }
        }
Ejemplo n.º 9
0
        private async void GetInfoPallet(string codigo)
        {
            string[] cadena = Regex.Split(codigo, @"\r\n?|\n");
            if (!(cadena.Length > 1))
            {
                NavigationLoader.ShowLoading();
                var data = new
                {
                    UsuarioLectura = this.user.NombreCompleto,
                    CodigoPalet    = codigo
                };
                var response = await this.apiService.Post("Palet/GetByCodigo", data, Settings.AccessToken);

                if (response.success)
                {
                    if (response.data != null)
                    {
                        var result = JsonConvert.DeserializeObject <InfoPaletResponse>(response.data.ToString());
                        if (int.Parse(Settings.TypeUser) == (int)TipoEscaneo.chequeo)
                        {
                            if (result.perfilar)
                            {
                                StartActivity(new Intent(Application.Context, typeof(PalletCalidadActivity)));
                            }
                            else
                            {
                                StartActivity(new Intent(Application.Context, typeof(PalletChequeoActivity)));
                            }
                        }
                        else
                        {
                            if (result.perfilar)
                            {
                                Intent intent = new Intent(Application.Context, typeof(SeleccionCaraActivity));
                                intent.PutExtra("IdPallet", result.idPallet.ToString());
                                intent.PutExtra("CaraPallet", result.caraPallet);
                                StartActivity(intent);
                            }
                            else
                            {
                                this.PresentAlert("El pallet escaneado no es para perfilación.");
                            }
                        }
                        NavigationLoader.HideLoading();
                    }
                    else
                    {
                        NavigationLoader.HideLoading();
                        this.PresentAlert("No hay información del pallet escaneado. Código del pallet: " + codigo);
                    }
                }
                else
                {
                    NavigationLoader.HideLoading();
                    if (response.data == null)
                    {
                        this.PresentAlert("Se ha presentado un problema interno");
                    }
                    else
                    {
                        this.PresentAlert(response.data.ToString());
                    }
                }
            }
            this.txtCodebar.Text = "";
        }