/// <summary> /// 搜索图书 /// 按书名 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BSearch_Click(object sender, EventArgs e) { string queryCondition = "bookName:" + TextBInputSearch.Text;//获取用户搜索条件 List <Book> queryBooks = OnlineBookStore.App_Code.User.QueryBookFromDb(queryCondition); GridVShowBook.DataSource = queryBooks;//绑定用户查询的书籍 GridVShowBook.DataBind(); }
/// <summary> /// 高级搜索模块 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BConSearchGo_OnClick(object sender, EventArgs e) { string bookId = TextBConBookID.Text; string bookCategory = lbCategory.Text; string bookAuthor = TextBConAuthor.Text; string bookPress = TextBConPress.Text; //组装查询语句,供生成数据库查询语句 string queryCondition = null; if (bookCategory != "") { AddSpaceOrNot(queryCondition); queryCondition += "bookCategory:" + bookCategory; } if (bookId != "") { AddSpaceOrNot(queryCondition); queryCondition += "bookID:" + bookId; } if (bookAuthor != "") { AddSpaceOrNot(queryCondition); queryCondition += "bookAuthor:" + bookAuthor; } if (bookPress != "") { AddSpaceOrNot(queryCondition); queryCondition += "bookPress:" + bookPress; } List <Book> queryBookList = OnlineBookStore.App_Code.User.QueryBookFromDb(queryCondition); //获取到需要查询的书籍 GridVShowBook.DataSource = queryBookList; //绑定用户查询的书籍 GridVShowBook.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] != null) { manager = (Manager)Session["User"]; } //根据销量查询书籍 if (Session["DefaultBook"] == null) { defaultBooks = OnlineBookStore.App_Code.User.RecommendedBook(); //根据销量展示 Session["DefaultBook"] = defaultBooks; //存储,减少数据库访问 } //直接读取已经存储的书籍 else { defaultBooks = (List <Book>)Session["DefaultBook"]; } if (!IsPostBack) { GridVShowBook.DataSource = defaultBooks; GridVShowBook.DataBind(); } }