示例#1
0
文件: BLBooks.cs 项目: H8855/IIO11300
 public static List <Book> getBooks(Boolean useDB)
 {
     try
     {
         DataTable   dt;
         List <Book> temp = new List <Book>();
         //haetaan kirjoja, db-kerroksen palauttama datatable mapataan olioiksi
         if (useDB)
         {
             dt = DBBooks.GetBooks(cs);
         }
         else
         {
             dt = DBBooks.GetTestData();
         }
         //tehdään ORM eli DataTablen rivit muutetaan olioiksi
         Book book;
         foreach (DataRow dr in dt.Rows)
         {
             book         = new Book((int)dr[0]);
             book.Author  = dr["author"].ToString();
             book.Name    = dr["name"].ToString();
             book.Country = dr["country"].ToString();
             book.Year    = (int)dr["year"];
             //olio lisätään kokoelmaan
             temp.Add(book);
         }
         return(temp);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
文件: BLBooks.cs 项目: H8855/IIO11300
 public static void UpdateBook(Book book)
 {
     try
     {
         int lkm = DBBooks.UpdateBook(cs, book.Id, book.Name, book.Author, book.Country, book.Year);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }