Пример #1
0
        private void btnAddMenu_Click(object sender, EventArgs e)
        {
            string validInputRegex = @"^\£?([0-9]{1,3},([0-9]{3},)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$";
            Match  match           = Regex.Match(txtNMenuPrice.Text, validInputRegex, RegexOptions.IgnoreCase);

            if (!match.Success)
            {
                MessageBox.Show("Incorrect price format!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (Meat != null & Veg1 != null && Veg2 != null && Drink != null)
            {
                if (FoodMenu.Add(Meat, Veg1, Veg2, Drink, Convert.ToDecimal(txtNMenuPrice.Text)))
                {
                    MessageBox.Show("Menu Added!", "SUCCESS", MessageBoxButtons.OK);
                    LoadFoodMenus();
                }
                else
                {
                    MessageBox.Show("Failed to add Menu!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Please select one of each item!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }