public List <LibraryMovie> getMovieLibrary(int idUser)
        {
            con.Open();
            command.CommandText = String.Format("select id,idMovie, image, title from rel_user_movie where idUser = {0}", idUser);
            reader = command.ExecuteReader();
            List <LibraryMovie> libraryMovies = new List <LibraryMovie>();

            while (reader.Read())
            {
                LibraryMovie libraryMovie = new LibraryMovie((int)reader["id"], (int)reader["idMovie"], (string)reader["title"], (string)reader["image"]);
                libraryMovies.Add(libraryMovie);
            }
            foreach (LibraryMovie libraryMovie in libraryMovies)
            {
                reader.Close();
                command.CommandText = String.Format("select name from rel_movie_platform rel join cat_platform cat on rel.idPlatform = cat.id where idRelMovieUser = {0}", libraryMovie.id.ToString());
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    libraryMovie.platforms.Add((string)reader["name"]);
                }
            }
            con.Close();

            return(libraryMovies);
        }
Beispiel #2
0
        private void libraryList_DoubleClick(object sender, EventArgs e)
        {
            ListViewItem currentItem = libraryList.SelectedItems[0];

            actualMovie = libraryMovies.First(o => o.idMovie.ToString().Equals(currentItem.Name));
            listPlatforms.Items.Clear();
            platformsImages.Images.Clear();
            listPlatforms.LargeImageList = platformsImages;
            foreach (string platform in actualMovie.platforms)
            {
                var   item  = listPlatforms.Items.Add(platform, platform, "");
                Image image = (Image)Properties.Resources.ResourceManager.GetObject(platform.ToLower().Replace(" ", "_").Replace("-", "_"));
                platformsImages.Images.Add(platform, image);
                item.ImageKey = platform;
            }
            pnlPlatforms.Location = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);
            pnlPlatforms.Visible  = true;
        }