private void CargarProductosContados() { try { var servicios = new Services.ProductosServices(); var Lista = new List <Productos>(); var respuesta = servicios.TraerListaProductosContados(Usuario); if (respuesta.Code == 1) { if (respuesta.Lista.Count > 0) { List <Entidades.ListaProductos> lp = new List <Entidades.ListaProductos>(); foreach (var i in respuesta.Lista) { lp.Add(JsonConvert.DeserializeObject <Entidades.ListaProductos>(i.ToString())); } this.listContado.Clear(); foreach (var i in lp) { Lista.Add(new Productos { Codigo = i.Codigo_Producto, Nombre = i.Nombre, Estado = i.Estado, Resultado = i.Resultado, Conteo1 = i.Conteo1, Conteo2 = i.Conteo2, Conteo3 = i.Conteo3, NoMostrarApp = i.NoMostrarApp //para no mostrar los productos que se marcaron en 0 }); } if (this.buttonSelect == 2) { listContado = Lista; Acr.UserDialogs.UserDialogs.Instance.HideLoading(); Device.BeginInvokeOnMainThread(() => { this.lvwProductos.ItemsSource = listContado; if (listContado.Count <= 0) { this.imgResultado.IsVisible = true; this.imgResultado.HeightRequest = 100; } else { this.imgResultado.IsVisible = false; this.imgResultado.HeightRequest = 0; this.btnContados.Text = " Contados (" + listContado.Count().ToString() + ")"; } }); } if (this.buttonSelect == 3) { if (Usuario.Conteo == 1) { listDiferencias = Lista.Where(x => x.Estado == "0" && (x.Conteo1 == 0 && x.NoMostrarApp == 0)).ToList(); } if (Usuario.Conteo == 2) { listDiferencias = Lista.Where(x => x.Estado == "0" && (x.Conteo2 == 0 && x.NoMostrarApp == 0)).ToList(); } if (Usuario.Conteo == 3) { listDiferencias = Lista.Where(x => x.Estado == "0" && (x.Conteo3 == 0 && x.NoMostrarApp == 0)).ToList(); } Acr.UserDialogs.UserDialogs.Instance.HideLoading(); Device.BeginInvokeOnMainThread(() => { this.lvwProductos.ItemsSource = listDiferencias; if (listDiferencias.Count <= 0) { this.imgResultado.IsVisible = true; this.imgResultado.HeightRequest = 100; } else { this.imgResultado.IsVisible = false; this.imgResultado.HeightRequest = 0; this.btnDiferencias.Text = " Diferencias (" + listDiferencias.Count().ToString() + ")"; } }); } } else { Acr.UserDialogs.UserDialogs.Instance.HideLoading(); Device.BeginInvokeOnMainThread(() => { this.lvwProductos.ItemsSource = new List <Productos>(); this.imgResultado.IsVisible = true; this.imgResultado.HeightRequest = 100; }); } } else { Acr.UserDialogs.UserDialogs.Instance.HideLoading(); Device.BeginInvokeOnMainThread(() => { Acr.UserDialogs.UserDialogs.Instance.Toast(new Acr.UserDialogs.ToastConfig("Ocurrio un Problema! ,Intentar de Nuevo!")); this.imgResultado.IsVisible = false; this.imgResultado.HeightRequest = 0; }); return; } } catch (Exception) { Acr.UserDialogs.UserDialogs.Instance.Toast(new Acr.UserDialogs.ToastConfig("Ocurrio un Problema! ,Intentar de Nuevo!")); Acr.UserDialogs.UserDialogs.Instance.HideLoading(); Device.BeginInvokeOnMainThread(() => { this.imgResultado.IsVisible = false; this.imgResultado.HeightRequest = 0; }); return; } }
private void CargarProductosContados() { try { var servicios = new Services.ProductosServices(); var Lista = new List <Productos>(); var respuesta = servicios.TraerListaProductosContados(Usuario); if (respuesta.Code == 1) { if (respuesta.Lista.Count > 0) { List <Entidades.ListaProductos> lp = new List <Entidades.ListaProductos>(); foreach (var i in respuesta.Lista) { lp.Add(JsonConvert.DeserializeObject <Entidades.ListaProductos>(i.ToString())); } this.listContado.Clear(); foreach (var i in lp) { Lista.Add(new Productos { Codigo = i.Codigo_Producto, Nombre = i.Nombre, Estado = i.Estado, Resultado = i.Resultado }); } if (this.buttonSelect == 2) { listContado = Lista; this.lvwProductos.ItemsSource = listContado; } if (this.buttonSelect == 3) { if (listDiferencias.Count <= 0) { if (Usuario.Conteo == 1) { listDiferencias = Lista.Where(x => x.Estado == "0" && x.Conteo1 == 0).ToList(); } if (Usuario.Conteo == 2) { listDiferencias = Lista.Where(x => x.Estado == "0" && x.Conteo2 == 0).ToList(); } if (Usuario.Conteo == 3) { listDiferencias = Lista.Where(x => x.Estado == "0" && x.Conteo3 == 0).ToList(); } } this.lvwProductos.ItemsSource = listDiferencias; } } else { this.lvwProductos.ItemsSource = new List <Productos>(); } } } catch (Exception) { return; // throw; } }