Exemple #1
0
        private void Go_To_Back(object sender, RoutedEventArgs e)
        {
            AllCategoriesWindow allCategories = new AllCategoriesWindow();

            allCategories.Show();
            Hide();
        }
        private void Button_All_Categories(object sender, RoutedEventArgs e)
        {
            AllCategoriesWindow allCategories = new AllCategoriesWindow();

            allCategories.Show();
            Hide();
        }
Exemple #3
0
        private void createBtn_Click(object sender, RoutedEventArgs e)
        {
            string getName;

            if (textBoxCategory.Text != "")
            {
                getName = textBoxCategory.Text.Trim();
            }
            else
            {
                MessageBox.Show("Введите название!");
                return;
            }


            string getCategoryId;

            if (listOfIcons.SelectedIndex > -1)
            {
                getCategoryId = listOfIcons.SelectedItems[0].ToString();
            }
            else
            {
                MessageBox.Show("Выберите категорию!");
                return;
            }

            Category category = new Category(getName, Convert.ToInt32(getCategoryId));


            using (ApplicationContext context = new ApplicationContext())
            {
                context.Categories.Add(category);
                context.SaveChanges();
            }
            AllCategoriesWindow allCategories = new AllCategoriesWindow();

            allCategories.Show();
            Hide();
        }