コード例 #1
0
 private void cmdAddRecipe_Click(object sender, EventArgs e)
 {
     if (txtHeadline.Text == "" || cboRecipeType == null || txtIngredients.Text == "" || txtInstructions.Text == "")
     {
         MessageBox.Show("Du har inte fyllt i all information om receptet.");
     }
     else
     {
         string        headLine          = txtHeadline.Text;
         RecipeType    recipeType        = new RecipeType(cboRecipeType.SelectedItem.ToString());
         string[]      ingredientArray   = txtIngredients.Lines;
         string[]      instructionsArray = txtInstructions.Lines;
         List <string> ingredients       = ingredientArray.ToList();
         List <string> instructions      = instructionsArray.ToList();
         Recipe        recipe            = new Recipe(txtHeadline.Text, ingredients, instructions, recipeType);
         FileHandler.AddRecipe(recipe);
     }
 }