protected void btnConfirm_Click(object sender, EventArgs e) { Int64 readerId = Int64.Parse(Session["ReaderId"].ToString()); DateTime dateAdded = DateTime.Now; DateTime dateEnd = dateAdded.AddDays(10); List <Int32> bookList = new List <Int32>(); if (Session["bookId1"] != null) { if (Session["bookId2"] != null) { if (Session["bookId3"] != null) { bookList.Add(Int32.Parse(Session["bookId1"].ToString())); bookList.Add(Int32.Parse(Session["bookId2"].ToString())); bookList.Add(Int32.Parse(Session["bookId3"].ToString())); } else { bookList.Add(Int32.Parse(Session["bookId1"].ToString())); bookList.Add(Int32.Parse(Session["bookId2"].ToString())); } } else { bookList.Add(Int32.Parse(Session["bookId1"].ToString())); } } else { Response.Redirect("Book.aspx"); } CertificateBLL certificateBLL = new CertificateBLL(1, readerId, dateAdded, dateEnd); BorrowBookBLL borrowBookBLL = new BorrowBookBLL(); try { borrowBookBLL.Add(certificateBLL, bookList); string script = "alert(\"Success!\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); this.btnConfirm.Visible = false; this.btnCancel.Visible = false; Session.Abandon(); //Response.Redirect("Reader.aspx"); } catch (Exception ex) { string script = "alert(\"Error while add certificate: " + ex.Message + "\");"; ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true); } }