private void ImportFromIMDB() { string URL = tb_Url.Text; string id; int IndexIDStart; int IndexIDEnd; IndexIDStart = URL.IndexOf("/title/") + 7; if (IndexIDStart == -1) { throw new Exception("IMDB_ID_NOT_FOUND"); } IndexIDEnd = URL.IndexOf("/", IndexIDStart); if (IndexIDEnd == -1 && URL.IndexOf("tt") == 0) { id = URL; } else if (IndexIDEnd != -1) { id = URL.Substring(IndexIDStart, IndexIDEnd - IndexIDStart); } else { throw new Exception("ID_FORMAT_INVALID"); } MovieObject movie = Database_Connector.GetFromIMDB(id); movie.Category = CategoryObject.GetCategoryID(GetSelectedCategory()); Database_Connector.Insert.Movie(movie); }
private MovieObject GetMovieFromSelectedRow() { foreach (DataGridViewRow row in dgv_SearchResults.SelectedRows) { MovieObject movie = new MovieObject(); DateTime date = (DateTime)row.Cells[6].Value; movie.ID = int.Parse(row.Cells[0].Value.ToString()); movie.Nom_en = row.Cells[1].Value.ToString(); movie.Nom_fr = row.Cells[2].Value.ToString(); movie.Description_en = row.Cells[3].Value.ToString(); movie.Description_fr = row.Cells[4].Value.ToString(); movie.Director = row.Cells[5].Value.ToString(); movie.Date = date; movie.Rated = row.Cells[7].Value.ToString(); movie.Runtime = int.Parse(row.Cells[8].Value.ToString()); var data = (Byte[])(row.Cells[9].Value); var stream = new MemoryStream(data); movie.Poster = Image.FromStream(stream); movie.Category = CategoryObject.GetCategoryID(row.Cells[11].Value.ToString()); return(movie); } return(new MovieObject()); }
private void btn_Modify_Click(object sender, EventArgs e) { try { MovieObject oMovie = new MovieObject(); oMovie.Category = CategoryObject.GetCategoryID(cb_Categories.Text); oMovie.ID = movie.ID; oMovie.Nom_en = lb_TitreEN.Text.ToString(); oMovie.Nom_fr = lb_TitreFR.Text.ToString(); oMovie.Description_fr = lb_DescFR.Text.ToString(); oMovie.Description_en = lb_DescEN.Text.ToString(); //oMovie.Date = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture); oMovie.Date = DateTime.ParseExact(dtp.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); oMovie.Rated = lb_Rating.Text.ToString(); oMovie.Runtime = int.Parse(lb_Time.Text.ToString()); oMovie.Director = lb_Director.Text.ToString(); oMovie.Poster = pictureBox1.Image; Database_Connector.Update.Movie(oMovie); MessageBox.Show("Modification fait!"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }