public static void UpdateMovie(int id, string title, string description, string directors, string writers, string stars, string picture, int genreId, string releaseDate) { const string query = "UPDATE movie " + "SET (name, description, director, writer, stars, picture, genre_id, release_date) " + "= (@title, @description, @directors, @writers, @stars, @picture, @genre_id, @release_date) " + "WHERE id = @id"; try { using var cmd = new NpgsqlCommand(query, Con); cmd.Parameters.AddWithValue("title", title); cmd.Parameters.AddWithValue("description", description); cmd.Parameters.AddWithValue("directors", directors); cmd.Parameters.AddWithValue("writers", writers); cmd.Parameters.AddWithValue("stars", stars); cmd.Parameters.AddWithValue("picture", picture); cmd.Parameters.AddWithValue("genre_id", genreId); cmd.Parameters.AddWithValue("release_date", NpgsqlDate.Parse(releaseDate)); cmd.Parameters.AddWithValue("id", id); cmd.Prepare(); cmd.ExecuteNonQuery(); } catch (Exception e) { CustomMessageBox.Show(e.Message); } }
public static void AddMovie(string title, string description, string directors, string writers, string stars, string picture, int genreId, string releaseDate) { const string query = "INSERT INTO movie (name, description, director, writer, stars, picture, genre_id, release_date) " + "VALUES (@title, @description, @directors, @writers, @stars, @picture, @genre_id, @release_date)"; try { using var cmd = new NpgsqlCommand(query, Con); cmd.Parameters.AddWithValue("title", title); cmd.Parameters.AddWithValue("description", description); cmd.Parameters.AddWithValue("directors", directors); cmd.Parameters.AddWithValue("writers", writers); cmd.Parameters.AddWithValue("stars", stars); cmd.Parameters.AddWithValue("picture", picture); cmd.Parameters.AddWithValue("genre_id", genreId); cmd.Parameters.AddWithValue("release_date", NpgsqlDate.Parse(releaseDate)); cmd.Prepare(); cmd.ExecuteNonQuery(); // Delete the index to prevent errors SearchController.RemoveIndex(); } catch (Exception e) { CustomMessageBox.Show(e.Message); } }
private Author GetAuthorValues(Author author) { Author res = new Author(); if (author != null) { Console.WriteLine("Current author"); Console.WriteLine(author); res.Id = author.Id; } Console.WriteLine("Enter signature:"); res.Signature = Console.ReadLine(); res.Person = new Person(); Console.WriteLine("Enter name:"); res.Person.Name = Console.ReadLine(); Console.WriteLine("Enter surname:"); res.Person.Surname = Console.ReadLine(); Console.WriteLine("Enter birthdate(or null if u don't want to enter this value)"); string birthdate = Console.ReadLine(); if (birthdate == "null") { res.Person.BirthDate = null; } else { res.Person.BirthDate = NpgsqlDate.Parse(birthdate); } return(res); }
private Reader GetReaderValues(Reader reader) { Reader res = new Reader(); if (reader != null) { Console.WriteLine("Current author"); Console.WriteLine(reader); res.Id = reader.Id; } Console.WriteLine("Enter favouritegenre:"); res.FavouriteGenre = Console.ReadLine(); res.Person = new Person(); Console.WriteLine("Enter name:"); res.Person.Name = Console.ReadLine(); Console.WriteLine("Enter surname:"); res.Person.Surname = Console.ReadLine(); Console.WriteLine("Enter birthdate(or null if u don't want to enter this value)"); string birthdate = Console.ReadLine(); if (birthdate == "null") { res.Person.BirthDate = null; } else { res.Person.BirthDate = NpgsqlDate.Parse(birthdate); } return(res); }
private NpgsqlDate GetDate(string msg) { Console.WriteLine(msg); string res = Console.ReadLine(); return(NpgsqlDate.Parse(res)); }
internal static object ToDate(NpgsqlBackendTypeInfo typeInfo, String backendData, Int16 typeSize, Int32 typeModifier) { return(NpgsqlDate.Parse(backendData)); }
internal static object ToDate(NpgsqlBackendTypeInfo typeInfo, byte[] bBackendData, Int16 typeSize, Int32 typeModifier) { string backendData = BackendEncoding.UTF8Encoding.GetString(bBackendData); return(NpgsqlDate.Parse(backendData)); }