private void StockActual_PreviewKeyUp(object sender, KeyRoutedEventArgs e)
        {
            TextBox tb = (TextBox)sender;

            CloureManager.NumberInput(tb);
            ProductStock productStock = (ProductStock)((FrameworkElement)e.OriginalSource).DataContext;
            double       stock_actual = 0;

            double.TryParse(tb.Text, out stock_actual);
            productStock.Actual = stock_actual;
        }
        public static async Task <List <ProductStock> > GetStock(int id)
        {
            List <ProductStock> productStocks = new List <ProductStock>();

            try
            {
                List <CloureParam> cparams = new List <CloureParam>();
                cparams.Add(new CloureParam("module", "products_services"));
                cparams.Add(new CloureParam("topic", "cargar_stock"));
                cparams.Add(new CloureParam("producto_id", id));
                string res = await CloureManager.ExecuteAsync(cparams);

                JsonObject api_result = JsonObject.Parse(res);
                string     error      = api_result.GetNamedString("Error");
                if (error == "")
                {
                    JsonObject api_response = api_result.GetNamedObject("Response");
                    JsonArray  registers    = api_response.GetNamedArray("Registros");

                    foreach (JsonValue jsonValue in registers)
                    {
                        JsonObject register = jsonValue.GetObject();

                        ProductStock item = new ProductStock();
                        item.PropiedadId     = (int)register.GetNamedNumber("PropiedadId");
                        item.PropiedadNombre = register.GetNamedString("PropiedadNombre");
                        item.MinPrompt       = register.GetNamedString("MinPrompt");
                        item.CurrentPrompt   = register.GetNamedString("CurrentPrompt");
                        item.Actual          = CloureManager.ParseNumber(register.GetNamedValue("Actual"));
                        item.Min             = CloureManager.ParseNumber(register.GetNamedValue("Min"));

                        productStocks.Add(item);
                    }
                }
                else
                {
                    throw new Exception(error);
                }
            }
            catch (Exception ex)
            {
                var dialog = new MessageDialog(ex.Message);
                await dialog.ShowAsync();
            }

            return(productStocks);
        }