Пример #1
0
        public static async Task <HttpResponseMessage> UpdateRollo(RolloModel rollo)
        {
            HttpClient httpClient = new HttpClient();
            var        uri        = new UrlMain();
            string     url        = string.Concat(uri.UrlM, "rollos/?id=", rollo.Idrollo);

            String js = JsonConvert.SerializeObject(rollo);

            HttpContent httpContent = new StringContent(js);

            httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var response = await httpClient.PutAsync(url, httpContent).ConfigureAwait(false);

            return(response);
        }
Пример #2
0
        public static async Task <List <RolloModel> > GetRollosXidContenedor_ancho(int idcontenedor)
        {
            HttpClient httpClient = new HttpClient();
            var        uri        = new UrlMain();
            string     url        = string.Concat(uri.UrlM, "rollos/ancho/?", "idcontenedor=", idcontenedor.ToString());

            var response = await httpClient.GetAsync(url).ConfigureAwait(false);

            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                var rollos = RolloModel.FromJson(json);

                return(rollos);
            }
            return(null);
        }
Пример #3
0
        private async void BtbguardarWidth_Click(object sender, EventArgs e)
        {
            var progress = new ProgressDialog(this)
            {
                Indeterminate = true
            };

            progress.SetProgressStyle(ProgressDialogStyle.Spinner);
            progress.SetMessage("Loading... Please wait...");
            progress.SetCancelable(false);

            try
            {
                if (Validartxt(txtWidth) && idrolloWidth != 0)
                {
                    var culture = new CultureInfo("en-US");

                    var obj = new RolloModel()
                    {
                        Idrollo = idrolloWidth,
                        Ancho   = double.Parse(txtWidth.Text, culture.NumberFormat)
                    };

                    var conection = new ConnectivityService();

                    if (conection.IsConnected)
                    {
                        progress.Show();

                        var resp = await Task.Run(() => { return(RolloServ.UpdateRollo(obj).Result); });


                        if (resp.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            ListarollosWidth.RemoveAt(ListarollosWidth.FindIndex(x => x.Idrollo == idrolloWidth));
                            txtsecuenciaRolloWidth.Text = string.Empty;
                            lblnombrerolloWidth.Text    = "";
                            Toast.MakeText(this, "Ingreso Correcto", ToastLength.Long).Show();
                            idrolloWidth = 0;
                            Limpiartext();
                            Enabled(false);

                            var countItem = ListarollosWidth.Count;
                            lbltotalrollos.Text = string.Concat("Total de rollos por medir: ", countItem.ToString());
                            txtsecuenciaRolloWidth.RequestFocus();

                            progress.Dismiss();
                        }
                        else
                        {
                            progress.Dismiss();
                            Alerta("Advertencia?", "Ha ocurrido un error, no se efectuaron los cambios!!!");
                        }
                    }
                    else
                    {
                        progress.Dismiss();
                        Alerta("Advertencia?", "Verifique su conexion a la red wifi");
                    }
                }
                else
                {
                    progress.Dismiss();
                    Toast.MakeText(this, "llenar correctamente", ToastLength.Long).Show();
                }
            }
            catch (Exception ex)
            {
                progress.Dismiss();
                Alerta("Advertencia?", ex.Message);
            }
        }