public partial class BookLending : System.Web.UI.Page
{
LendService lendSrv = new LendService();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["ReaderId"] != null)
{
if (Request.QueryString["bookid"] != null)
{
int yonghubianhao = Convert.ToInt16(Session["ReaderId"]);
int tushubianhao = Convert.ToInt16(Request.QueryString["bookid"]);
lendSrv.AddBorrowRecord(yonghubianhao, tushubianhao, DateTime.Now,DateTime.MaxValue);
}
}
else
{
Response.Redirect("~/Login.aspx");
}
}
GridView1.DataSource = lendSrv.bookshowByid(Convert.ToInt16(Session["ReaderId"]));
GridView1.DataBind();
}
protected void btnborrow_Click(object sender, EventArgs e)
{
Response.Redirect("~/Bookchaxun.aspx");
}
protected void btndelete_Click(object sender, EventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
CheckBox chkBook = new CheckBox();
chkBook = (CheckBox)GridView1.Rows[i].FindControl("CheckBox12");
if (chkBook != null)
{
if (chkBook.Checked == true)
{
int bookId = int.Parse(GridView1.Rows[i].Cells[1].Text);
lendSrv.DeleteBorrowRecord(int.Parse(Session["ReaderId"].ToString()), bookId);
}
}
}
GridView1.DataSource = lendSrv.bookshowByid(Convert.ToInt16(Session["ReaderId"]));
GridView1.DataBind();
}