private void OnRemoveCommandExecuted()
 {
     for (int i = _inventoryList.Count - 1; i >= 0; i--)
     {
         if (_inventoryList[i].IsSelected)
         {
             _inventoryList.RemoveAt(i);
         }
     }
     AccessionCount = InventoryList.Select(i => i.Item.accession_id).Distinct().Count();
 }
Пример #2
0
 private void OnAddItemToList(InventoryThumbnail inventory)
 {
     if (_inventoryList.Any(i => i.Item.inventory_id == inventory.inventory_id))
     {
         Device.BeginInvokeOnMainThread(() => {
             PageDialogService.DisplayAlertAsync("Warnning", "Inventory exists in list", "OK");
         });
     }
     else
     {
         _inventoryList.Add(new WrappedSelection <InventoryThumbnail>()
         {
             IsSelected = false, Item = inventory
         });
         AccessionCount = InventoryList.Select(i => i.Item.AccessionNumber).Distinct().Count();
         TotalQuantity  = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum();
     }
 }
Пример #3
0
        private void OnRemoveCommandExecuted()
        {
            for (int i = _inventoryList.Count - 1; i >= 0; i--)
            {
                if (_inventoryList[i].IsSelected)
                {
                    _inventoryList.RemoveAt(i);
                }
            }

            if (IsAllSelected)
            {
                IsAllSelected = false;
            }

            SelectedRowsCount = 0;
            AccessionCount    = InventoryList.Select(i => i.Item.AccessionNumber).Distinct().Count();
            TotalQuantity     = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum();
        }
Пример #4
0
        public InventoriesPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IEventAggregator eventAggregator)
            : base(navigationService, pageDialogService)
        {
            Title = "Inventory list";

            _restClient = new RestClient();
            //_inventoryCollection = new ObservableCollection<InventoryThumbnail>(InventoryFactory.GetInventories());
            _inventoryList = new ObservableCollection <WrappedSelection <InventoryThumbnail> >();

            /*
             * foreach (var inventory in InventoryFactory.GetInventories())
             * {
             *  _inventoryList.Add(new WrappedSelection<InventoryThumbnail>() { Item = inventory, IsSelected = false });
             * }*/

            ItemTappedCommand = new DelegateCommand <Object>(OnItemTappedCommandExecuted);

            NewCommand    = new DelegateCommand(OnNewCommandExecuted);
            ScanCommand   = new DelegateCommand(OnScanCommand);
            SearchCommand = new DelegateCommand(OnSearchCommandExecuted);

            PrintCommand  = new DelegateCommand(OnPrintCommandExecuted);
            RemoveCommand = new DelegateCommand(OnRemoveCommandExecuted);

            RegisterTransactionCommand = new DelegateCommand(OnRegisterTransactionCommandExecuted);
            //UpdateAttributeBatchCommand = new DelegateCommand(OnUpdateAttributeBatchCommandExecuted);

            ChangeLocationCommand       = new DelegateCommand(OnChangeLocationCommandExecuted);
            ViewInventoryActionsCommand = new DelegateCommand(OnViewInventoryActionsCommand);
            SaveListCommand             = new DelegateCommand(OnSaveListCommand);

            SelectItemCommand = new DelegateCommand <Object>(OnSelectItemCommand);

            SelectedRowsCount = InventoryList.Count(i => i.IsSelected == true);
            AccessionCount    = InventoryList.Select(i => i.Item.accession_id).Distinct().Count();
            TotalQuantity     = _inventoryList.Select(i => i.Item.quantity_on_hand).Sum();

            eventAggregator.GetEvent <AddInventoryToListEvent>().Subscribe(OnAddItemToList);
        }
Пример #5
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");
            }
        }