protected void btnSearch_Click(object sender, EventArgs e) { string sql = ""; int item = searchItem.SelectedIndex; switch (item) { case 0: sql = "select * from tb_bookInfo where bookBarCode like " + target.Text; break; case 1: sql = "select * from tb_bookInfo where bookName like '" + target.Text + "'"; break; case 2: sql = "select * from tb_bookInfo where bookType like " + target.Text; break; case 3: sql = "select * from tb_bookInfo where bookCase like '" + target.Text + "'"; break; case 4: sql = "select * from tb_bookInfo where author like '" + target.Text + "'"; break; } gvBookInfo.DataSource = DataOperate.GetDataset(sql, "tb_bookInfo"); gvBookInfo.DataKeyNames = new string[] { "bookBarCode" }; gvBookInfo.DataBind(); }
protected void btnBookSearch_Click(object sender, EventArgs e) { if (Convert.ToInt32(borrowCount.Text.Trim()) > 0) //判断读者是否还可以借书 { if (bookBarCode.Text.Trim() != "") //判断图书条形码是否为空 { string BookBarCode = bookBarCode.Text; //获取图书条形码 string sql = "select * from tb_bookBorrow left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode left join tb_bookType on tb_bookInfo.bookType = tb_bookType.bookTypeID left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode where tb_bookBorrow.bookBarCode='" + BookBarCode + "'and tb_bookBorrow.readerBarCode='" + readerBarCode.Text + "'"; DataSet ds = DataOperate.GetDataset(sql, "tb_bookBorrow"); //调用公共类中getDataSet方法,将查询结果返回给DataSet对象 if (ds.Tables[0].Rows.Count > 0) //查询结果非空 { gvBookReturn.DataSource = ds; //获取数据源 gvBookReturn.DataKeyNames = new string[] { "bookBarCode" }; //设置主键 gvBookReturn.DataBind(); //绑定GridView控件 } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书条形码错误!')</script>"); } } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('图书条形码不能为空!')</script>"); } } else { ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('借阅数量已满!不可以再借阅!')</script>"); } }
protected void btnSearch_Click(object sender, EventArgs e) { string sql = ""; int item = searchItem.SelectedIndex; switch (item) { case 0: sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_bookBorrow.bookBarCode like '" + target.Text + "'"; break; case 1: sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_bookInfo.bookName like '" + target.Text + "'"; break; case 2: sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_bookBorrow.readerBarCode like '" + target.Text + "'"; break; case 3: sql = "select * from tb_bookBorrow left join tb_readerInfo on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode left join tb_bookInfo on tb_bookBorrow.bookBarCode = tb_bookInfo.bookBarCode where tb_readerInfo.readerName like '" + target.Text + "'"; break; } gvBorrowInfo.DataSource = DataOperate.GetDataset(sql, "tb_bookBorrow"); gvBorrowInfo.DataKeyNames = new string[] { "bookBarCode" }; gvBorrowInfo.DataBind(); }
public void bindReaderInfo() { string sql = "select * from tb_readerInfo"; gvReaderInfo.DataSource = DataOperate.GetDataset(sql, "tb_readerInfo"); gvReaderInfo.DataKeyNames = new string[] { "readerBarCode" }; gvReaderInfo.DataBind(); }
public void bindReaderType() { string sql = "select * from tb_readerType"; gvReaderType.DataSource = DataOperate.GetDataset(sql, "tb_readerType"); gvReaderType.DataKeyNames = new string[] { "readerTypeID" }; gvReaderType.DataBind(); }
public void bindBookCase() { string sql = "select * from tb_bookCase"; gvBookCase.DataSource = DataOperate.GetDataset(sql, "tb_bookCase"); gvBookCase.DataKeyNames = new string[] { "bookcaseID" }; gvBookCase.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string sql1 = "select top 5 * from tb_bookInfo order by borrowSum desc"; //设置SQL语句 gvBookOrder.DataSource = DataOperate.GetDataset(sql1, "tb_bookInfo"); //获取图书信息数据源 gvBookOrder.DataBind(); string sql2 = "select tb_readerInfo.readerBarCode,tb_readerInfo.readerName,count(*) as borrowSum from tb_readerInfo inner join tb_bookBorrow on tb_bookBorrow.readerBarCode = tb_readerInfo.readerBarCode group by tb_readerInfo.readerBarCode,tb_readerInfo.readerName order by count(*) desc"; gvReaderOrder.DataSource = DataOperate.GetDataset(sql2, "tb_readderInfo"); //获取图书信息数据源 gvReaderOrder.DataBind(); }