Exemple #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtName.Text == null || txtPrice.Text == null || cmbCategory.SelectedIndex <= 0)
            {
                MessageBox.Show("please fill all the required fields");
            }
            else
            {
                MenuItem currentItem;
                bool     ExistingItem = int.TryParse(lblProductID.Text, out int pID);
                if (ExistingItem)
                {
                    //
                    currentItem = new MenuItem
                    {
                        Name            = txtName.Text,
                        ProductID       = pID,
                        PreparationTime = Convert.ToInt32(numPrep.Value),
                        Category        = (Category)cmbCategory.SelectedItem,
                        Price           = Convert.ToDecimal(txtPrice.Text),
                        Quantity        = Convert.ToInt32(numQuantity.Value),
                    };
                    int rows = menuItemSrv.EditMenuItem(currentItem);
                    ShowResult(rows, "item edited sucessfully", "btn submit, add menu item");
                }
                else
                {
                    currentItem = new MenuItem
                    {
                        Name = txtName.Text,
                        //ProductID = Convert.ToInt32(lblProductID.Text),
                        PreparationTime = Convert.ToInt32(numPrep.Value),
                        Category        = (Category)cmbCategory.SelectedItem,
                        Price           = Convert.ToDecimal(txtPrice.Text),
                        Quantity        = Convert.ToInt32(numQuantity.Value),
                    };
                    int rows = menuItemSrv.AddMenuItem(currentItem);

                    ShowResult(rows, "item added sucessfully", "btn submit click, edit menu item");
                }
            }



            RefreshPanel();
            FillListView();
        }
Exemple #2
0
        private void BTN_MIMenuAdd_Click(object sender, EventArgs e)
        {
            bool found = false;

            foreach (var x in menuItemService.getMenuTypes())
            {
                if (TXTB_Menutype.Text != string.Empty)
                {
                    if (x.Type == TXTB_Menutype.Text)
                    {
                        found = true;
                    }
                }
            }
            if (!found)
            {
                MessageBox.Show("Menu type not found!");
                return;
            }

            decimal price;

            if (TXTB_MIMenuName.Text == string.Empty)
            {
                MessageBox.Show("Fill in a menu name");
                return;
            }

            if (!decimal.TryParse(TXTB_MIPrice.Text, out price))
            {
                MessageBox.Show("Fill in correct price");
                return;
            }
            string MenuName = TXTB_MIMenuName.Text;

            price = decimal.Parse(TXTB_MIPrice.Text) / 100;

            menuItemService.AddMenuItem(this.selectedMenu.Id, MenuName, price);
            MessageBox.Show("Menu Item toegevoegd", "Menu Item!", MessageBoxButtons.OK);

            displayGrid();
        }
 private void BtnAddDish_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(textBox1.Text))
     {
         // it is not empty or null!
         Random rdm        = new Random();
         int    menuItemId = rdm.Next(1, 999999);
         int    VAT;
         if (comboBoxBTW.SelectedItem == comboBoxBTW.Items[0])
         {
             VAT = 21;
         }
         else
         {
             VAT = 6;
         }
         menuItemService.AddMenuItem(menuItemId, textBox1.Text, numericUpDown1.Value, VAT, (int)numericUpDown3.Value, type, comboBoxType.SelectedItem.ToString());
         menuService.AddItemToMenu(menu.Id, menuItemId);
     }
     else
     {
         LblWarning.Text = "Kan geen item zonder naam toevoegen!";
     }
 }