void initFormOperations()
 {
     dg_AllCategories.Items.Clear();
     foreach (tbl_KitchenInventoryCategory item in KitchenInventoryCategory.getAll())
     {
         dg_AllCategories.Items.Add(item);
     }
     UpdateLayout();
 }
コード例 #2
0
        void initFormOperations()
        {
            var allCategories = KitchenInventoryCategory.getAll();

            foreach (tbl_KitchenInventoryCategory item in allCategories)
            {
                cb_Category.ItemsSource       = allCategories;
                cb_Category.DisplayMemberPath = "Name";
                cb_Category.SelectedValuePath = "Id";
            }
        }
 private void btn_DeleteCaterory(object sender, RoutedEventArgs e)
 {
     if (dg_AllCategories.SelectedItem != null)
     {
         KitchenInventoryCategory.delete((tbl_KitchenInventoryCategory)dg_AllCategories.SelectedItem);
         AutoClosingMessageBox.Show("Category Deleted", "Success", 3000);
         initFormOperations();
     }
     else
     {
         AutoClosingMessageBox.Show("Please Select a Item", "Alert", 3000);
     }
 }
 private void btn_AddNewCaterory(object sender, RoutedEventArgs e)
 {
     if (tb_Name.Text != "")
     {
         tbl_KitchenInventoryCategory kic = new tbl_KitchenInventoryCategory();
         kic.Name = tb_Name.Text;
         KitchenInventoryCategory.insert(kic);
         AutoClosingMessageBox.Show("Category Added", "Success", 3000);
         tb_Name.Text = "";
         initFormOperations();
     }
     else
     {
         AutoClosingMessageBox.Show("Please Enter Category Name", "Alert", 3000);
     }
 }
 private void btn_UpdateCaterory(object sender, RoutedEventArgs e)
 {
     if (dg_AllCategories.SelectedItem != null)
     {
         tbl_KitchenInventoryCategory category = (tbl_KitchenInventoryCategory)dg_AllCategories.SelectedItem;
         var dialog = new Form_InputDialog(category.Name);
         if (dialog.ShowDialog() == true)
         {
             category.Name = dialog.ResponseText;
             KitchenInventoryCategory.update(category);
             AutoClosingMessageBox.Show("Category Updated", "Success", 3000);
             initFormOperations();
         }
     }
     else
     {
         AutoClosingMessageBox.Show("Please Select a Item", "Alert", 3000);
     }
 }
        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";
            }
        }