private async void cmdEdit_Clicked(object sender, EventArgs e)
        {
            if (lstInventoryItems.SelectedItem == null)
            {
                await App.Current.MainPage.DisplayAlert("Error", "No item selected", "OK");

                return;
            }

            updateType = UpdateType.Update;
            InventoryItem item = (InventoryItem)lstInventoryItems.SelectedItem;

            InventoryItem = new InventoryItemDetailViewModel()
            {
                InventoryItemId     = item.InventoryItemId,
                Name                = item.Name,
                Description         = item.Description,
                Barcode             = item.Barcode,
                Price               = item.Price,
                InventoryGroupIdRef = item.InventoryGroupIdRef,
            };
            gridAddEdit.BindingContext = InventoryItem;
            pickGroup.ItemsSource      = groups;
            DetermineSelectedIndex(InventoryItem, pickGroup);

            gridInventoryItemList.IsVisible = false;
            gridAddEdit.IsVisible           = true;
        }
        private void cmdAdd_Clicked(object sender, EventArgs e)
        {
            updateType    = UpdateType.Add;
            InventoryItem = new InventoryItemDetailViewModel();
            gridAddEdit.BindingContext = InventoryItem;
            pickGroup.ItemsSource      = groups;

            gridInventoryItemList.IsVisible = false;
            gridAddEdit.IsVisible           = true;
        }
Esempio n. 3
0
        public async Task <ObservableCollection <InventoryItemDetailViewModel> > GetinventoryItems()
        {
            if (items.Count == 0)
            {
                DCEMVDemoServerClient client = SessionSingleton.GenDCEMVServerApiClient();
                using (SessionSingleton.HttpClient)
                {
                    ObservableCollection <string> list = await client.StoreInventoryitemsGetAsync();

                    ObservableCollection <InventoryItemDetailViewModel> listRet = new ObservableCollection <InventoryItemDetailViewModel>();
                    list.ToList().ForEach(z =>
                    {
                        InventoryItem x = InventoryItem.FromJsonString(z);
                        InventoryItemDetailViewModel ivm = new InventoryItemDetailViewModel()
                        {
                            Barcode             = x.Barcode,
                            Description         = x.Description,
                            InventoryGroupIdRef = x.InventoryGroupIdRef,
                            InventoryItemId     = x.InventoryItemId,
                            Name  = x.Name,
                            Price = x.Price,
                        };
                        listRet.Add(ivm);
                    });

                    if (list == null)
                    {
                        return(items);
                    }
                    else
                    {
                        items = listRet;
                    }
                }
            }

            return(items);
        }