コード例 #1
0
        private void btn_Save(object sender, RoutedEventArgs e)
        {
            if (tb_Name.Text == "" || tb_Quantity.Text == "" || tb_MinimumQuantity.Text == "" || tb_PurchasePrice.Text == "")
            {
                AutoClosingMessageBox.Show("Please Enter Correct Values", "Alert", 3000);
                return;
            }

            tbl_KitchenInventory ki = new tbl_KitchenInventory();

            try
            {
                ki.Name                        = tb_Name.Text;
                ki.Quantity                    = Convert.ToDouble(tb_Quantity.Text);
                ki.MinimumQuantity             = Convert.ToDouble(tb_MinimumQuantity.Text);
                ki.PurchasePrice               = Convert.ToDouble(tb_PurchasePrice.Text);
                ki.ExpiryDate                  = dp_ExpiryDate.SelectedDate;
                ki.KitchenInventoryCategory_Id = catId;
                KitchenInventory.insert(ki);
                AutoClosingMessageBox.Show("Item Added", "Success", 3000);
                Close();
                new Form_AddNewKitchenInventory().Show();
            }
            catch
            {
                AutoClosingMessageBox.Show("Some Error Occured", "Alert", 3000);
                return;
            }
        }
 private void btn_DeleteKitchenInventory(object sender, RoutedEventArgs e)
 {
     if (dg_AllKitchenInventory.SelectedItem != null)
     {
         KitchenInventory.delete((tbl_KitchenInventory)dg_AllKitchenInventory.SelectedItem);
         AutoClosingMessageBox.Show("Item Deleted", "Success", 3000);
         initFormOperations();
     }
 }
 private void tb_Price_KeyDown_PressEnter(object sender, KeyEventArgs e)
 {
     if (dg_AllKitchenItems.SelectedItem != null)
     {
         if (e.Key == Key.Enter)
         {
             tbl_KitchenInventory ki = (tbl_KitchenInventory)dg_AllKitchenItems.SelectedItem;
             ki.PurchasePrice = Convert.ToDouble(tb_Price.Text);
             KitchenInventory.update(ki);
             initFormOperations();
         }
     }
 }
 void initFormOperations()
 {
     dg_AllKitchenItems.Items.Clear();
     dg_AllLowInventoryItems.Items.Clear();
     foreach (tbl_KitchenInventory item in KitchenInventory.getAll())
     {
         dg_AllKitchenItems.Items.Add(item);
     }
     foreach (tbl_KitchenInventory item in KitchenInventory.getLowInventoryItem())
     {
         dg_AllLowInventoryItems.Items.Add(item);
     }
 }
コード例 #5
0
        private IActionResult ValidatePlannerKitchenInventory(Planner planner)
        {
            var plannerInventory = _context.KitchenInventories.Where(i => i.PodId == planner.PodId).SingleOrDefault();

            if (plannerInventory == null)
            {
                KitchenInventory inventory = new KitchenInventory()
                {
                    PodId = planner.PodId
                };
                _context.Add(inventory);
                _context.SaveChanges();

                return(View(nameof(Index)));
            }

            return(View(nameof(Index)));
        }
        void initFormOperations()
        {
            dg_AllInventoryItems.ItemsSource = KitchenInventory.getAll();
            var categoriesList = FoodItem.getAll();

            foreach (tbl_FoodItem item1 in categoriesList)
            {
                cb_AllFoodItems.ItemsSource       = categoriesList;
                cb_AllFoodItems.DisplayMemberPath = "Name";
                cb_AllFoodItems.SelectedValuePath = "Id";
            }

            var categoriesList1 = Deal.getAll();

            foreach (tbl_Deal item1 in categoriesList1)
            {
                cb_AllDeals.ItemsSource       = categoriesList1;
                cb_AllDeals.DisplayMemberPath = "Name";
                cb_AllDeals.SelectedValuePath = "Id";
            }
        }
        void initFormOperations(int id)
        {
            ki                         = KitchenInventory.getById(id);
            tb_Name.Text               = ki.Name;
            tb_Quantity.Text           = Convert.ToString(ki.Quantity);
            tb_MinimumQuantity.Text    = Convert.ToString(ki.MinimumQuantity);
            tb_PurchasePrice.Text      = Convert.ToString(ki.PurchasePrice);
            dp_ExpiryDate.SelectedDate = ki.ExpiryDate;
            catId                      = (int)ki.KitchenInventoryCategory_Id;
            cb_Category.SelectedValue  = catId;
            UpdateLayout();

            var allCategories = KitchenInventoryCategory.getAll();

            foreach (tbl_KitchenInventoryCategory item in allCategories)
            {
                cb_Category.ItemsSource       = allCategories;
                cb_Category.DisplayMemberPath = "Name";
                cb_Category.SelectedValuePath = "Id";
            }
        }
 void initFormOperations()
 {
     dg_AllKitchenInventory.ItemsSource = null;
     dg_AllKitchenInventory.ItemsSource = KitchenInventory.getAll();
     UpdateLayout();
 }