예제 #1
0
        public FilmsShowAdmin()
        {
            InitializeComponent();
            film_Icons             = new List <Film_icon>();
            deleteList             = new List <Film_icon>();
            using CinemaContext db = new();
            var films = db.FilmsRaitingsGenres.ToList();

            foreach (FilmsRaitingsGenre film in films)
            {
                Film      filmString = db.Films.Find(film.IdFilm);
                Film_icon film_Icon  = new Film_icon(Manager.CreateSource(film.Poster), film.NameFilm, film.Genre,
                                                     Math.Round(film.Rating, 1).ToString(), (int)film.AgeLimit, 2, filmString);
                film_Icon.Margin              = new Thickness(5, 5, 5, 5);
                film_Icon.deleteButton.Click += ChooseFilms;
                film_Icons.Add(film_Icon);
                wrappanel.Children.Add(film_Icon);
            }
            var genres = db.AllGenres.ToList();

            foreach (AllGenre genre in genres)
            {
                RadioButton radioButton = new RadioButton();
                radioButton.Content  = genre.Genre;
                radioButton.Checked += GenreChecked;
                Films_genre.Children.Add(radioButton);
            }
        }
예제 #2
0
        private void Search()
        {
            wrappanel.Children.Clear();
            using CinemaContext db = new();
            SqlParameter isDate = new("@filters", "0");

            if (i != 0)
            {
                isDate = new("@filters", "1");
            }
            SqlParameter MovieDate = new("@date_movie", SelectedDate);
            var          films     = db.Films.FromSqlRaw("SearchMovies @date_movie, @filters", MovieDate, isDate).ToList();

            foreach (Film film in films)
            {
                Film_icon film_Icon = film_Icons.Find(item => item.Name_film == film.NameFilm);
                if (film_Icon is not null)
                {
                    if (Search_box.Text == "" || Search_box.FontStyle == FontStyles.Italic || film_Icon.Name_film.ToLower().StartsWith(Search_box.Text.ToLower()))
                    {
                        if (Age.Text == "" || film_Icon.Age_limit == int.Parse(Age.Text))
                        {
                            if (SelectGenre == "" || film_Icon.Genres_list.Contains(SelectGenre))
                            {
                                wrappanel.Children.Add(film_Icon);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        private void ChooseFilms(object sender, RoutedEventArgs e)
        {
            Button    button    = (Button)sender;
            Film_icon film_Icon = film_Icons.Find(item => item.deleteButton == button);

            if (button.Background == Brushes.Red)
            {
                button.Background  = Brushes.LightGray;
                button.BorderBrush = Brushes.LightGray;
                deleteList.Remove(film_Icon);
            }
            else
            {
                button.Background  = Brushes.Red;
                button.BorderBrush = Brushes.Red;
                deleteList.Add(film_Icon);
            }
        }