/*
         * public DelegateCommand ItemTappedCommand { get; }
         * private async void OnItemTappedCommandExecuted()
         * {
         *
         * }
         */
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            try
            {
                if (InventoryViabilityRuleList == null)
                {
                    InventoryViabilityRuleList = await _restService.SearchInventoryViabilityRuleAsync("@inventory_viability_rule.inventory_viability_rule_id > 0", null, "inventory_viability_rule");
                }

                if (parameters.ContainsKey("InventoryViability") && InventoryViabilityList != null)
                {
                    WrappedSelection <InventoryViability> newInventoryViability = new WrappedSelection <InventoryViability>
                    {
                        IsSelected = true,
                        Item       = (InventoryViability)parameters["InventoryViability"]
                    };
                    SelectedInventoryViability = null;

                    WrappedSelection <InventoryViability> temp = _inventoryViabilityList.FirstOrDefault(x => x.Item.InventoryViabilityId == newInventoryViability.Item.InventoryViabilityId);
                    if (temp != null)
                    {
                        InventoryViabilityList.Remove(temp);
                    }
                    InventoryViabilityList.Add(newInventoryViability);

                    InventoryViabilityList = new ObservableCollection <WrappedSelection <InventoryViability> >(
                        InventoryViabilityList.OrderByDescending(x => x.Item.TestedDate).Select(
                            item => new WrappedSelection <InventoryViability> {
                        IsSelected = item.IsSelected, Item = item.Item
                    })
                        );

                    SelectedInventoryViability = newInventoryViability;
                    //SelectedInventoryViability.IsSelected = true;
                }
            }
            catch (Exception ex)
            {
                await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "OK");
            }
        }
Example #2
0
        private async void OnSelectItemCommand(Object param)
        {
            try
            {
                WrappedSelection <InventoryThumbnail> listItem = (WrappedSelection <InventoryThumbnail>)param;
                if (listItem != null)
                {
                    listItem.IsSelected = !listItem.IsSelected;
                }

                if (listItem.IsSelected)
                {
                    SelectedRowsCount++;
                }
                else
                {
                    SelectedRowsCount--;
                }
            }
            catch (Exception ex)
            {
                await PageDialogService.DisplayAlertAsync("Error", ex.Message, "OK");
            }
        }
Example #3
0
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            try
            {
                if (_dataviewColumnList == null)
                {
                    _dataviewColumnList = await _restClient.GetDataviewAtributeList(Settings.WorkgroupInventoryThumbnailDataview);

                    if (_dataviewColumnList != null)
                    {
                        if (_dataviewColumnList.Count > 1)
                        {
                            Header1 = _dataviewColumnList[1].title;
                        }
                        if (_dataviewColumnList.Count > 2)
                        {
                            Header2 = _dataviewColumnList[2].title;
                        }
                        if (_dataviewColumnList.Count > 3)
                        {
                            Header3 = _dataviewColumnList[3].title;
                        }
                        if (_dataviewColumnList.Count > 4)
                        {
                            Header4 = _dataviewColumnList[4].title;
                        }
                        if (_dataviewColumnList.Count > 5)
                        {
                            Header5 = _dataviewColumnList[5].title;
                        }
                        if (_dataviewColumnList.Count > 6)
                        {
                            Header6 = _dataviewColumnList[6].title;
                        }
                        if (_dataviewColumnList.Count > 7)
                        {
                            Header7 = _dataviewColumnList[7].title;
                        }
                    }
                }

                if (parameters.ContainsKey("inventory")) //Update UI
                {
                    InventoryThumbnail tempInventory = (InventoryThumbnail)parameters["inventory"];
                    WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == tempInventory.inventory_id);
                    if (inventoryThumbnailItem == null)
                    {
                        InventoryList.Add(new WrappedSelection <InventoryThumbnail> {
                            Item = tempInventory, IsSelected = false
                        });
                    }
                    else
                    {
                        inventoryThumbnailItem.Item = tempInventory;

                        /*
                         * int index = InventoryList.IndexOf(inventoryThumbnailItem);
                         * InventoryList.Remove(inventoryThumbnailItem);
                         * InventoryList.Insert(index, new WrappedSelection<InventoryThumbnail> { Item = tempInventory, IsSelected = false });
                         */
                    }
                }

                if (parameters.ContainsKey("InventoryThumbnail"))
                {
                    InventoryThumbnail tempInventory = (InventoryThumbnail)parameters["InventoryThumbnail"];
                    WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == tempInventory.inventory_id);
                    if (inventoryThumbnailItem == null)
                    {
                        InventoryList.Add(new WrappedSelection <InventoryThumbnail> {
                            Item = tempInventory, IsSelected = false
                        });
                    }
                    else
                    {
                        inventoryThumbnailItem.Item = tempInventory;
                    }

                    AccessionCount = InventoryList.Select(i => i.Item.AccessionNumber).Distinct().Count();
                    TotalQuantity  = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum();
                }

                if (parameters.ContainsKey("InventoryThumbnailList"))
                {
                    List <InventoryThumbnail> inventoryList = (List <InventoryThumbnail>)parameters["InventoryThumbnailList"];

                    foreach (var inventoryThumbnail in inventoryList)
                    {
                        var wrappedInventory = InventoryList.FirstOrDefault(x => x.Item.inventory_id == inventoryThumbnail.inventory_id);
                        if (wrappedInventory == null)
                        {
                            WrappedSelection <InventoryThumbnail> temp = new WrappedSelection <InventoryThumbnail>()
                            {
                                Item = inventoryThumbnail, IsSelected = false
                            };
                            InventoryList.Add(temp);
                        }
                        else
                        {
                            wrappedInventory.Item = inventoryThumbnail;

                            /*int index = _inventoryList.IndexOf(wrappedInventory);
                             * InventoryList.Remove(wrappedInventory);
                             * InventoryList.Insert(index, new WrappedSelection<InventoryThumbnail> { Item = inventoryThumbnail, IsSelected = wrappedInventory.IsSelected });*/
                        }
                    }

                    AccessionCount = InventoryList.Select(i => i.Item.AccessionNumber).Distinct().Count();
                    TotalQuantity  = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum();
                }
            }
            catch (Exception ex)
            {
                await PageDialogService.DisplayAlertAsync("Error", ex.Message, "OK");
            }
        }
        public override async void OnNavigatedTo(INavigationParameters parameters)
        {
            try
            {
                if (parameters.ContainsKey("inventoryList"))
                {
                    List <InventoryThumbnail> inventoryList = (List <InventoryThumbnail>)parameters["inventoryList"];

                    foreach (var inventoryThumbnail in inventoryList)
                    {
                        var wrappedInventory = InventoryList.FirstOrDefault(x => x.Item.inventory_id == inventoryThumbnail.inventory_id);
                        if (wrappedInventory == null)
                        {
                            WrappedSelection <InventoryThumbnail> temp = new WrappedSelection <InventoryThumbnail>()
                            {
                                Item = inventoryThumbnail, IsSelected = false
                            };
                            InventoryList.Add(temp);
                        }
                        else
                        {
                            int index = _inventoryList.IndexOf(wrappedInventory);
                            InventoryList.Remove(wrappedInventory);
                            InventoryList.Insert(index, new WrappedSelection <InventoryThumbnail> {
                                Item = inventoryThumbnail, IsSelected = wrappedInventory.IsSelected
                            });
                        }
                    }

                    AccessionCount = InventoryList.Select(i => i.Item.accession_id).Distinct().Count();
                }
                if (parameters.ContainsKey("InventoryThumbnail"))
                {
                    InventoryThumbnail inventoryThumbnail = (InventoryThumbnail)parameters["InventoryThumbnail"];

                    WrappedSelection <InventoryThumbnail> inventoryThumbnailItem = _inventoryList.FirstOrDefault(item => item.Item.inventory_id == inventoryThumbnail.inventory_id);
                    if (inventoryThumbnailItem == null)
                    {
                        InventoryList.Add(new WrappedSelection <InventoryThumbnail> {
                            Item = inventoryThumbnail, IsSelected = false
                        });
                    }
                    else
                    {
                        int index = InventoryList.IndexOf(inventoryThumbnailItem);
                        InventoryList.Remove(inventoryThumbnailItem);
                        InventoryList.Insert(index, new WrappedSelection <InventoryThumbnail> {
                            Item = inventoryThumbnail, IsSelected = false
                        });
                    }
                }
                if (parameters.ContainsKey("message"))
                {
                    await _pageDialogService.DisplayAlertAsync("Message", (string)parameters["message"], "OK");
                }
            }
            catch (Exception ex)
            {
                await _pageDialogService.DisplayAlertAsync("Error", ex.Message, "OK");
            }
        }