예제 #1
0
        private void ChangeStorage(StorageItemQuantityResult storageItem, StorageItemQuantityListViewAdapter adapter)
        {
            var storages = Database.GetStorageNames();

            if (storages.Count == 0)
            {
                return;
            }

            storages.Insert(0, "[Kein Lagerort]");

            AlertDialog.Builder dialog = new AlertDialog.Builder(this);
            dialog.SetTitle("Lagerort auswählen");
            dialog.SetItems(storages.ToArray(), (sender, args) =>
            {
                if (args.Which == 0)
                {
                    storageItem.StorageName = null;
                }
                else
                {
                    storageItem.StorageName = storages[args.Which];
                }
                storageItem.IsChanged = true;
                adapter.NotifyDataSetChanged();
                return;
            });
            dialog.Show();
        }
예제 #2
0
        private void SetEditMode(bool editMode)
        {
            this.isEditMode = editMode;

            this.InvalidateOptionsMenu();

            ListView listView = FindViewById <ListView>(Resource.Id.ArticleList);
            StorageItemQuantityListViewAdapter adapter = listView.Adapter as StorageItemQuantityListViewAdapter;

            if (editMode)
            {
                FindViewById(Resource.Id.StorageItemQuantity_Storage).Visibility = ViewStates.Visible;
                FindViewById(Resource.Id.StorageItemQuantity_Step).Visibility    = ViewStates.Visible;
                adapter.ActivateButtons();
                this.Window.SetSoftInputMode(SoftInput.StateHidden);
            }
            else
            {
                FindViewById(Resource.Id.StorageItemQuantity_Storage).Visibility = ViewStates.Gone;
                FindViewById(Resource.Id.StorageItemQuantity_Step).Visibility    = ViewStates.Gone;
                adapter.DeactivateButtons();
            }

            listView.InvalidateViews();
        }
예제 #3
0
        private void ChangeQuantity(StorageItemQuantityResult storageItem, StorageItemQuantityListViewAdapter adapter)
        {
            var dialog = new AlertDialog.Builder(this);

            dialog.SetMessage("Anzahl eingeben:");
            EditText input = new EditText(this);

            input.InputType = InputTypes.ClassNumber | InputTypes.NumberFlagDecimal;

            if (storageItem.Quantity > 0)
            {
                input.Text = storageItem.Quantity.ToString();
            }
            input.SetSelection(input.Text.Length);
            dialog.SetView(input);
            dialog.SetPositiveButton("OK", (sender, whichButton) =>
            {
                if (string.IsNullOrEmpty(input.Text))
                {
                    input.Text = "0";
                }

                decimal neueAnzahl = 0;

                bool decialOk = Decimal.TryParse(input.Text, NumberStyles.Any, CultureInfo.InvariantCulture, out neueAnzahl);
                if (decialOk)
                {
                    storageItem.Quantity  = neueAnzahl;
                    storageItem.IsChanged = true;
                    adapter.NotifyDataSetChanged();
                }
            });
            dialog.SetNegativeButton("Cancel", (s, e) => {});
            dialog.Show();
        }
예제 #4
0
        private void ChangeBestBeforeDate(StorageItemQuantityResult storageItem, StorageItemQuantityListViewAdapter adapter)
        {
            DateTime?date = storageItem.BestBefore;

            // Haltbarkeitsdatum erfassen (kann aber auch weggelassen werden)
            storageItem.IsChanged = true;
            adapter.NotifyDataSetInvalidated();


            if (!UseAltDatePicker)
            {
                DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime? time)
                {
                    if (time.HasValue)
                    {
                        storageItem.BestBefore = time.Value;
                    }
                    else
                    {
                        storageItem.BestBefore = null;
                    }

                    storageItem.IsChanged = true;
                    adapter.NotifyDataSetInvalidated();

                    if (this.quantity > 0)
                    {
                        this.ChangeQuantity(storageItem, adapter);
                    }
                }, date);
                frag.ShowsDialog = true;
                frag.Show(FragmentManager, DatePickerFragment.TAG);
            }
            else
            {
                AltDatePickerFragment frag = AltDatePickerFragment.NewInstance(delegate(DateTime? time)
                {
                    if (time.HasValue)
                    {
                        storageItem.BestBefore = time.Value;
                    }
                    else
                    {
                        storageItem.BestBefore = null;
                    }

                    storageItem.IsChanged = true;
                    adapter.NotifyDataSetInvalidated();

                    if (this.quantity > 0)
                    {
                        this.ChangeQuantity(storageItem, adapter);
                    }
                }, date);
                frag.ShowsDialog = true;
                frag.Show(FragmentManager, AltDatePickerFragment.TAG);
            }
        }
예제 #5
0
        private void ShowStorageListForArticle(int articleId)
        {
            StorageItemQuantityActivity.liste = new List <StorageItemQuantityListView>();

            var storageItemQuantityList = Database.GetStorageItemQuantityList(articleId);

            foreach (StorageItemQuantityResult storegeItem in storageItemQuantityList)
            {
                StorageItemQuantityListView item = new StorageItemQuantityListView(storegeItem);

                StorageItemQuantityActivity.liste.Add(item);
            }

            StorageItemQuantityListViewAdapter listAdapter = new StorageItemQuantityListViewAdapter(this, StorageItemQuantityActivity.liste);
            ListView listView = FindViewById <ListView>(Resource.Id.ArticleList);

            listView.Adapter = listAdapter;

            listAdapter.ItemClicked += ListAdapter_ItemClicked;
        }