Exemple #1
0
        public void FillComboBox()
        {
            cBoxCategorys.Items.Clear();
            var dbm        = new DBmanager();
            var categories = dbm.GetCategories();

            foreach (var category in categories)
            {
                cBoxCategorys.Items.Add(category.KategoriBeskrivning.ToString());
                cBoxCategoriesNewAddDelete.Items.Add(category.KategoriBeskrivning.ToString());
            }
        }
Exemple #2
0
        private void btnUpdateRecipe_Click(object sender, EventArgs e)
        {
            var dbm = new DBmanager();

            if (lstBoxRecipe.SelectedIndex > -1)
            {
                dbm.UpdateRecipe(lstBoxRecipe.SelectedItem.ToString(), tBoxTitle.Text, richTextDescription.Text, richTextIngrediens.Text, cBoxCategoriesNewAddDelete.SelectedItem.ToString());
                GetsearchedTitles();
            }
            else
            {
                MessageBox.Show("You haven´t selected a recipe to update");
            }
        }
Exemple #3
0
        private void btnDeleteRecipe_Click(object sender, EventArgs e)
        {
            var dbm = new DBmanager();

            if (lstBoxRecipe.SelectedIndex > -1)
            {
                dbm.DeleteRecipe(lstBoxRecipe.SelectedItem.ToString());
                ResetTextBox();
                GetsearchedTitles();
            }
            else
            {
                MessageBox.Show("You haven´t selected a recipe to delete");
            }
        }
Exemple #4
0
 private void lstBoxRecipe_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstBoxRecipe.SelectedIndex > -1)
     {
         cBoxCategoriesNewAddDelete.Items.Clear();
         var dbm    = new DBmanager();
         var recipe = dbm.GetSelectedRecipe(lstBoxRecipe.SelectedItem.ToString());
         tBoxTitle.Text           = recipe.Titel.ToString();
         richTextDescription.Text = recipe.Beskrivning.ToString();
         richTextIngrediens.Text  = recipe.Ingredienser.ToString();
         FillComboBox();
         var selectedCategory = dbm.GetSelectedCategory(lstBoxRecipe.SelectedItem.ToString());
         cBoxCategoriesNewAddDelete.SelectedItem = selectedCategory.KategoriBeskrivning.ToString();
     }
 }
Exemple #5
0
        private void btnCreateNewRecipe_Click(object sender, EventArgs e)
        {
            var dbm = new DBmanager();

            if (tBoxTitle.Text.Length >= 1 && richTextDescription.Text.Length > 1 && richTextIngrediens.Text.Length > 1 && cBoxCategoriesNewAddDelete.SelectedIndex > -1)
            {
                dbm.CreateNewRecipe(tBoxTitle.Text, richTextDescription.Text, richTextIngrediens.Text, cBoxCategoriesNewAddDelete.SelectedItem.ToString());
                ResetTextBox();
                GetsearchedTitles();
            }
            else
            {
                MessageBox.Show("You have not filled all boxes");
            }
        }
Exemple #6
0
        public void GetsearchedTitles()
        {
            lstBoxRecipe.Items.Clear();
            var dbm = new DBmanager();

            if (cBoxCategorys.SelectedIndex <= -1 || cBoxCategorys.Text == "No Category")
            {
                var recipies = dbm.GetSearchedRecipes(tBoxSearchField.Text);
                foreach (var recipe in recipies)
                {
                    lstBoxRecipe.Items.Add(recipe.Titel.ToString());
                }
            }
            else
            {
                var recipies = dbm.GetSearchedRecipesWith(cBoxCategorys.Text, tBoxSearchField.Text);
                foreach (var recipe in recipies)
                {
                    lstBoxRecipe.Items.Add(recipe.Titel.ToString());
                }
            }
        }