コード例 #1
0
        private void AddArticleWithQuantity()
        {
            var storageName = FindViewById <EditText>(Resource.Id.StorageItemQuantity_StorageText).Text;

            StorageItemQuantityResult storageItemQuantity = new StorageItemQuantityResult();

            storageItemQuantity.ArticleId   = this.articleId;
            storageItemQuantity.Quantity    = (decimal)this.quantity;
            storageItemQuantity.BestBefore  = DateTime.Today;
            storageItemQuantity.StorageName = storageName;
            storageItemQuantity.IsChanged   = true;

            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)
            {
                storageItemQuantity.BestBefore = null;

                if (this.quantity > 0)
                {
                    this.ChangeQuantity(storageItemQuantity, adapter);
                }
                return;
            }

            this.ChangeBestBeforeDate(storageItemQuantity, adapter);
        }
コード例 #2
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();
        }
コード例 #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
 internal void AddStorageItem(StorageItemQuantityResult storegeItem)
 {
     this.count++;
     this.quantity += storegeItem.Quantity;
     this.AddUnitQuantity(storegeItem.Unit, storegeItem.Size, storegeItem.Quantity);
     this.AddCalorie(storegeItem.Quantity, storegeItem.Calorie);
     this.AddCosts(storegeItem.Quantity, storegeItem.Price);
 }
コード例 #5
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);
            }
        }
コード例 #6
0
 public StorageItemListView(StorageItemQuantityResult storageItem)
 {
     this.StorageItem = storageItem;
 }
コード例 #7
0
        internal static void UpdateStorageItemQuantity(StorageItemQuantityResult storageItem)
        {
            SQLite.SQLiteConnection databaseConnection = Android_Database.Instance.GetConnection();
            if (databaseConnection == null)
            {
                return;
            }

            string        cmd = string.Empty;
            SQLiteCommand command;

            int defaultStorageId = 1;

            if (storageItem.StorageItemId == 0)
            {
                // Neuanlage, aber Menge = 0
                if (storageItem.Quantity == 0)
                {
                    return;
                }

                TRACE("Lagerposition Neuanlage: {0}, {1}, {2}", storageItem.Quantity, storageItem.BestBefore_DebuggerDisplay, storageItem.StorageName);
                cmd    += "INSERT INTO StorageItem (StorageId, ArticleId, Quantity, BestBefore, StorageName) VALUES (?, ?, ?, ?, ?)";
                command = databaseConnection.CreateCommand(cmd, new object[]
                {
                    defaultStorageId,
                    storageItem.ArticleId,
                    storageItem.Quantity,
                    storageItem.BestBefore,
                    storageItem.StorageName
                });

                command.ExecuteNonQuery();

                // Neue Lagerposition-Id übernehmen.
                command = databaseConnection.CreateCommand("SELECT last_insert_rowid()");
                storageItem.StorageItemId = command.ExecuteScalar <int>();
            }
            else
            {
                if (storageItem.Quantity == 0)
                {
                    TRACE("Lagerposition Löschung: {0}, {1}, {2}", storageItem.StorageItemId, storageItem.BestBefore_DebuggerDisplay, storageItem.StorageName);
                    cmd    += "DELETE FROM StorageItem WHERE StorageItemId = ?";
                    command = databaseConnection.CreateCommand(cmd, new object[] { storageItem.StorageItemId });
                    storageItem.StorageItemId = 0;
                }
                else
                {
                    TRACE("Lagerposition Änderung: {0}, {1}, {2}", storageItem.Quantity, storageItem.BestBefore_DebuggerDisplay, storageItem.StorageName);
                    cmd    += "UPDATE StorageItem SET Quantity = ?, BestBefore = ?, StorageName = ? WHERE StorageItemId = ?";
                    command = databaseConnection.CreateCommand(cmd, new object[]
                    {
                        storageItem.Quantity,
                        storageItem.BestBefore,
                        storageItem.StorageName,
                        storageItem.StorageItemId
                    });
                }
                command.ExecuteNonQuery();
            }
        }
コード例 #8
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();
            }
        }
コード例 #9
0
 public StorageItemQuantityListView(StorageItemQuantityResult storageItem) : base(storageItem)
 {
 }