Esempio n. 1
0
        public MainWindow()
        {
            InitializeComponent();

            Canvas.SetLeft(AntHill, (1400 - 20) / 2);
            Canvas.SetTop(AntHill, (800 - 20) / 2);

            for (int i = 0; i < 40; i++)
            {
                Thread.Sleep(30);
                var ant = new Ant();
                Ants.Add(ant);
                Canvas.Children.Add(ant);

                for (int j = 0; j < 5; j++)
                {
                    Thread.Sleep(30);
                    var food = new Food();
                    FoodItems.Add(food);
                    Canvas.Children.Add(food);
                }
            }

            RunLooper();
        }
Esempio n. 2
0
        //DELETE FoodItem
        public void DeleteItem(int id)
        {
            FoodItems i = context.FoodItems.FirstOrDefault(e => e.ItemID == id);

            context.FoodItems.Remove(i);
            context.SaveChanges();
        }
Esempio n. 3
0
        public List <FoodItems> GetFoodItemDetails(int iVendorId)
        {
            string           strQuery     = string.Format(SQLCMD.SELECT_FOOD_ITEMS, iVendorId);
            List <FoodItems> lstFoodItems = new List <FoodItems>();

            sqlConn.Open();
            using (SqlCommand sqlCmd = new SqlCommand(strQuery, sqlConn))
            {
                sqlCmd.CommandType = CommandType.Text;
                using (SqlDataReader sqlReader = sqlCmd.ExecuteReader())
                {
                    while (sqlReader.Read())
                    {
                        FoodItems objFoodItems = new FoodItems();
                        objFoodItems.FoodItemId    = Convert.ToInt32(sqlReader["FoodItemId"]);
                        objFoodItems.FoodItemName  = sqlReader["FoodItemName"].ToString();
                        objFoodItems.FoodItemPrice = Convert.ToDouble(sqlReader["FoodItemPrice"]);
                        objFoodItems.TaxPercentage = Convert.ToDouble(sqlReader["TaxPercentage"]);
                        lstFoodItems.Add(objFoodItems);
                    }
                }
            }
            sqlConn.Close();
            return(lstFoodItems);
        }
Esempio n. 4
0
 public void AddItem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (foodnametxt.Text == "" || Descriptiontxt.Text == "" || pricetxt.Text == "")
         {
             status.Foreground = Brushes.Red;
             status.Content    = "Усі поля обов'язкові.";
         }
         else
         {
             _rVmObj = new RestaurantViewModel();
             FoodItems fooditem = new FoodItems();
             fooditem.FoodName    = foodnametxt.Text;
             fooditem.Description = Descriptiontxt.Text;
             fooditem.fPrice      = Convert.ToInt32(pricetxt.Text.ToString());
             _rVmObj.AddFoodItem(fooditem);
             DataContext       = new RestaurantViewModel();
             status.Foreground = Brushes.Green;
             status.Content    = "Страва успішно додана.";
         }
     }
     catch (Exception exp)
     {
         status.Foreground = Brushes.Red;
         status.Content    = "Введіть значення.";
     }
 }
        public void AddFoodItem(FoodItem item)
        {
            var quantityType = HKQuantityType.GetQuantityType(HKQuantityTypeIdentifierKey.DietaryEnergyConsumed);
            var quantity     = HKQuantity.FromQuantity(HKUnit.Joule, item.Joules);

            var now = NSDate.Now;

            var metadata       = new NSDictionary(HKMetadataKey.FoodType, item.Name);
            var caloriesSample = HKQuantitySample.FromType(quantityType, quantity, now, now, metadata);

            HealthStore.SaveObject(caloriesSample, (success, error) => {
                if (success)
                {
                    FoodItems.Insert(item, 0);
                    var indexPathForInsertedFoodItem = NSIndexPath.FromRowSection(0, 0);
                    InvokeOnMainThread(() => {
                        TableView.InsertRows(new NSIndexPath[] { indexPathForInsertedFoodItem }, UITableViewRowAnimation.Automatic);
                    });
                }
                else
                {
                    Console.WriteLine("An error occured saving the food {0}. In your app, try to handle this gracefully. " +
                                      "The error was: {1}.", item.Name, error);
                }
            });
        }
Esempio n. 6
0
        private void btnAddItem_Click(object sender, EventArgs e)
        {
            if (txtAddFoodItem.Text != "" && !act.GetAllitemName().Contains(txtAddFoodItem.Text))
            {
                FoodItems i = new FoodItems();

                i.ItemName = txtAddFoodItem.Text;
                int  id;
                bool result = int.TryParse(cmbCAtShow.SelectedValue.ToString(), out id);
                i.CatId = id;
                if (txtSmallPrice.Value > 0 || txtLargePrice.Value > 0 || txtMidPrice.Value > 0)
                {
                    i.small      = 1;
                    i.smallprice = txtSmallPrice.Value;
                    i.mid        = 2;
                    i.midprice   = txtMidPrice.Value;
                    i.larg       = 3;
                    i.largeprice = txtLargePrice.Value;
                }
                else
                {
                    i.ItemPrice = txtAddPrice.Value;
                }
                act.AddItem(i);
                MakeTxtEmpty();

                lstFoodItems.DataSource    = act.GetAllFoodItems(int.Parse(cmbCAtShow.SelectedValue.ToString()));
                lstFoodItems.DisplayMember = "ItemName";
                lstFoodItems.ValueMember   = "ItemID";
            }
            else
            {
                MessageBox.Show("text is empty or cat is exist");
            }
        }
Esempio n. 7
0
            public virtual void Use()
            {
                Console.WriteLine("What do you want to consume?");
                Inventory.MyInventory();
                string ConsumeItem = Convert.ToString(Console.ReadLine());

                if (FoodItems.ContainsKey(ConsumeItem))
                {
                    Console.WriteLine("You eat " + ConsumeItem);
                    Inventory.MyItems.Remove(ConsumeItem);
                }
                else if (DrinkItems.Equals(ConsumeItem))
                {
                    Console.WriteLine("You drink " + ConsumeItem);
                    Inventory.MyItems.Remove(ConsumeItem);
                }
                else if (SnackItems.Equals(ConsumeItem))
                {
                    Console.WriteLine("You snack on " + ConsumeItem);
                    Inventory.MyItems.Remove(ConsumeItem);
                }
                else
                {
                    Console.WriteLine("you don't have the item in your inventory.");
                }
                //Jämnför input med vad som finns i dictionaries. Stämmer det så ska den ge tillbaka en string beroende på vilken dictionary som ger "true". Ta bort saken från inventory.
            }
Esempio n. 8
0
        private async void ExecuteLoadProductsCommand()
        {
            IsBusy = true;
            try
            {
                FoodItems.Clear();
                IEnumerable <Product> products = await productExampleDB.GetAllProductsAsync();

                FoodItems = new ObservableCollection <Food>();
                foreach (var item in products)
                {
                    if (item is Food)
                    {
                        FoodItems.Add((Food)item);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 9
0
    IEnumerator ExchangeAndMatch(FoodItems _item1, FoodItems _item2)
    {
        // Run the exchange function
        Exchange(_item1, _item2);

        // Wait till it move to the right position and run
        yield return(new WaitForSeconds(.3f));

        if (CheckHorizontalMatch() || CheckVerticalMatch())
        {
            // Remove the food that match and drop down new food
            RemoveMatchFood();
            yield return(new WaitForSeconds(.6f));

            DropDownNewFood();

            // Reset the match food arraylist after remove
            matchFoods = new List <FoodItems>();

            // Check the new spawn food is match
            yield return(new WaitForSeconds(.6f));

            StartCoroutine(AutoMatch());
        }
        else
        {
            // If it didn't match, then move the 2 food back to its position
            Exchange(_item1, _item2);
        }
    }
Esempio n. 10
0
    private void Update()
    {
        // If no food got clicked then dont run
        if (currentSelectFood == null)
        {
            return;
        }
        // If we are clicking but not selected any food then dont run
        if (Input.GetMouseButtonUp(0))
        {
            currentSelectFood = null;
            return;
        }

        //Input.touchCount == 1 && Input.touches[0].phase == TouchPhase.Moved
        // Give the mouse a moveing dir
        if (Input.GetMouseButton(0))
        {
            mouseMoveX = Input.GetAxis("Mouse X");
            mouseMoveY = Input.GetAxis("Mouse Y");
        }

        // If we move the mouse not far then dont run
        if (Mathf.Abs(mouseMoveX) < .3f && Mathf.Abs(mouseMoveY) < .3f)
        {
            return;
        }

        OnFoodMove();

        // Reset
        mouseMoveX = 0;
        mouseMoveY = 0;
    }
Esempio n. 11
0
    bool CheckVerticalMatch()
    {
        bool isMatch = false;

        // Loop all the food by vertical and see if they match
        for (int columIndex = 0; columIndex < Def.columCount; columIndex++)
        {
            for (int rowIndex = 0; rowIndex < Def.rowCount - 2; rowIndex++)
            {
                FoodItems item1 = GetFoodItems(rowIndex, columIndex);
                FoodItems item2 = GetFoodItems(rowIndex + 1, columIndex);
                FoodItems item3 = GetFoodItems(rowIndex + 2, columIndex);

                // If the type of food are all the same then its match
                if (item1.foodType == item2.foodType && item2.foodType == item3.foodType)
                {
                    isMatch = true;
                    AddMatchFood(item1);
                    AddMatchFood(item2);
                    AddMatchFood(item3);
                }
            }
        }
        return(isMatch);
    }
Esempio n. 12
0
 private void AddItem_Click(object sender, RoutedEventArgs e)//button add
 {
     if (!string.IsNullOrEmpty(fooditem.SelectedValue.ToString()) ||
         !string.IsNullOrEmpty(tableitem.SelectedValue.ToString()) || !string.IsNullOrEmpty(Quantitytxt.Text))
     {
         _vOrderItems          = new ViewOrderItems();
         _oVM                  = new OrderingViewModel();
         fooditemdata          = _oVM.getFoodDetail(Convert.ToInt32(fooditem.SelectedValue));
         _vOrderItems.Quantity = Convert.ToInt32(Quantitytxt.Text);
         _vOrderItems.Price    = fooditemdata.fPrice * _vOrderItems.Quantity;
         _vOrderItems.FoodID   = fooditemdata.FoodID;
         _vOrderItems.FoodName = fooditemdata.FoodName;
         _vOrderItems.TableID  = Convert.ToInt32(tableitem.SelectedValue);
         var createdOrder = _oVM.PlaceOrder(_vOrderItems);
         if (createdOrder != null)
         {
             mycart.Add(_vOrderItems);
             fooditemsgrid.ItemsSource = mycart;
             fooditemsgrid.Items.Refresh();
             status.Content = "Додано до списку замовлених страв";
         }
     }
     else
     {
         status.Foreground = Brushes.Red;
         status.Content    = "Всі поля обов'язкові для заповнення";
         status.Foreground = Brushes.Green;
     }
 }
Esempio n. 13
0
    void SetFoodItem(int rowIndex, int columIndex, FoodItems item)
    {
        // Return the food value we have when we want to exchange
        ArrayList temp = foodList[rowIndex] as ArrayList;

        temp[columIndex] = item;
    }
Esempio n. 14
0
    void OnFoodMove()
    {
        // If we are move the food to the left or right
        if (Mathf.Abs(mouseMoveX) > Mathf.Abs(mouseMoveY))
        {
            // Get the food we are moving and see witch way
            FoodItems targetItem = GetFoodItems(currentSelectFood.rowIndex, currentSelectFood.columIndex + (mouseMoveX > 0 ? 1 : -1));

            // If there is a item we clicked then exchange it
            if (targetItem != null)
            {
                StartCoroutine(ExchangeAndMatch(currentSelectFood, targetItem));
            }
            else
            {
                // If no then reset everything
                currentSelectFood = null;
            }
        }

        // Same but move up and down
        else if (Mathf.Abs(mouseMoveX) < Mathf.Abs(mouseMoveY))
        {
            FoodItems targetItem = GetFoodItems(currentSelectFood.rowIndex + (mouseMoveY > 0 ? 1 : -1), currentSelectFood.columIndex);
            if (targetItem != null)
            {
                StartCoroutine(ExchangeAndMatch(currentSelectFood, targetItem));
            }
            else
            {
                currentSelectFood = null;
            }
        }
    }
Esempio n. 15
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                FoodItems.Clear();
                var foodItems = await FoodDataStore.GetItemsAsync(true);

                foreach (var item in foodItems)
                {
                    FoodItems.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
 private void AddItem_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (foodnametxt.Text == "" || descriptiontxt.Text == "" || pricetxt.Text == "")
         {
             status.Foreground = Brushes.Red;
             status.Content    = "Alanlar boş bırakılamaz";
         }
         else
         {
             _rVmObj = new RestaurantViewModel();
             FoodItems fooditem = new FoodItems();
             fooditem.FoodName    = foodnametxt.Text;
             fooditem.Description = descriptiontxt.Text;
             fooditem.fPrice      = Convert.ToInt32(pricetxt.Text.ToString());
             _rVmObj.AddFoodItem(fooditem);
             DataContext       = new RestaurantViewModel();
             status.Foreground = Brushes.Green;
             status.Content    = "Ürün başarılı bir şekilde eklendi.";
         }
     }
     catch (Exception exp)
     {
         status.Foreground = Brushes.Red;
         status.Content    = "Girilen değerleri kontrol ediniz.";
     }
 }
Esempio n. 17
0
        private async Task ExecuteLoadItemsCommand(bool allItems)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                FoodItems.Clear();
                var items = allItems ? await DataStore.GetItemsAsync() : await DataStore.GetMyItemsAsync();

                foreach (var item in items)
                {
                    FoodItems.Add(item);
                    Console.WriteLine(item.FoodName + " " + item.BrandName);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        void UpdateJournal(object sender, EventArgs args)
        {
            var calendar = NSCalendar.CurrentCalendar;

            var startDate = DateTime.Now.Date;
            var endDate   = startDate.AddDays(1);

            var sampleType = HKSampleType.GetQuantityType(HKQuantityTypeIdentifierKey.DietaryEnergyConsumed);
            var predicate  = HKQuery.GetPredicateForSamples((NSDate)startDate, (NSDate)endDate, HKQueryOptions.None);

            var query = new HKSampleQuery(sampleType, predicate, 0, new NSSortDescriptor[0], (resultQuery, results, error) => {
                if (error != null)
                {
                    Console.WriteLine("An error occured fetching the user's tracked food. " +
                                      "In your app, try to handle this gracefully. The error was: {0}.", error.LocalizedDescription);
                    return;
                }

                InvokeOnMainThread(() => {
                    FoodItems.RemoveAllObjects();
                    foreach (HKQuantitySample sample in results)
                    {
                        var foodName  = (NSString)sample.Metadata.Dictionary [HKMetadataKey.FoodType];
                        double joules = sample.Quantity.GetDoubleValue(HKUnit.Joule);
                        var foodItem  = FoodItem.Create(foodName, joules);

                        FoodItems.Add(foodItem);
                    }

                    TableView.ReloadData();
                });
            });

            HealthStore.ExecuteQuery(query);
        }
Esempio n. 19
0
        public int InsertNewFoodItem(FoodItems newfoodItem)
        {
            var res = _rDBContext.FoodItems.Add(newfoodItem);

            _rDBContext.SaveChanges();
            return(res.FoodID);
        }
Esempio n. 20
0
        public async Task <FoodItem> GetFoodItemAsTracked(FoodItem fakeFoodItem)
        {
            var realFoodItem = await FoodItems
                               .Where(v => v.FoodItemId == fakeFoodItem.FoodItemId)
                               .FirstAsync();

            return(realFoodItem);
        }
        public void FoodItemsConstructorMethod()
        {
            FoodItems testItem = new FoodItems("Potatoes", 53.24M, "Chip");

            Assert.AreEqual("Chip", testItem.Type);
            Assert.AreEqual("Potatoes", testItem.ProductName);
            Assert.AreEqual(53.24M, testItem.Price);
        }
Esempio n. 22
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            NSIndexPath indexPathForSelectedRow = TableView.IndexPathForSelectedRow;

            SelectedFoodItem = FoodItems.GetItem <FoodItem> ((nuint)indexPathForSelectedRow.Row);
            ((JournalViewController)NavigationController.ViewControllers [NavigationController.ViewControllers.Length - 2]).
            AddFoodItem(SelectedFoodItem);
            NavigationController.PopViewController(true);
        }
Esempio n. 23
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell     = TableView.DequeueReusableCell(CellIdentifier, indexPath);
            var foodItem = FoodItems.GetItem <FoodItem> ((nuint)indexPath.Row);

            cell.TextLabel.Text       = foodItem.Name;
            cell.DetailTextLabel.Text = EnergyFormatter.StringFromJoules(foodItem.Joules);
            return(cell);
        }
Esempio n. 24
0
 void RemoveMatchFood()
 {
     // Loop all the food in the matchfood arraylist and destroy it
     for (int i = 0; i < matchFoods.Count; i++)
     {
         FoodItems item = matchFoods[i] as FoodItems;
         item.DestroyFood();
     }
 }
Esempio n. 25
0
        public IActionResult OnGet(int restaurantId)
        {
            FoodItems = iFoodType.GetById(restaurantId);
            if (FoodItems == null)
            {
                return(RedirectToPage("../NoteFound"));
            }

            return(Page());
        }
        private void GetCustomerList()
        {
            FoodItems.Clear();
            selectedFoodItem = null;

            foreach (var fooditem in _dbLayerObj.GetFoodItems())
            {
                FoodItems.Add(fooditem);
            }
        }
Esempio n. 27
0
        private async void GetFoodItems()
        {
            var foods = new FoodItemService();
            var items = await foods.GetFoodItemsAsync();

            foreach (var item in items)
            {
                FoodItems.Add(item);
            }
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            FoodItems banana    = new FoodItems("banana", FoodGroup.Fruit);
            FoodItems banana2   = new FoodItems("banana", FoodGroup.Fruit);
            FoodItems chocolate = new FoodItems("chocolate", FoodGroup.Sweets);

            Console.WriteLine("banana == banana2: " + (banana == banana2));
            Console.WriteLine("banana2 == chocolate: " + (banana2 == chocolate));
            Console.WriteLine("chocolate == banana : " + (chocolate == banana));
        }
Esempio n. 29
0
 public void insertFood(FoodItems food)
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH, false))
     {
         dbConn.RunInTransaction(() =>
         {
             dbConn.Insert(food);
         });
     }
 }
Esempio n. 30
0
        public void UpdateItem()
        {
            FoodItems Item = new FoodItems();

            Item        = Items.ElementAt(SelectedIndex);
            Name        = Item.FoodName;
            Description = Item.Description;
            Price       = Item.fPrice;
            Menu.Items.RemoveAt(SelectedIndex);
        }