예제 #1
0
        //get all the books
        public List<BookEN> getCookwares()
        {
            List<BookEN> books = new List<BookEN>();

            String sql = "SELECT * FROM Book";
            // string sql = "SELECT * FROM NOTES ORDER BY ID DESC";
            SqlConnection con = new SqlConnection(db);

            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand(sql, con);
                SqlDataReader reader = cmd.ExecuteReader();
                BookEN bookTemp = new BookEN();

                while (reader.Read())
                {
                    bookTemp = new BookEN();

                    bookTemp.Author = reader["Author"].ToString();
                    bookTemp.Date = reader["Date"].ToString();
                    bookTemp.Isbn = reader["Isbn"].ToString();
                    bookTemp.Title = reader["Title"].ToString();

                    books.Add(bookTemp);
                }
            }
            catch (Exception ex) { }
            finally
            {
                con.Close();
            }

            return books;
        }
예제 #2
0
 //Function to add a new book
 public bool insertBook(BookEN book)
 {
     bool added = false;
     SqlConnection c = new SqlConnection(db);
     try
     {
         c.Open();
         SqlCommand com = new SqlCommand("INSERT INTO Book VALUES (" + book.Title + ", " + book.Author + "," + book.Isbn + "," + book.Date + ")", c);
         com.ExecuteNonQuery();
         added = true;
     }
     catch (Exception ex) { }
     finally
     {
         c.Close();
     }
     return added;
 }
예제 #3
0
        public BookEN getBook(RecipeEN recipe)
        {
            BookEN book = new BookEN();
            SqlConnection c = new SqlConnection(db);
            try
            {
                c.Open();
                SqlCommand com = new SqlCommand("SELECT FROM Book WHERE Title = '" + recipe.Book + "'", c);
                SqlDataReader dr = com.ExecuteReader();

                if (dr.Read())
                {
                    book.Author = dr["Author"].ToString();
                    book.Date = dr["Date"].ToString();
                    book.Isbn = dr["Isbn"].ToString();
                    book.Title = dr["Title"].ToString();
                }
            }
            catch (Exception ex) { }
            finally { c.Close(); }
            return book;
        }
예제 #4
0
 //Function to add a new book
 public void insertBook(BookEN book)
 {
 }
예제 #5
0
 // Get all the books
 public List<BookEN> getBooks()
 {
     BookEN books = new BookEN();
     return books.getBooks();
 }