예제 #1
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);
            }
        }
예제 #2
0
        public static DatePickerFragment NewInstance(Action <DateTime?> onDateSelected, DateTime?date)
        {
            DatePickerFragment frag = new DatePickerFragment();

            if (date.HasValue)
            {
                frag.Date = date.Value.AddMonths(-1);
            }
            frag.DateSelectedHandler = onDateSelected;
            return(frag);
        }
예제 #3
0
        private void AddArticle_Click(object sender, EventArgs e)
        {
            var storageName = FindViewById <EditText>(Resource.Id.StorageItemQuantity_StorageText).Text;

            StorageItemQuantityResult storageItemQuantity = new StorageItemQuantityResult();

            storageItemQuantity.ArticleId   = this.articleId;
            storageItemQuantity.Quantity    = 1;
            storageItemQuantity.BestBefore  = DateTime.Today;
            storageItemQuantity.StorageName = storageName;
            storageItemQuantity.IsChanged   = true;

            if (this.quantity > 1)
            {
                storageItemQuantity.Quantity = (decimal)this.quantity;
            }

            StorageItemQuantityListView itemView = new StorageItemQuantityListView(storageItemQuantity);

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

            adapter.Add(itemView);
            listView.InvalidateViews();

            if (!this.durableInfinity)
            {
                // Haltbarkeitsdatum erfassen (kann aber auch weggelassen werden)
                listView.InvalidateViews();
                if (!UseAltDatePicker)
                {
                    DatePickerFragment frag = DatePickerFragment.NewInstance(delegate(DateTime? time)
                    {
                        if (time.HasValue)
                        {
                            storageItemQuantity.BestBefore = time.Value;
                        }
                        else
                        {
                            storageItemQuantity.BestBefore = null;
                        }

                        listView.InvalidateViews();

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

                        listView.InvalidateViews();

                        if (this.quantity > 0)
                        {
                            this.ChangeQuantity(storageItemQuantity, adapter);
                        }
                    }, DateTime.Today);
                    frag.ShowsDialog = true;
                    frag.Show(FragmentManager, AltDatePickerFragment.TAG);
                }
            }
            else
            {
                // Ist ohne Haltbarkeitsdatum (unendlich haltbar)
                // Datum muss nicht erfasst werden.
                storageItemQuantity.BestBefore = null;
                listView.InvalidateViews();
            }
        }