public void AddFilm(Film newFilmToAdd) { try { Connect(); cmd = new OracleCommand(); cmd.Connection = con; cmd.CommandText = "INSERT INTO FILM (FILMNAAM, RATING, KIJKWIJZER, GENRE, KWALITEIT, DIMENSIONAAL,LENGTE) VALUES ( :NewFilmnaam,:NewRating, :NewKijkwijzer, :NewGenre, :NewKwaliteit, :NewDimensionaal, :NewLengte)"; cmd.Parameters.Add("NewFilmnaam", OracleDbType.Varchar2).Value = newFilmToAdd.FilmNaam; cmd.Parameters.Add("NewRating", OracleDbType.Int32).Value = newFilmToAdd.Rating; cmd.Parameters.Add("NewKijkwijzer", OracleDbType.Varchar2).Value = newFilmToAdd.Kijkwijzer; cmd.Parameters.Add("NewGenre", OracleDbType.Varchar2).Value = newFilmToAdd.Genre; cmd.Parameters.Add("NewKwaliteit", OracleDbType.Varchar2).Value = newFilmToAdd.Kwaliteit; cmd.Parameters.Add("NewDimensionaal", OracleDbType.Varchar2).Value = newFilmToAdd.is3D; cmd.Parameters.Add("NewLengte", OracleDbType.Int32).Value = newFilmToAdd.Lengte; cmd.ExecuteNonQuery(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); } finally { Disconnect(); } }
public Film GetFilm(int filmid) { Film filmtoadd = null; try { Connect(); this.cmd = new OracleCommand(); this.cmd.Connection = this.con; this.cmd.CommandText = "SELECT * FROM FILM WHERE FILMID =:NewFilmID"; cmd.Parameters.Add("NewFilmID", filmid); this.cmd.CommandType = System.Data.CommandType.Text; this.dr = this.cmd.ExecuteReader(); while (dr.Read()) { var filmID = SafeReadInt(dr, 0); var filmnaam = SafeReadString(dr, 1); var rating = SafeReadInt(dr, 2); var kijkwijzer = SafeReadString(dr, 3); var genre = SafeReadString(dr, 4); var kwaliteit = SafeReadString(dr, 5); var dimensionaal = SafeReadString(dr, 6); var lengte = SafeReadInt(dr, 7); bool is3d; if (dimensionaal == "3D") { is3d = true; } else { is3d = false; } filmtoadd = new Film(filmID, filmnaam, rating, kijkwijzer, genre, kwaliteit, is3d, lengte.ToString()); } } catch (Exception ex) { Debug.WriteLine(ex.Message); return null; } finally { Disconnect(); } return filmtoadd; }
public static void AddFilm(Film film) { DatabaseHandler db = new DatabaseHandler(); db.AddFilm(film); }