コード例 #1
0
 private void setMoviePoster(Dictionary <string, string> Movie)
 {
     using (var bmpTemp = new Bitmap(PosterStorage.GetFile(Movie["poster_path"].ToString())))
     {
         MoviePoster.Image = new Bitmap(bmpTemp);
     }
 }
コード例 #2
0
 private void setMoviePoster(MySqlDataReader movie)
 {
     using (var bmpTemp = new Bitmap(PosterStorage.GetFile(movie["poster_path"].ToString())))
     {
         MoviePoster.Image = new Bitmap(bmpTemp);
     }
 }
コード例 #3
0
 private void setMoviePoster(MySqlDataReader movie)
 {
     // ambil gambar lokal dan pasangkan ke picturebox
     using (Bitmap bmpTemp = new Bitmap(
                PosterStorage.GetFile(
                    movie["poster_path"].ToString()
                    )
                ))
     {
         MoviePoster.Image = new Bitmap(bmpTemp);
     }
 }
コード例 #4
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateInputs();

                SaveButton.Text = "SAVING...";

                MovieStorage    movieStorage    = new MovieStorage(MovieID.Text, this.MoviePath);
                SubtitleStorage subtitleStorage = new SubtitleStorage(MovieID.Text, SubtitlePathLabel.Text);
                PosterStorage   posterStorage   = new PosterStorage(MovieID.Text, MoviePoster);

                SqlConnector DBC = new SqlConnector();

                string query = "INSERT INTO movies (id, title, description, release_year, poster_path, movie_path, subtitle_path) VALUES (@id, @title, @description, @release_year, @poster_path, @movie_path, @subtitle_path)";

                MySqlCommand command = new MySqlCommand(query, DBC.connection);
                command.Parameters.Add("@id", MySqlDbType.Int64);
                command.Parameters.Add("@title", MySqlDbType.String);
                command.Parameters.Add("@description", MySqlDbType.String);
                command.Parameters.Add("@release_year", MySqlDbType.Date);
                command.Parameters.Add("@poster_path", MySqlDbType.String);
                command.Parameters.Add("@movie_path", MySqlDbType.String);
                command.Parameters.Add("@subtitle_path", MySqlDbType.String);

                command.Parameters["@id"].Value            = MovieID.Text;
                command.Parameters["@title"].Value         = MovieTitle.Text;
                command.Parameters["@description"].Value   = MovieDescription.Text;
                command.Parameters["@release_year"].Value  = MovieReleaseYear.Value.ToString("yyyy-MM-dd");
                command.Parameters["@poster_path"].Value   = posterStorage.GetName();
                command.Parameters["@movie_path"].Value    = movieStorage.GetName();
                command.Parameters["@subtitle_path"].Value = subtitleStorage.GetName();


                try
                {
                    DBC.connection.Open();

                    if (command.ExecuteNonQuery() != -1)
                    {
                        movieStorage.Run();
                        posterStorage.Run();
                        subtitleStorage.Run();

                        SaveButton.Text = "SAVE";

                        MessageBox.Show("Berhasil disimpan.");

                        this.Close();
                    }
                    else
                    {
                        SaveButton.Text = "SAVE";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DBC.connection.Close();
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #5
0
        private void DeleteMovieButton_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Hapus film ini?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                string query = "Select * from movies where id=@movie_id";

                MySqlCommand command = new MySqlCommand(query, DBC.connection);
                command.Parameters.Add("@movie_id", MySqlDbType.Int64);
                command.Parameters["@movie_id"].Value = BrowseMovieItem.ClickedMovieID;

                try
                {
                    DBC.connection.Open();

                    MySqlDataReader reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        MovieStorage movieStorage = new MovieStorage(reader["movie_path"].ToString());
                        movieStorage.Delete();

                        MoviePoster.Image.Dispose();

                        PosterStorage posterStorage = new PosterStorage(reader["poster_path"].ToString());
                        posterStorage.Delete();

                        SubtitleStorage subtitleStorage = new SubtitleStorage(reader["subtitle_path"].ToString());
                        subtitleStorage.Delete();

                        DBC.connection.Close();

                        DBC.connection.Open();

                        query = "DELETE FROM movies WHERE id= @movie_id";

                        command = new MySqlCommand(query, DBC.connection);
                        command.Parameters.Add("@movie_id", MySqlDbType.Int64);
                        command.Parameters["@movie_id"].Value = BrowseMovieItem.ClickedMovieID;

                        if (command.ExecuteNonQuery() != -1)
                        {
                            DBC.connection.Close();

                            DBC.connection.Open();

                            query = "DELETE FROM last_watched WHERE movie_id= @movie_id";

                            command = new MySqlCommand(query, DBC.connection);
                            command.Parameters.Add("@movie_id", MySqlDbType.Int64);
                            command.Parameters["@movie_id"].Value = BrowseMovieItem.ClickedMovieID;

                            if (command.ExecuteNonQuery() != -1)
                            {
                                this.Close();
                            }
                            else
                            {
                                Console.WriteLine("Film tidak berhasil di hapus");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Film tidak berhasil di hapus");
                        }
                    }
                }catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
                finally
                {
                    DBC.connection.Close();
                }
            }
        }