Пример #1
0
        private void addRecipe_Click(object sender, EventArgs e)
        {
            var recipe = new Recipe
            {
                Dishes      = new DishRepository(_connectionString).GetAll(),
                Ingredients = new IngredientRepository(_connectionString).GetAll(),
                Units       = new UnitRepository(_connectionString).GetAll(),
            };
            var dialogResult = new AddOrEditRecipeForm(recipe, _connectionString).ShowDialog(this);

            if (dialogResult == DialogResult.Cancel)
            {
                FillOrRefreshTreeOfRecipes();
            }
        }
Пример #2
0
        private void editRecipe_Click(object sender, EventArgs e)
        {
            var dishName = recipesTreeView.SelectedNode.Text;

            var dishID = new DishRepository(_connectionString).GetAll().First(x => x.DishName == dishName).DishID;

            var recipe = new RecipeRepository(_connectionString).GetById(dishID);

            recipe.Dishes      = new DishRepository(_connectionString).GetAll();
            recipe.Ingredients = new IngredientRepository(_connectionString).GetAll();
            recipe.Units       = new UnitRepository(_connectionString).GetAll();

            var dialogResult = new AddOrEditRecipeForm(recipe, _connectionString).ShowDialog(this);

            if (dialogResult == DialogResult.Cancel)
            {
                FillOrRefreshTreeOfRecipes();
            }
        }