コード例 #1
0
        protected void btnIssue_Click(object sender, EventArgs e)
        {
            
            foreach (GridViewRow row in GridView1.Rows)
            {
                CheckBox cb = (CheckBox)row.FindControl("ckbSelBook");
                if (cb.Checked)
                {
                    IssueDAL issueDAL = new IssueDAL();
                    BookDAL bookDAL = new BookDAL();

                    //Calculate issued copy and retrieve number of copies 
                    int bookID = Convert.ToInt16(row.Cells[1].Text);
                    int issuedCopies = issueDAL.CountCopies(bookID);
                    int NumberOfCopies = bookDAL.GetNumberOfCopies(bookID);

                    if (issuedCopies < NumberOfCopies)
                    {
                        issueDAL.IssueBook(Convert.ToInt16(Session["UserID"]), Convert.ToInt16(row.Cells[1].Text));  //@TODO add userID
                        lblStatus.Text = "Book has been Issued Successfully";
                    }
                    else
                    {
                        lblStatus.Text = "The Book is not available at the moment";
                    }
                }
            }
        }