Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        private NpgsqlDate GetDate(string msg)
        {
            Console.WriteLine(msg);
            string res = Console.ReadLine();

            return(NpgsqlDate.Parse(res));
        }
Esempio n. 6
0
 internal static object ToDate(NpgsqlBackendTypeInfo typeInfo, String backendData, Int16 typeSize, Int32 typeModifier)
 {
     return(NpgsqlDate.Parse(backendData));
 }
Esempio n. 7
0
        internal static object ToDate(NpgsqlBackendTypeInfo typeInfo, byte[] bBackendData, Int16 typeSize, Int32 typeModifier)
        {
            string backendData = BackendEncoding.UTF8Encoding.GetString(bBackendData);

            return(NpgsqlDate.Parse(backendData));
        }