private void RefreshList() { using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext()) { lst_Ingredients.ItemsSource = db.Ingredients.ToList(); } }
private void BuildRecipeListBox() { try { using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext()) { var r = from re in db.Recipes select re; foreach(Recipe re in r) { var i = from ing in db.Ingredients join ri in db.RecipeIngredients on ing.ing_ID equals ri.ing_ID where ri.rec_ID == re.rec_ID select ing; List<IngredientEntry> ingredients = new List<IngredientEntry>(); foreach(Ingredient ing in i) { var m = from mes in db.RecipeIngredients where mes.ing_ID == ing.ing_ID && mes.rec_ID == re.rec_ID select mes.Measurement; var a = from mes in db.RecipeIngredients where mes.ing_ID == ing.ing_ID && mes.rec_ID == re.rec_ID select mes.ri_Amount; IngredientEntry ingred = new IngredientEntry(ing, m.First(), (double)a.First()); ingredients.Add(ingred); } RecipeEntry rec = new RecipeEntry(re.rec_Name, re.rec_Source,(RecipeCategory)cmb_RecipeCategory.SelectedItem,re.rec_Description,re.rec_PreparationInstructions,re.rec_CookingInstructions, ingredients, re.rec_ID); _Recipes.Add(rec); } } lst_Recipes.ItemsSource = _Recipes; } catch (Exception e) { MessageBox.Show(e.Message); } }
private void BuildIngredientComboBox() { try { using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext()) { cmb_IngredientNames.ItemsSource = db.Ingredients; } } catch (Exception e) { MessageBox.Show("Building Ingredient Combobox failed: " + e.Message); } }
private void BuildMeasurementComboBox() { try { using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext()) { cmb_Measurement.ItemsSource = db.Measurements; } } catch (Exception e) { MessageBox.Show("Building Measurement Combobox failed: " + e.Message); } }
private void BuildCategoryComboBox() { try { using (RecipeBook_DataModelDataContext db = new RecipeBook_DataModelDataContext()) { cmb_RecipeCategory.ItemsSource = db.RecipeCategories; } } catch (Exception e) { MessageBox.Show("Building Category Combobox failed: " + e.Message); } }