private void btnAddToWatchlist_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbTitle.Text) && string.IsNullOrEmpty(tbYear.Text) && string.IsNullOrEmpty(tbRated.Text) && string.IsNullOrEmpty(tbReleased.Text) && string.IsNullOrEmpty(tbGenre.Text) && string.IsNullOrEmpty(tbActors.Text) && string.IsNullOrEmpty(tbPlot.Text) && string.IsNullOrEmpty(tbMetascore.Text) && string.IsNullOrEmpty(pbPoster.ImageLocation)) { MessageBox.Show("Fields cannot be empty!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Image img = pbPoster.Image; byte[] arr; ImageConverter converter = new ImageConverter(); arr = (byte[])converter.ConvertTo(img, typeof(byte[])); ImdbEntity obj = new ImdbEntity() { Title = tbTitle.Text, Year = tbYear.Text, Rated = tbRated.Text, Released = tbReleased.Text, Genre = tbGenre.Text, Actors = tbActors.Text, Plot = tbPlot.Text, Metascore = tbMetascore.Text, Poster = pbPoster.ImageLocation, Picture = arr }; DAL.AddMovie(obj); }
public static void AddMovie(ImdbEntity imdbentity) { string connectionString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString; using (SqlConnection conn = new SqlConnection(connectionString)) { using (SqlCommand cmd = new SqlCommand("AddNewMovie", conn)) { conn.Open(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Title", imdbentity.Title); cmd.Parameters.AddWithValue("@Year", imdbentity.Year); cmd.Parameters.AddWithValue("@imdbRating", imdbentity.Rated); cmd.Parameters.AddWithValue("@Released", imdbentity.Released); cmd.Parameters.AddWithValue("@Genre", imdbentity.Genre); cmd.Parameters.AddWithValue("@Actors", imdbentity.Actors); cmd.Parameters.AddWithValue("@Plot", imdbentity.Plot); cmd.Parameters.AddWithValue("@Metascore", imdbentity.Metascore); cmd.Parameters.AddWithValue("@Poster", imdbentity.Poster); cmd.Parameters.AddWithValue("@Image", imdbentity.Picture); var i = cmd.ExecuteNonQuery(); if (i >= 1) { MessageBox.Show("Movie is added to watch list!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Movie already exist in your watchlist!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
public MovieDetailsForm(ImdbEntity obj) { InitializeComponent(); tbTitle.Text = obj.Title; tbYear.Text = obj.Year; tbRated.Text = obj.imdbRating; tbReleased.Text = obj.Released; tbGenre.Text = obj.Genre; tbActors.Text = obj.Actors; tbPlot.Text = obj.Plot; tbMetascore.Text = obj.Metascore; pbPoster.ImageLocation = obj.Poster; btnLeft.Hide(); btnRight.Hide(); }