private void UpdateWindow()
        {
            int selectedRecipe = (int)App.Current.Properties["RecipeID"];


            WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
            foodProjectDataSet.EnforceConstraints = false; //Tek af constraints


            // MainRecipeDetails
            WpfApplication1.FoodProjectDataSetTableAdapters.MainRecipeDetailsTableAdapter foodProjectDataSetMainRecipeDetailsTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.MainRecipeDetailsTableAdapter();
            foodProjectDataSetMainRecipeDetailsTableAdapter.FillByRid(foodProjectDataSet.MainRecipeDetails, selectedRecipe);
            System.Windows.Data.CollectionViewSource mainRecipeDetailsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("mainRecipeDetailsViewSource")));
            mainRecipeDetailsViewSource.View.MoveCurrentToFirst();

            // Recipe
            WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
            foodProjectDataSetRecipeTableAdapter.FillByRid(foodProjectDataSet.Recipe, selectedRecipe);
            System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
            recipeViewSource.View.MoveCurrentToFirst();

            // CuisineInfo
            WpfApplication1.FoodProjectDataSetTableAdapters.CuisineInfoTableAdapter foodProjectDataSetCuisineInfoTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.CuisineInfoTableAdapter();
            foodProjectDataSetCuisineInfoTableAdapter.FillByCuisineInfo(foodProjectDataSet.CuisineInfo, selectedRecipe);
            System.Windows.Data.CollectionViewSource cuisineInfoViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("cuisineInfoViewSource")));
            cuisineInfoViewSource.View.MoveCurrentToFirst();
        }
        private void btnSortByRating_Click(object sender, RoutedEventArgs e)
        {
            txtNameSEARCH.Clear();

            WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
            foodProjectDataSet.EnforceConstraints = false;

            NameOrRating = false;

            if (cuisineComboBox.SelectedValue != null)
            {
                int x = cuisineComboBox.SelectedIndex + 1;

                WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                foodProjectDataSetRecipeTableAdapter.FillByCusinAndRating(foodProjectDataSet.Recipe, x);
                System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                recipeViewSource.View.MoveCurrentToFirst();
            }

            else
            {
                WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                foodProjectDataSetRecipeTableAdapter.FillByRating(foodProjectDataSet.Recipe);
                System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                recipeViewSource.View.MoveCurrentToFirst();
            }
        }
        private void btnSortAZ_Click(object sender, RoutedEventArgs e)
        {
            txtNameSEARCH.Clear();

            UpdateLayout();
            WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
            foodProjectDataSet.EnforceConstraints = false;

            NameOrRating = true;

            if (cuisineComboBox.SelectedValue != null)
            {
                int x = cuisineComboBox.SelectedIndex + 1;


                // Load data into the table Recipe. You can modify this code as needed.
                WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                foodProjectDataSetRecipeTableAdapter.FillByCusinAndName(foodProjectDataSet.Recipe, x);
                System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                recipeViewSource.View.MoveCurrentToFirst();
            }
            else
            {
                // Load data into the table Recipe. You can modify this code as needed.
                WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                foodProjectDataSetRecipeTableAdapter.FillByname(foodProjectDataSet.Recipe);
                System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                recipeViewSource.View.MoveCurrentToFirst();
            }
        }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
     foodProjectDataSet.EnforceConstraints = false;
     // Load data into the table Recipe. You can modify this code as needed.
     WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
     foodProjectDataSetRecipeTableAdapter.Fill(foodProjectDataSet.Recipe);
     System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
     recipeViewSource.View.MoveCurrentToFirst();
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            int rid = (int)App.Current.Properties["rid"];

            WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
            foodProjectDataSet.EnforceConstraints = false; //Tek af constraints

            // Measure
            WpfApplication1.FoodProjectDataSetTableAdapters.MeasureTableAdapter foodProjectDataSetMeasureTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.MeasureTableAdapter();
            foodProjectDataSetMeasureTableAdapter.Fill(foodProjectDataSet.Measure);
            //System.Windows.Data.CollectionViewSource measureViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("measureViewSource")));
            //measureViewSource.View.MoveCurrentToFirst();

            // Ingredient
            WpfApplication1.FoodProjectDataSetTableAdapters.IngredientTableAdapter foodProjectDataSetIngredientTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.IngredientTableAdapter();
            foodProjectDataSetIngredientTableAdapter.Fill(foodProjectDataSet.Ingredient);
            //System.Windows.Data.CollectionViewSource ingredientViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("ingredientViewSource")));
            //ingredientViewSource.View.MoveCurrentToFirst();

            // Recipe
            WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
            foodProjectDataSetRecipeTableAdapter.FillByRid(foodProjectDataSet.Recipe, rid);
            System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
            recipeViewSource.View.MoveCurrentToFirst();

            // MainRecipeDetails
            WpfApplication1.FoodProjectDataSetTableAdapters.MainRecipeDetailsTableAdapter foodProjectDataSetMainRecipeDetailsTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.MainRecipeDetailsTableAdapter();
            foodProjectDataSetMainRecipeDetailsTableAdapter.FillByRid(foodProjectDataSet.MainRecipeDetails, rid);
            System.Windows.Data.CollectionViewSource mainRecipeDetailsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("mainRecipeDetailsViewSource")));
            mainRecipeDetailsViewSource.View.MoveCurrentToFirst();

            // CuisineInfo
            WpfApplication1.FoodProjectDataSetTableAdapters.CuisineInfoTableAdapter foodProjectDataSetCuisineInfoTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.CuisineInfoTableAdapter();
            foodProjectDataSetCuisineInfoTableAdapter.FillByCuisineInfo(foodProjectDataSet.CuisineInfo, rid);
            System.Windows.Data.CollectionViewSource cuisineInfoViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("cuisineInfoViewSource")));
            cuisineInfoViewSource.View.MoveCurrentToFirst();

            // Cuisine
            WpfApplication1.FoodProjectDataSetTableAdapters.CuisineTableAdapter foodProjectDataSetCuisineTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.CuisineTableAdapter();
            foodProjectDataSetCuisineTableAdapter.Fill(foodProjectDataSet.Cuisine);
            //System.Windows.Data.CollectionViewSource cuisineViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("cuisineViewSource")));
            //cuisineViewSource.View.MoveCurrentToFirst();

            string currentImage = foodProjectDataSetRecipeTableAdapter.GetImageUrl(rid);

            App.Current.Properties["image_url"] = currentImage;
            App.Current.Properties["isDeleted"] = isDeleted;

            unsavedChanges = false;
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();

            int    max = (int)foodProjectDataSetRecipeTableAdapter.GetHighestRid();
            Random r   = new Random(DateTime.Now.Day);
            int    rid = r.Next(1, max);

            do
            {
                UpdateWindow(foodProjectDataSetRecipeTableAdapter, rid);
                rid++;
            } while (RecipeName.Text == null || RecipeName.Text == "");

            //MessageBox.Show(mainRecipeDetailsViewSource.Source.ToString());
        }
        private void UpdateWindow()
        {
            WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
            foodProjectDataSet.EnforceConstraints = false;
            // Load data into the table Recipe. You can modify this code as needed.
            WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
            foodProjectDataSetRecipeTableAdapter.FillByname(foodProjectDataSet.Recipe);
            System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
            recipeViewSource.View.MoveCurrentToFirst();

            // Load data into the table Cuisine. You can modify this code as needed.
            WpfApplication1.FoodProjectDataSetTableAdapters.CuisineTableAdapter foodProjectDataSetCuisineTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.CuisineTableAdapter();
            foodProjectDataSetCuisineTableAdapter.Fill(foodProjectDataSet.Cuisine);
            System.Windows.Data.CollectionViewSource cuisineViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("cuisineViewSource")));
            cuisineViewSource.View.MoveCurrentToFirst();

            cuisineComboBox.SelectedValue = null;
        }
Пример #8
0
        private void UpdateWindow()
        {
            try
            {
                WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));

                foodProjectDataSet.EnforceConstraints = false;
                // Load data into the table Recipe. You can modify this code as needed.
                WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                foodProjectDataSetRecipeTableAdapter.Fill(foodProjectDataSet.Recipe);
                System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                recipeViewSource.View.MoveCurrentToFirst();


                // Load data into the table Cuisine. You can modify this code as needed.
                WpfApplication1.FoodProjectDataSetTableAdapters.CuisineTableAdapter foodProjectDataSetCuisineTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.CuisineTableAdapter();
                foodProjectDataSetCuisineTableAdapter.Fill(foodProjectDataSet.Cuisine);
                System.Windows.Data.CollectionViewSource cuisineViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("cuisineViewSource")));
                cuisineViewSource.View.MoveCurrentToFirst();

                // Load data into the table Category. You can modify this code as needed.
                WpfApplication1.FoodProjectDataSetTableAdapters.CategoryTableAdapter foodProjectDataSetCategoryTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.CategoryTableAdapter();
                foodProjectDataSetCategoryTableAdapter.Fill(foodProjectDataSet.Category);
                System.Windows.Data.CollectionViewSource categoryViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("categoryViewSource")));
                categoryViewSource.View.MoveCurrentToFirst();

                // Load data into the table Ingredient. You can modify this code as needed.
                WpfApplication1.FoodProjectDataSetTableAdapters.IngredientTableAdapter foodProjectDataSetIngredientTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.IngredientTableAdapter();
                foodProjectDataSetIngredientTableAdapter.Fill(foodProjectDataSet.Ingredient);
                System.Windows.Data.CollectionViewSource categoryIngredientViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("categoryIngredientViewSource")));
                categoryIngredientViewSource.View.MoveCurrentToFirst();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Villa í Update");
            }
        }
        private void TextBox_SelectionChanged(object sender, RoutedEventArgs e)
        {
            UpdateLayout();
            //MessageBox.Show(cuisineComboBox.SelectedIndex.ToString());
            if (cuisineComboBox != null)
            {
                if (NameOrRating == false)
                {
                    string search = '%' + txtNameSEARCH.Text + '%';
                    int    x      = cuisineComboBox.SelectedIndex + 1;

                    WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
                    foodProjectDataSet.EnforceConstraints = false;
                    // Load data into the table Recipe. You can modify this code as needed.
                    WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                    foodProjectDataSetRecipeTableAdapter.SearchRating(foodProjectDataSet.Recipe, x, search);
                    System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                    recipeViewSource.View.MoveCurrentToFirst();
                }
                else
                {
                    string search = '%' + txtNameSEARCH.Text + '%';
                    int    x      = cuisineComboBox.SelectedIndex + 1;

                    WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
                    foodProjectDataSet.EnforceConstraints = false;
                    // Load data into the table Recipe. You can modify this code as needed.
                    WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                    foodProjectDataSetRecipeTableAdapter.FillBySearchName(foodProjectDataSet.Recipe, x, search);
                    System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                    recipeViewSource.View.MoveCurrentToFirst();
                }
            }
            if (cuisineComboBox.SelectedItem == null)
            {
                if (NameOrRating == false)
                {
                    string search = '%' + txtNameSEARCH.Text + '%';

                    WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
                    foodProjectDataSet.EnforceConstraints = false;
                    // Load data into the table Recipe. You can modify this code as needed.
                    WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                    foodProjectDataSetRecipeTableAdapter.FillByRatingSearch(foodProjectDataSet.Recipe, search);
                    System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                    recipeViewSource.View.MoveCurrentToFirst();
                }
                else
                {
                    string search = '%' + txtNameSEARCH.Text + '%';

                    WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
                    foodProjectDataSet.EnforceConstraints = false;
                    // Load data into the table Recipe. You can modify this code as needed.
                    WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                    foodProjectDataSetRecipeTableAdapter.FillByNameSEARCH(foodProjectDataSet.Recipe, search);
                    System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                    recipeViewSource.View.MoveCurrentToFirst();
                }
            }
        }
        private void cuisineComboBox_DropDownClosed(object sender, EventArgs e)
        {
            txtNameSEARCH.Clear();


            try
            {
                if (cuisineComboBox.SelectedIndex == -1)
                {
                    UpdateWindow();
                }
                else
                {
                    var x = cuisineComboBox.SelectedIndex + 1;
                    //MessageBox.Show(x.ToString());
                    WpfApplication1.FoodProjectDataSet foodProjectDataSet = ((WpfApplication1.FoodProjectDataSet)(this.FindResource("foodProjectDataSet")));
                    foodProjectDataSet.EnforceConstraints = false;
                    // Load data into the table Recipe. You can modify this code as needed.
                    WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter foodProjectDataSetRecipeTableAdapter = new WpfApplication1.FoodProjectDataSetTableAdapters.RecipeTableAdapter();
                    foodProjectDataSetRecipeTableAdapter.FillByBIGTEST(foodProjectDataSet.Recipe, x);

                    System.Windows.Data.CollectionViewSource recipeViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("recipeViewSource")));
                    recipeViewSource.View.MoveCurrentToFirst();

                    //cuisineComboBox.SelectedIndex = -1;
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.ToString());
            }
        }