private void ButtonAddDrink_Click(object sender, EventArgs e) { if (textBoxDrink.Text == "" || comboBoxBar2.SelectedItem == null || textBoxPrice2.Text == "") { MessageBox.Show("Bad input"); return; } Bar bar = ((Bar)comboBoxBar2.SelectedItem); string drinkName = textBoxDrink.Text; if (Regex.IsMatch(textBoxPrice2.Text, @"(^[1-9]\d*(.\d{1,2})?$)|(^0(\.\d{1,2})?$)")) { float price = (float)Convert.ToDouble(textBoxPrice2.Text); if (drinkManager.GetDrinkByName(drinkName) == null) { drinkManager.AddDrink(drinkName); } Drink drink = drinkManager.GetDrinkByName(drinkName); if (barManager.GetBarByID(bar.barID).availableDrinks.ContainsKey(drink.drinkID)) { MessageBox.Show("Drink with this name already exists in this bar"); return; } barManager.GetBarByID(bar.barID).AddDrink(drink.drinkID, price); drink.AddBar(bar.barID, price); } textBoxDrink.Text = ""; textBoxPrice2.Text = ""; PopulateComboBoxBar(); }