/// <summary> /// Met a jour les informations d'un film /// </summary> /// <param name="film"></param> public async void update(Film film) { using (SQLiteCommand command = new SQLiteCommand($"UPDATE {TABLE_FILMS} " + $"SET {FILMS_CHEMIN} =@chemin, {FILMS_TITRE} = @titre, {FILMS_REALISATEUR}=@realisateur, {FILMS_ACTEURS}=@acteurs, " + $"{FILMS_GENRES}=@genres, {FILMS_NATIONALITE}=@nationalite, {FILMS_RESUME}=@resume, {FILMS_DATESORTIE}=@datesortie, " + $"{FILMS_ETAT}=@etat, {FILMS_DATEVU}=@datevu, {FILMS_TAG}=@tag, {FILMS_FLAGS}=@flags" + $" WHERE {FILMS_ID} = @id")) { command.Parameters.AddWithValue("@id", film.Id); command.Parameters.AddWithValue("@chemin", film.Chemin); command.Parameters.AddWithValue("@titre", film.Titre); command.Parameters.AddWithValue("@realisateur", film.Realisateur); command.Parameters.AddWithValue("@acteurs", film.Acteurs); command.Parameters.AddWithValue("@genres", film.Genres); command.Parameters.AddWithValue("@nationalite", film.Nationalite); command.Parameters.AddWithValue("@datesortie", film.DateSortie); command.Parameters.AddWithValue("@resume", film.Resume); command.Parameters.AddWithValue("@datevu", film.DateVu.Ticks); command.Parameters.AddWithValue("@tag", film.Etiquettes); command.Parameters.AddWithValue("@image", BaseFilms.SqlBinaryPeutEtreNull(Images.imageToByteArray(film.Affiche))); command.Parameters.AddWithValue("@etat", film.EtatInt); command.Parameters.AddWithValue("@flags", film.Flags); executeNonQuery(command); sauveAlternatives(film.Id, film.Alternatives()); } }
public void sauveAlternatives(int id, List <InfosFilm> alternatives) { using (SQLiteCommand command = new SQLiteCommand($"DELETE FROM {TABLE_ALTERNATIVES} WHERE {ALTERNATIVES_FILMID} = @id")) { command.Parameters.AddWithValue("@id", id); executeNonQuery(command); } // Ajouter les nouvelles alternatives, associees au film dont on donne l'id if (alternatives != null) { foreach (InfosFilm alternative in alternatives) { using (SQLiteCommand command = new SQLiteCommand($"INSERT into {TABLE_ALTERNATIVES} " + $"({ALTERNATIVES_FILMID}, {ALTERNATIVES_REALISATEUR}, {ALTERNATIVES_ACTEURS}, {ALTERNATIVES_GENRES}, {ALTERNATIVES_NATIONALITE}, {ALTERNATIVES_RESUME}, {ALTERNATIVES_DATESORTIE}, {ALTERNATIVES_IMAGE})" + " VALUES (@id, @realisateur, @acteurs, @genres, @nationalite, @resume, @datesortie, @affiche)")) { command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@realisateur", alternative._realisateur); command.Parameters.AddWithValue("@acteurs", alternative._acteurs); command.Parameters.AddWithValue("@genres", alternative._genres); command.Parameters.AddWithValue("@nationalite", alternative._nationalite); command.Parameters.AddWithValue("@datesortie", alternative._dateSortie); command.Parameters.AddWithValue("@resume", alternative._resume); command.Parameters.AddWithValue("@affiche", BaseFilms.SqlBinaryPeutEtreNull(Images.imageToByteArray(alternative._image))); executeNonQuery(command); } } } }
public async void ajouteFilm(Film f) { using (SQLiteCommand command = new SQLiteCommand($"INSERT into {TABLE_FILMS} " + $"({FILMS_CHEMIN}, {FILMS_TITRE}, {FILMS_REALISATEUR}, {FILMS_ACTEURS}, {FILMS_GENRES}, {FILMS_NATIONALITE}, {FILMS_RESUME}, {FILMS_DATESORTIE}, {FILMS_ETAT}, {FILMS_TAG}, {FILMS_FLAGS}, {FILMS_IMAGE})" + " VALUES (@chemin, @titre, @realisateur, @acteurs, @genres, @nationalite, @resume, @datesortie, @etat, @tag, @flags, @image)")) { //if ( f.getImage() != null ) // f.imageId = getImageId( f.imageId, f.getImage() ); command.Parameters.AddWithValue("@chemin", f.Chemin); command.Parameters.AddWithValue("@titre", f.Titre); command.Parameters.AddWithValue("@realisateur", f.Realisateur); command.Parameters.AddWithValue("@acteurs", f.Acteurs); command.Parameters.AddWithValue("@genres", f.Genres); command.Parameters.AddWithValue("@nationalite", f.Nationalite); command.Parameters.AddWithValue("@datesortie", f.DateSortie); command.Parameters.AddWithValue("@resume", f.Resume); command.Parameters.AddWithValue("@etat", f.EtatInt); command.Parameters.AddWithValue("@tag", f.Etiquettes); command.Parameters.AddWithValue("@flags", f.Flags); command.Parameters.AddWithValue("@image", BaseFilms.SqlBinaryPeutEtreNull(Images.imageToByteArray(f.Affiche))); executeNonQuery(command); // Obtenir l'id du dernier film ajoute command.CommandText = $"select last_insert_rowid() as {FILMS_ID} from {TABLE_FILMS};"; object o = executeScalar(command); f.Id = Convert.ToInt32(o); sauveAlternatives(f.Id, f.Alternatives()); } }
internal void sauveImage(int id, Image image) { using (SQLiteCommand command = new SQLiteCommand($"UPDATE {TABLE_FILMS} SET {FILMS_IMAGE} =@image WHERE {FILMS_ID} = @id")) { command.Parameters.AddWithValue("@id", id); command.Parameters.AddWithValue("@image", BaseFilms.SqlBinaryPeutEtreNull(Images.imageToByteArray(image))); executeNonQuery(command); } }