private async void LoadDetailsPlan(int id)
        {
            var list   = new List <ViewCountPlanDetailExtend>();
            var result = await countServices.GetById(id);

            if (result != null)
            {
                list.AddRange(result.Select(item => new ViewCountPlanDetailExtend()
                {
                    Id                 = item.Id,
                    IdCountPlan        = item.IdCountPlan,
                    Name               = item.Name,
                    Description        = item.Description,
                    ProductCode        = item.ProductCode,
                    Quantity           = item.Quantity,
                    TotalCounted       = item.TotalCounted,
                    BarCode            = item.BarCode,
                    ProductDescription = item.ProductDescription,
                    TotalProduct       = item.TotalProduct,
                    HasDetails         = (item.TotalProduct > 0) ? "Images/check.png" : "Images/uncheck.png",
                    ProductOk          = (item.Quantity <= item.TotalProduct) ? "Images/yes.png" : "Images/no.png"
                }));

                if (list.Count() > 0)
                {
                    PlanName        = result.FirstOrDefault().Name;
                    PlanDescription = result.FirstOrDefault().Name + " " + result.FirstOrDefault().Description;
                }


                Details = new ObservableCollection <ViewCountPlanDetailExtend>(list);
            }
        }
Пример #2
0
        private async void ListCount_OnItemSelected(object sender, SelectedItemChangedEventArgs e)
        {
            CountViewModel viewModel = sender as CountViewModel;

            if (e.SelectedItem == null)
            {
                return;
            }
            var x = (CountPlan)e.SelectedItem;


            var result = await countServices.GetById(x.Id);

            if (result.Any(a => a.TotalProduct > 0))
            {
                var answer = await DisplayAlert("TSHIRT", x.Name + " ya tiene SubConteos, Desea Continuar un nuevo SubConteo?", "SI", "NO");

                if (answer)
                {
                    Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(new Plan(x.Id));
                }
            }
            else
            {
                Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(new Plan(x.Id));
            }
        }
        private void AsyncLoadDetailsPlan()
        {
            IsPage = false;

            Task.Run(async() =>
            {
                var list   = new List <ViewCountPlanDetailExtend>();
                var result = await countServices.GetById(IdPlan);
                if (result != null)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        list.AddRange(result.Listrows.Select(item => new ViewCountPlanDetailExtend()
                        {
                            Id                 = item.Id,
                            IdCountPlan        = item.IdCountPlan,
                            Name               = item.Name,
                            Description        = item.Description,
                            ProductCode        = item.ProductCode,
                            Quantity           = item.Quantity,
                            TotalCounted       = item.TotalCounted,
                            BarCode            = item.BarCode,
                            ProductDescription = item.ProductDescription,
                            TotalProduct       = item.TotalProduct,
                            HasDetails         = (item.TotalProduct > 0) ? "Images/check.png" : "Images/uncheck.png",
                            ProductOk          = (item.Quantity <= item.TotalProduct) ? "Images/yes.png" : "Images/no.png"
                        }));

                        if (list.Count() > 0)
                        {
                            PlanName        = result.Listrows.FirstOrDefault().Name;
                            PlanDescription = result.Listrows.FirstOrDefault().Name + " " + result.Listrows.FirstOrDefault().Description;
                        }


                        ItemsCount = result.Count;
                        NumberPage = 1;

                        if (ItemsCount > 10)
                        {
                            decimal valueItemscount    = Convert.ToDecimal(ItemsCount);
                            decimal valueItemsperpages = Convert.ToDecimal(ITEM_PER_PAGE);
                            decimal valueResult        = Math.Ceiling(valueItemscount / valueItemsperpages);

                            TotalPage = Convert.ToInt32(valueResult);

                            MsgPage = Convert.ToString(NumberPage) + " / " + Convert.ToString(TotalPage);
                            IsPage  = true;
                        }


                        Details = new ObservableCollection <ViewCountPlanDetailExtend>(list);
                    });
                }
            });
        }