private void OrderButton_Click(object sender, EventArgs e) { //Declaring local variable for storing total topping chosen by the user int totalTopings = checkedListBoxForIngredients.CheckedIndices.Count; //Add selected toppings in local tempToppingList variable string tempToppingList = ""; for (int i = 0; i <= checkedListBoxForIngredients.CheckedIndices.Count - 1; i++) { tempToppingList += checkedListBoxForIngredients.CheckedItems[i].ToString() + (i == (checkedListBoxForIngredients.CheckedIndices.Count - 1) ? "." : ", "); } Pizza aPizza = new Pizza(sizeComboBox.SelectedIndex, souceComboBox.SelectedItem.ToString(), totalTopings, tempToppingList); //When validation is passed add order to pizzaOrderList static attributes of Pizza class if (PizzaValidation.IsValidationPassed(aPizza)) { Pizza.pizzaOrderList.Add(aPizza); MessageBox.Show("Your order is placed..!!"); Summary_Click(sender, e);//prepare result in summary tabPage } else { MessageBox.Show("Validation failed..!! You must build your pizza with appropriate items"); } }
public virtual ValidationResult Validate() { PizzaValidation pizzaValidation = new PizzaValidation(); return(pizzaValidation.Validate(this)); }