Exemple #1
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem selectedItem = (ComboBoxItem)TypeBox.SelectedItem;

            if (selectedItem.Content.ToString() == "Жанр")
            {
                BookGenre genre = (BookGenre)ListBox.SelectedItem; if (TextBox.Text != "")
                {
                    genre.Title = TextBox.Text;
                }
                else
                {
                    genre.Title = "N/A";
                }; main.GetGenreDB().Update(); MessageBox.Show("Жанр успешно изменен", "Успешно", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            if (selectedItem.Content.ToString() == "Тип")
            {
                MagazineType type = (MagazineType)ListBox.SelectedItem; if (TextBox.Text != "")
                {
                    type.Title = TextBox.Text;
                }
                else
                {
                    type.Title = "N/A";
                }; main.GetTypeDB().Update(); MessageBox.Show("Тип успешно изменен", "Успешно", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            Close();
        }
Exemple #2
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem selectedItem = (ComboBoxItem)TypeBox.SelectedItem;

            if (selectedItem.Content.ToString() == "Жанр")
            {
                BookGenre genre = (BookGenre)ListBox.SelectedItem; main.GetGenreDB().Delete(genre.Id); MessageBox.Show("Жанр успешно удален", "Успешно удалено", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            if (selectedItem.Content.ToString() == "Тип")
            {
                MagazineType type = (MagazineType)ListBox.SelectedItem; main.GetTypeDB().Delete(type.Id); MessageBox.Show("Тип успешно удален", "Успешно удалено", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            Close();
        }
Exemple #3
0
        public void LoadMagazineCombobox()
        {
            MagazineType AllType = new MagazineType {
                Title = "Все", Id = 0
            };

            List <MagazineType> AllList = new List <MagazineType>();

            AllList.Add(AllType);
            foreach (MagazineType item in GetTypeDB().Load())
            {
                AllList.Add(item);
            }
            TypeBox.ItemsSource       = AllList;
            TypeBox.SelectedValuePath = "Id";
            TypeBox.DisplayMemberPath = "Title";
        }
Exemple #4
0
        private void Ok_Click(object sender, RoutedEventArgs e)
        {
            switch (ChangeType())
            {
            case 1:
                BookGenre newGenre = new BookGenre();
                newGenre.Title = TextBox.Text;
                Main.GetGenreDB().Insert(newGenre);
                break;

            case 2:
                MagazineType newType = new MagazineType();
                newType.Title = TextBox.Text;
                Main.GetTypeDB().Insert(newType);
                break;
            }

            this.DialogResult = true;
            Close();
        }
Exemple #5
0
        private void TypeSelect(object sender, SelectionChangedEventArgs e)
        {
            MagazineType TypeMagazine = (MagazineType)TypeBox.SelectedItem;

            MagazineGrid.ItemsSource = TypeMagazine.Magazines;
        }