Exemple #1
0
        public async Task <EntregaAlmacen> updateRepuesto(EntregaAlmacen repuesto)
        {
            try
            {
                client = initClient();
                var    contentPost = new StringContent("", Encoding.UTF8, "application/json");
                string url         = string.Format(@"api/EntregaAlmacen?key={0}&cantidad={1}&destino={2}&maquina={3}"
                                                   , repuesto.Cod_Producto, repuesto.Cantidad, repuesto.Destino, repuesto.Maquina);
                var response = await client.PutAsync(url, contentPost);

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

                    repuesto = JsonConvert.DeserializeObject <EntregaAlmacen>(content);

                    return(repuesto);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Se ha producido una excipcion no controlada", ex.InnerException);
            }

            return(null);
        }
        // PUT: api/EntregaAlmacen/5

        public IHttpActionResult Put(string codRepusto, string codEmpleado)
        {
            try {
                OpenService();

                if (entregaAlmacenServicio != null)
                {
                    EntregaAlmacen nuevaEntrega = new EntregaAlmacen();
                    nuevaEntrega.Cod_Almacen  = @"PATIO";
                    nuevaEntrega.Cod_Producto = codRepusto.Trim();
                    if (codEmpleado.Trim() != string.Empty)
                    {
                        nuevaEntrega.Cod_Empleado = codEmpleado.Trim();
                    }
                    else
                    {
                        throw new Exception("No se ha introducido codigo empleado");
                    }
                    entregaAlmacenServicio.Create(ref nuevaEntrega);

                    return(Ok(nuevaEntrega));
                }
            }
            catch (Exception ex)
            {
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.InternalServerError);
                response.Content        = new StringContent(ex.Message);
                response.RequestMessage = Request;
                var error = new HttpResponseException(response);
                return((IHttpActionResult)error);
            }
            return(null);
        }
Exemple #3
0
        public static async Task <EntregaAlmacen> addRepuesto(string codEmpleado, string codRepuesto)
        {
            EntregaAlmacen repuesto = await datos.addRepuesto(codEmpleado, codRepuesto);

            if (repuesto != null)
            {
                repuestos.Add(repuesto);
            }
            return(repuesto);
        }
        private async void OnClik_btoAceptar(object sender, EventArgs e)
        {
            var _btoAceptar = (Button)sender;

            if (validar())
            {
                progressLayout.Visibility = ViewStates.Visible;
                repuesto = await ManagerRepuestos.updateRepuesto(repuesto);

                progressLayout.Visibility = ViewStates.Gone;

                Finish();
            }
            else
            {
                _btoAceptar.SetError("Introduza una cantidad antes de aceptar", warning);
            }
        }
        public void createUpdateDeleteRepuesto()
        {
            RepositoryEntragaAlmacenEpis repoEntregaEPI = new RepositoryEntragaAlmacenEpis(hostWs);
            EntregaAlmacen nuevoItem = new EntregaAlmacen();

            nuevoItem.Cod_Almacen  = "PATIO";
            nuevoItem.Cod_Empleado = "E0006";
            nuevoItem.Cod_Producto = "REP000001";

            //CREATE
            repoEntregaEPI.Add(ref nuevoItem);

            //UPDATE
            nuevoItem.Cantidad = 2;
            nuevoItem.Destino  = Destino.Otros;
            repoEntregaEPI.Update(ref nuevoItem);

            //DELETE
            repoEntregaEPI.Remove(nuevoItem.Key);

            Assert.Pass();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.detalleRepuesto);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            string key = Intent.GetStringExtra("idEntregaAlmacen");

            repuesto = ManagerRepuestos.getRepuestoByKey(key);

            SupportActionBar.Title = string.Format(@"{0} - {1}", repuesto.Cod_Producto, repuesto.Unit_of_Measure_Code);

            edittext              = FindViewById <EditText>(Resource.Id.textCantidad);
            edittext.TextChanged += Edittext_TextChanged;
            if (repuesto.Cantidad != 0)
            {
                edittext.Text = repuesto.Cantidad.ToString();
            }
            else
            {
                edittext.Text = string.Empty;
            }

            edittext.FocusChange += (sender, args) =>
            {
                bool isFocused = args.HasFocus;
                if (!isFocused)
                {
                    spinner_OnClick(sender);
                }
            };

            spinnerDestino = (Spinner)FindViewById(Resource.Id.spinnerDestino);

            spinnerDestino.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerDestino_ItemSelected);

            spinnerMaquina = (Spinner)FindViewById(Resource.Id.spinnerMaquina);
            spinnerMaquina.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerMaquina_ItemSelected);
            spinnerMaquina.Visibility    = ViewStates.Invisible;

            var s = (Destino[])Enum.GetValues(typeof(Destino));

            adapterDestinos = new AdapterSpinner <Destino>(this, Android.Resource.Layout.SimpleSpinnerItem, s);
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerDestino.Adapter              = adapterDestinos;
            spinnerDestino.Focusable            = true;
            spinnerDestino.FocusableInTouchMode = true;
            spinnerDestino.RequestFocus(FocusSearchDirection.Up);

            var arrayMaquinas = (Maquina[])Enum.GetValues(typeof(Maquina));

            adapterMaquinas = new AdapterSpinner <Maquina>(this, Android.Resource.Layout.SimpleSpinnerItem, arrayMaquinas);
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerMaquina.Adapter              = adapterMaquinas;
            spinnerMaquina.Focusable            = true;
            spinnerMaquina.FocusableInTouchMode = true;
            spinnerMaquina.RequestFocus(FocusSearchDirection.Up);

            TextView textDescription = FindViewById <TextView>(Resource.Id.textDescription);

            textDescription.Text = repuesto.Descripcion_Producto;

            Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);
            warning = (Drawable)Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);

            if (repuesto.Cantidad != 0)
            {
                spinnerDestino.SetSelection((int)repuesto.Destino);
                spinnerMaquina.SetSelection((int)repuesto.Maquina);
            }

            Button btoAceptar = FindViewById <Button>(Resource.Id.btoAceptar);

            btoAceptar.Click += OnClik_btoAceptar;

            progressLayout            = FindViewById <LinearLayout>(Resource.Id.progressBar);
            progressLayout.Visibility = ViewStates.Gone;
        }
Exemple #7
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            var ignored = base.OnCreateView(inflater, container, savedInstanceState);

            view = inflater.Inflate(Resource.Layout.detalleRepuesto, null);


            string key    = string.Empty;
            Bundle bundle = this.Arguments;

            if (bundle != null)
            {
                key = bundle.GetString("idEntregaAlmacen");
            }
            repuesto = ManagerRepuestos.getRepuestoByKey(key);



            AppCompatActivity activity = (AppCompatActivity)this.Activity;

            activity.SupportActionBar.Title    = string.Format(@"Producto: {0}", repuesto.Cod_Producto);
            activity.SupportActionBar.Subtitle = string.Format(@"Unidad Medida: {0}", repuesto.Unit_of_Measure_Code);
            edittext = view.FindViewById <EditText>(Resource.Id.textCantidad);



            edittext.TextChanged += Edittext_TextChanged;
            if (repuesto.Cantidad != 0)
            {
                edittext.Text = repuesto.Cantidad.ToString();
            }
            else
            {
                edittext.Text = string.Empty;
            }

            //spinnerDestino.SetSelection(repuesto.) = 0;
            edittext.FocusChange += (sender, args) =>
            {
                bool isFocused = args.HasFocus;
                if (!isFocused)
                {
                    spinner_OnClick(sender);
                }
            };

            spinnerDestino = (Spinner)view.FindViewById(Resource.Id.spinnerDestino);

            spinnerDestino.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerDestino_ItemSelected);
            //spinnerDestino.ItemClick += spinner_OnClick;


            spinnerMaquina = (Spinner)view.FindViewById(Resource.Id.spinnerMaquina);

            spinnerMaquina.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinnerMaquina_ItemSelected);
            spinnerMaquina.Visibility    = ViewStates.Invisible;
            //spinnerMaquina.ItemClick += spinner_OnClick;


            var s = (Destino[])Enum.GetValues(typeof(Destino));

            adapterDestinos = new AdapterSpinner <Destino>(this.Activity, Android.Resource.Layout.SimpleSpinnerItem, s);
            // Specify the layout to use when the list of choices appears
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            spinnerDestino.Adapter = adapterDestinos;

            spinnerDestino.Focusable            = true;
            spinnerDestino.FocusableInTouchMode = true;
            spinnerDestino.RequestFocus(FocusSearchDirection.Up);

            //string[] Maquinas = new String[] { "M1", "M2", "M3", "M4", "R1", "R2", "R3", "R4", "T1", "T2", "T3", "T4", "T5", "T6", "T7", "T8" };

            var arrayMaquinas = (Maquina[])Enum.GetValues(typeof(Maquina));

            adapterMaquinas = new AdapterSpinner <Maquina>(this.Activity, Android.Resource.Layout.SimpleSpinnerItem, arrayMaquinas);
            // Specify the layout to use when the list of choices appears
            adapterDestinos.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            spinnerMaquina.Adapter              = adapterMaquinas;
            spinnerMaquina.Focusable            = true;
            spinnerMaquina.FocusableInTouchMode = true;
            spinnerMaquina.RequestFocus(FocusSearchDirection.Up);

            TextView textDescription = view.FindViewById <TextView>(Resource.Id.textDescription);

            textDescription.Text = repuesto.Descripcion_Producto;



            Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);
            warning = (Drawable)Resources.GetDrawable(Android.Resource.Drawable.AlertLightFrame);


            //spinnerDestino.Click += (object sender, EventArgs e) =>
            //{
            //    InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService);
            //    imm.HideSoftInputFromWindow(edittext.WindowToken, 0);
            //};


            Button btoAceptar = view.FindViewById <Button>(Resource.Id.btoAceptar);

            btoAceptar.Click += OnClik_btoAceptar;

            progressLayout            = view.FindViewById <LinearLayout>(Resource.Id.progressBarDetalle);
            progressLayout.Visibility = ViewStates.Gone;

            if (repuesto.Cantidad != 0)
            {
                spinnerDestino.SetSelection((int)repuesto.Destino);
                spinnerMaquina.SetSelection((int)repuesto.Maquina);
            }

            return(view);
        }
Exemple #8
0
 public static async Task <EntregaAlmacen> updateRepuesto(EntregaAlmacen repuesto)
 {
     return(await datos.updateRepuesto(repuesto));
 }
        private async void eliminarRepuesto(EntregaAlmacen item)
        {
            await ManagerRepuestos.eliminarRepuesto(item.Key);

            this.adaptarSwipe.NotifyDataSetChanged();
        }
        private async Task launchScaner()
        {
            var    scanner = new MobileBarcodeScanner();
            Button flashButton;
            View   zxingOverlay;

            scanner.UseCustomOverlay = true;

            //Inflate our custom overlay from a resource layout
            zxingOverlay = LayoutInflater.FromContext(this.Activity).Inflate(Resource.Layout.OverlayReadBarCode, null);

            //Find the button from our resource layout and wire up the click event
            flashButton        = zxingOverlay.FindViewById <Button>(Resource.Id.buttonZxingFlash);
            flashButton.Click += (sender, e) => scanner.ToggleTorch();

            //Set our custom overlay
            scanner.CustomOverlay = zxingOverlay;

            //Start scanning!
            var result = await scanner.Scan();



            Toast.MakeText(this.Activity, result.Text, ToastLength.Long);
            //HandleScanResult(result);

            string msg = string.Empty;

            if (!ManagerRepuestos.existeRepuestoEnLista(empleado.No, result.Text))

            {
                if (result != null && !string.IsNullOrEmpty(result.Text))
                {
                    EntregaAlmacen rep = await ManagerRepuestos.addRepuesto(empleado.No, result.Text);

                    if (rep == null)
                    {
                        Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this.Activity);
                        alert.SetTitle("Error en lectura de Código de Barras");
                        alert.SetMessage("Código leido: " + result);
                        alert.SetPositiveButton("Ok", (s, e) =>
                        {
                            rep = null;
                            //msg = "Código leido: " + result;
                            //this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show());
                        });
                        alert.Show();
                    }
                    else
                    {
                        //var rep = await ManagerRepuestos.addRepuesto(empleado.No, result.Text);
                        //if (rep != null)
                        //{
                        adaptarSwipe.NotifyDataSetChanged();

                        //var activityDetalleRepuestoActivity = new Intent(this.Activity, typeof(detalleRepuestoActivity));
                        //activityDetalleRepuestoActivity.PutExtra("idEntregaAlmacen", rep.Key);
                        //StartActivity(activityDetalleRepuestoActivity);


                        Android.Support.V4.App.Fragment fragment = new AlmacenRepuestosXamarin.Fragments.DetalleRepuesto();

                        Bundle bundle = new Bundle();
                        bundle.PutString("idEntregaAlmacen", rep.Key);
                        fragment.Arguments = bundle;



                        FragmentManager.BeginTransaction()
                        .Replace(Resource.Id.content_frame, fragment)
                        .AddToBackStack("ListaRepuestosEntrega")
                        .Commit();
                        //}
                    }
                }
                else
                {
                    msg = "Scaneo Cancelado";
                }
            }
            else
            {
                msg = "Ya fue escaneado ese producto!!";
            }

            if (!string.IsNullOrEmpty(msg))
            {
                this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, msg, ToastLength.Short).Show());
            }
        }