public BookInfo GetBookByID(int bookID) { SqlHelper objSqlHelper = new SqlHelper(); List<BookInfo> books = new List<BookInfo>(); SqlParameter[] objParams = new SqlParameter[1]; objParams[0] = new SqlParameter("@bookID", SqlDbType.Int, 4); objParams[0].Value = bookID; SqlDataReader reader = objSqlHelper.ExecuteReader("je_Book_GetBookByID", objParams); BookInfo item = new BookInfo(); while (reader.Read()) { //图书编号 item.BookID = reader.GetInt32(reader.GetOrdinal("BookID")); //图书名字,分类,价格,会员价格,大图,小图 item.BookName = reader.GetString(reader.GetOrdinal("BookName")); item.Category = reader.GetInt32(reader.GetOrdinal("bookCategory")); item.Price = reader.GetDecimal(reader.GetOrdinal("bookPrice")); item.MemberPrice = reader.GetDecimal(reader.GetOrdinal("bookMemberPrice")); item.BookPublish = reader.GetString(reader.GetOrdinal("BookPublish")); item.BookImage = reader.GetString(reader.GetOrdinal("BookImage")); item.BookSmallImage = reader.GetString(reader.GetOrdinal("bookSmallImage")); //是否发布,是否推荐,是否特价,是否热卖,是否允许评论,库存数量 item.IsRelease = reader.GetBoolean(reader.GetOrdinal("isRelease")); item.IsGood = reader.GetBoolean(reader.GetOrdinal("isGood")); item.IsCheap = reader.GetBoolean(reader.GetOrdinal("isCheap")); item.IsSaleGood = reader.GetBoolean(reader.GetOrdinal("isSaleGood")); item.ReviewEnable = reader.GetBoolean(reader.GetOrdinal("reviewEnable")); item.Stock = reader.GetInt32(reader.GetOrdinal("bookStock")); //图书简介,作者,出版时间,国际编号,出版社,页数,版次 item.SmallBookDec = reader.GetString(reader.GetOrdinal("smallBookDesc")); item.BookAuthor = reader.GetString(reader.GetOrdinal("bookAuthor")); item.PublishTime = reader.GetDateTime(reader.GetOrdinal("bookPublishTime")); item.BookISBN = reader.GetString(reader.GetOrdinal("bookISBN")); item.BookPublish = reader.GetString(reader.GetOrdinal("bookPublish")); item.BookPages = reader.GetInt32(reader.GetOrdinal("bookPages")); item.BookEditions = reader.GetString(reader.GetOrdinal("bookEditions")); //是否为期书,搜索关键字,加入时间,具体介绍 item.IsExpect = reader.GetBoolean(reader.GetOrdinal("isExpect")); item.SearchKey = reader.GetString(reader.GetOrdinal("searchKey")); item.BookDec = reader.GetString(reader.GetOrdinal("BookDec")); item.ReadCount = reader.GetInt32(reader.GetOrdinal("bookReadCount")); item.ReviewCount = reader.GetInt32(reader.GetOrdinal("bookCommentCount")); // item.TeacherID = reader.GetInt32(reader.GetOrdinal("TeacherID")); item.CatenaID = reader.GetInt32(reader.GetOrdinal("CatenaID")); item.Rate = reader.GetDecimal(reader.GetOrdinal("bookRate")); //折扣,团队折扣,团队价格 item.Rebate = reader.GetInt32(reader.GetOrdinal("Rebate")); item.VipRebate = reader.GetInt32(reader.GetOrdinal("VipRebate")); item.VipPrice = reader.GetDecimal(reader.GetOrdinal("VipPrice")); item.IsMain = reader.GetBoolean(reader.GetOrdinal("IsMain")); } reader.Close(); return item; }
public IList<BookInfo> GetBook(BookType type) { SqlHelper objSqlHelper = new SqlHelper(); List<BookInfo> books = new List<BookInfo>(); SqlParameter[] objParams = new SqlParameter[1]; objParams[0] = new SqlParameter("@type", SqlDbType.Int, 4); objParams[0].Value = (int)type; SqlDataReader reader = objSqlHelper.ExecuteReader("je_Book_GetBook",objParams); while (reader.Read()) { BookInfo item = new BookInfo(); item = GetBookByID(reader.GetInt32(reader.GetOrdinal("BookID"))); books.Add(item); } reader.Close(); return books; }
public IList<BookInfo> GetTopBook(int year,int month,int catID) { SqlHelper objSqlHelper = new SqlHelper(); List<BookInfo> books = new List<BookInfo>(); SqlParameter[] objParams = new SqlParameter[3]; objParams[0] = new SqlParameter("@year", SqlDbType.Int, 4); objParams[1] = new SqlParameter("@month", SqlDbType.Int, 4); objParams[2] = new SqlParameter("@catID", SqlDbType.Int, 4); SqlDataReader reader = objSqlHelper.ExecuteReader("je_Book_GetTopBook", objParams); while (reader.Read()) { BookInfo item = new BookInfo(); item = GetBookByID(reader.GetInt32(reader.GetOrdinal("BookID"))); books.Add(item); } reader.Close(); return books; }
public static int UpdateBook(BookInfo book) { return books.UpdateBook(book); }
/// <summary> /// 新增图书信息 /// </summary> /// <returns></returns> public static void InsertBook(BookInfo book) { books.InsertBook(book); }
/// <summary> /// 更新图书价格 /// </summary> /// <param name="book"></param> /// <returns></returns> public static int UpdatePrice(BookInfo book) { return books.UpdatePrice(book); }
public int UpdatePrice(BookInfo book) { SqlHelper objSqlHelper = new SqlHelper(); SqlParameter[] objParams = new SqlParameter[3]; objParams[0] = new SqlParameter("@bookPrice", book.Price); objParams[1] = new SqlParameter("@bookMemberPrice", book.MemberPrice); objParams[2] = new SqlParameter("@bookID", book.BookID); return objSqlHelper.ExecuteNonQuery("je_Book_UpdatePrice", objParams); }
public int UpdateBook(BookInfo book) { SqlHelper objSqlHelper = new SqlHelper(); SqlParameter[] objParams = new SqlParameter[27]; //图书名字,分类,价格,会员价格,大图,小图 objParams[0] = new SqlParameter("@bookName", book.BookName); objParams[1] = new SqlParameter("@bookCategory", book.Category); objParams[2] = new SqlParameter("@bookPrice", book.Price); objParams[3] = new SqlParameter("@bookMemberPrice", book.MemberPrice); objParams[4] = new SqlParameter("@bookImage", StringHelper.convertStr(book.BookImage)); objParams[5] = new SqlParameter("@bookSmallImage", StringHelper.convertStr(book.BookSmallImage)); //是否发布,是否推荐,是否特价,是否热卖,是否允许评论,库存数量 objParams[6] = new SqlParameter("@isRelease", book.IsRelease); objParams[7] = new SqlParameter("@isCheap", book.IsCheap); objParams[8] = new SqlParameter("@isGood", book.IsGood); objParams[9] = new SqlParameter("@isSaleGood", book.IsSaleGood); objParams[10] = new SqlParameter("@reviewEnable", book.ReviewEnable); objParams[11] = new SqlParameter("@bookStock", book.Stock); //图书简介,作者,出版时间,国际编号,出版社,页数,版次 objParams[12] = new SqlParameter("@smallBookDesc", StringHelper.convertStr(book.SmallBookDec)); objParams[13] = new SqlParameter("@bookAuthor", StringHelper.convertStr(book.BookAuthor)); objParams[14] = new SqlParameter("@bookPublishTime", book.PublishTime); objParams[15] = new SqlParameter("@bookISBN", StringHelper.convertStr(book.BookISBN)); objParams[16] = new SqlParameter("@bookPublish", book.BookPublish); objParams[17] = new SqlParameter("@bookPages", book.BookPages); objParams[18] = new SqlParameter("@bookEditions", StringHelper.convertStr(book.BookEditions)); //是否为期书,搜索关键字,加入时间,具体介绍 objParams[19] = new SqlParameter("@isExpect", book.IsExpect); objParams[20] = new SqlParameter("@searchKey", StringHelper.convertStr(book.SearchKey)); objParams[21] = new SqlParameter("@TeacherID", book.TeacherID); objParams[22] = new SqlParameter("@BookDec", StringHelper.convertStr(book.BookDec)); objParams[23] = new SqlParameter("@CatenaID", book.CatenaID); objParams[24] = new SqlParameter("@bookID", book.BookID); objParams[25] = new SqlParameter("@VipPrice", book.VipPrice); objParams[26] = new SqlParameter("@IsMain", book.IsMain); return objSqlHelper.ExecuteNonQuery("je_Book_UpdateBook", objParams); }
public IList<BookInfo> GetCatBookByID(string bookName) { SqlHelper objSqlHelper = new SqlHelper(); List<BookInfo> books = new List<BookInfo>(); SqlParameter[] objParams = new SqlParameter[1]; objParams[0] = new SqlParameter("@bookName", SqlDbType.VarChar, 50); objParams[0].Value = bookName; SqlDataReader reader = objSqlHelper.ExecuteReader("je_Book_GetCatBookByID", objParams); while (reader.Read()) { BookInfo item = new BookInfo(); item.BookID = reader.GetInt32(reader.GetOrdinal("BookID")); item.BookName = reader.GetString(reader.GetOrdinal("BookName")); item.BookPublish = reader.GetString(reader.GetOrdinal("BookPublish")); item.BookImage = reader.GetString(reader.GetOrdinal("BookImage")); item.Price = reader.GetDecimal(reader.GetOrdinal("bookPrice")); item.MemberPrice = reader.GetDecimal(reader.GetOrdinal("bookMemberPrice")); item.BookSmallImage = reader.GetString(reader.GetOrdinal("bookSmallImage")); books.Add(item); } reader.Close(); return books; }