Esempio n. 1
0
        public List <suggestion> list2()
        {
            List <suggestion> libraryModels = new List <suggestion>();
            SqlConnection     con           = new SqlConnection(path);

            con.Open();
            SqlCommand    cmd    = new SqlCommand("select * from suggestions1", con);
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                suggestion lib = new suggestion();
                lib.SuggestionId      = reader.GetInt32(0);
                lib.BookName          = reader.GetString(1);
                lib.BookAuthor        = reader.GetString(2);
                lib.BookPublishedYear = reader.GetInt32(3);

                if (!reader.IsDBNull(4))
                {
                    lib.status = reader.GetString(4);
                }

                if (!reader.IsDBNull(5))
                {
                    lib.BookCategory = reader.GetString(5);
                }

                libraryModels.Add(lib);
            }
            reader.Close();
            con.Close();
            return(libraryModels);
        }
Esempio n. 2
0
        public void suggest(suggestion bookk)
        {
            SqlConnection con = new SqlConnection(path);

            con.Open();
            SqlCommand cmd      = new SqlCommand($"INSERT INTO suggestions1( Book_Name,Book_Published_Year,Book_Author,Book_Category) VALUES('{bookk.BookName}','{bookk.BookPublishedYear}','{bookk.BookAuthor}','{bookk.BookCategory}')", con);
            int        RowCount = cmd.ExecuteNonQuery();

            con.Close();
        }