public List <BookDetails> getLastBookID() { List <BookDetails> list = new List <BookDetails>(); string sql = ""; SqlCommand cmd = new SqlCommand(); sql = "select isnull(max(bookID)+1,1) as maxbookID from bookDetails"; SqlConnection con = new SqlConnection(db_connection_string); cmd.CommandText = sql; cmd.Connection = con; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { BookDetails c = new BookDetails(); c.bookID = int.Parse(rdr["maxbookID"].ToString()); list.Add(c); } con.Close(); return(list); }
internal List <BookDetails> getBookDetailsFromBookID(string bookID) { BookDetails book = new BookDetails(); List <BookDetails> list = new List <BookDetails>(); string sql = ""; SqlCommand cmd = new SqlCommand(); sql = "select * from bookDetails where bookID=@bookID"; SqlConnection con = new SqlConnection(db_connection_string); cmd.Parameters.AddWithValue("@bookID", bookID); cmd.CommandText = sql; cmd.Connection = con; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { BookDetails c = new BookDetails(); c.bookTitle = rdr["bookTitle"].ToString(); c.isbnCode = rdr["isbnCode"].ToString(); // c.bookLanguage = rdr["bookLanguage"].ToString(); c.author = rdr["author"].ToString(); c.publisher = rdr["publisher"].ToString(); c.price = rdr["price"].ToString(); //c.edition = rdr["edition"].ToString(); c.bookCategory = rdr["bookCategory"].ToString(); c.publisher = rdr["publisher"].ToString(); c.bookURL = rdr["bookURL"].ToString(); c.qty = rdr["qty"].ToString(); c.bookDescription = rdr["bookDescription"].ToString(); list.Add(c); } con.Close(); return(list); }