//populate list
 private async void populateItemsList(View view, int sId)
 {
     try
     {
         sItems             = ShoppingCollection.GetShoppingItems(sId);
         adapter            = new ShoppingItemsAdapter(view.Context, sItems);
         mListItems.Adapter = adapter;
     }
     catch (Exception ex)
     {
         Toast.MakeText(view.Context, "" + ex.Message, ToastLength.Long).Show();
     }
 }
Пример #2
0
        //save item
        private void CreateItem()
        {
            try
            {
                if (itemList.SelectedItemPosition <= -1)
                {
                    Toast.MakeText(this, "Select a shopping list!", ToastLength.Long).Show();
                    return;
                }
                if (itemName.Text.Equals("") || itemQty.Text.Equals("") || itemMse.Text.Equals("") || itemExpPrice.Text.Equals(""))
                {
                    Toast.MakeText(this, "Fill in all fields!", ToastLength.Long).Show();
                }
                else
                {
                    allLists = ShoppingCollection.GetShoppingLists();
                    DBHelper dbh = new DBHelper();

                    string  name     = DatabaseUtils.SqlEscapeString(itemName.Text);
                    int     list     = Convert.ToInt32(allLists[itemList.SelectedItemPosition].Id);
                    decimal qty      = Convert.ToDecimal(itemQty.Text);
                    string  measure  = DatabaseUtils.SqlEscapeString(itemMse.Text);
                    decimal expPrice = Convert.ToDecimal(itemExpPrice.Text);

                    string result = dbh.CreateShoppingItem(name, list, qty, measure, expPrice);

                    if (result.Equals("ok"))
                    {
                        Toast.MakeText(this, "Item added!", ToastLength.Short).Show();
                        Finish();
                    }
                    else
                    {
                        Toast.MakeText(this, result, ToastLength.Short).Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, "Error:\n" + ex.Message, ToastLength.Long);
            }
        }
Пример #3
0
        //check if goal near deadline
        public void CheckUpdate()
        {
            DateTime current = DateTime.Now;
            int      z       = ShoppingCollection.CheckItem(current).Count;

            Console.WriteLine("Shopping service: " + z);

            //Toast.MakeText(this, "Shopping lists count: " + z, ToastLength.Long).Show();

            //while (i < z)
            //{
            //    string title = ShoppingCollection.CheckItem(current)[i].ListTitle;

            //    Toast.MakeText(this, "Shopping lists today: " + title, ToastLength.Long).Show();
            //}

            Thread t = new Thread(() =>
            {
                Thread.Sleep(1000);
                if (ShoppingCollection.CheckItem(DateTime.Now).Count > 0)
                {
                    var nMgr = (NotificationManager)GetSystemService(NotificationService);

                    //Details of notification in previous recipe
                    Notification.Builder builder = new Notification.Builder(this)
                                                   .SetAutoCancel(true)
                                                   .SetContentTitle("Shopping Day")
                                                   .SetNumber(notifyId)
                                                   .SetContentText("You have got some shopping to do today.")
                                                   .SetVibrate(new long[] { 100, 200, 300 })
                                                   .SetSmallIcon(Resource.Drawable.ic_cart);

                    nMgr.Notify(0, builder.Build());
                }
            });

            t.Start();
        }
Пример #4
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Get layout for this activity
            SetContentView(Resource.Layout.AddShoppingItem);

            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            itemList     = FindViewById <Spinner>(Resource.Id.spinItemList);
            itemName     = FindViewById <EditText>(Resource.Id.txtShopItemName);
            itemQty      = FindViewById <EditText>(Resource.Id.txtShopItemQty);
            itemMse      = FindViewById <EditText>(Resource.Id.txtShopItemMeasure);
            itemExpPrice = FindViewById <EditText>(Resource.Id.itemExpPrice);

            allLists         = ShoppingCollection.SpinnerLists();
            adapter          = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, allLists);
            itemList.Adapter = adapter;
        }
 //populate list
 private async void populateShoppingList(View view)
 {
     lists             = ShoppingCollection.GetShoppingLists();
     adapter           = new ShoppingAdapter(view.Context, lists);
     mShopList.Adapter = adapter;
 }