Exemple #1
0
        private void btnChangeColor_Click(object sender, RoutedEventArgs e)
        {
            var car = _cars?.FirstOrDefault(x => x.CarId == ((Inventory)cboCars.SelectedItem)?.CarId);

            if (car != null)
            {
                car.Color = "Pink";
            }
        }
Exemple #2
0
        private async Task OnRemoveInventory(object param)
        {
            if (param is Inventory)
            {
                await inventoryRepo.DeleteInventoryAsync((param as Inventory).Id);

                InventoryList.Remove(InventoryList.FirstOrDefault(x => x.Id == (param as Inventory).Id));
                alertService.Show("Usuwanie towaru", $"Usunięto towar {(param as Inventory).Name}", "Zamknij");
            }
        }
    static bool CanAddProduct(int itemId, int storeId)
    {
        var inventory = InventoryList.FirstOrDefault(t => t.ItemId == itemId && t.StoreId == storeId);

        if (inventory == null)
        {
            throw new ApplicationException("No such product in inventory");
        }
        var stock = StockList.Where(st => st.ItemId == itemId &&
                                    st.Quantity < inventory.Quantity && st.StoreId == storeId);

        if (stock.Any())
        {
            Console.WriteLine("You can't add ItemId={0}. You have The minimum stock", itemId);
            return(false);
        }
        Console.WriteLine("You can add ItemId={0}", itemId);
        return(true);
    }
Exemple #4
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");
            }
        }