Exemplo n.º 1
0
        private void btnBorrow_Click(object sender, EventArgs e)
        {
            if (dtpBorrowed.Value < dtpDue.Value)
            {
                CirculatedCopy cc = new CirculatedCopy();
                cc.CopyNumber   = int.Parse(txtCopyNumber.Text);
                cc.MemberNumber = int.Parse(txtMemberCode.Text);
                cc.BorrowedDate = dtpBorrowed.Value;
                cc.DueDate      = dtpDue.Value;

                if (CirculatedCopyDAO.Add(cc))
                {
                    Copy c = CopyDAO.GetCopy(int.Parse(txtCopyNumber.Text));
                    c.Type = 1;
                    CopyDAO.UpdateType(c);
                    display(2);
                    view(int.Parse(txtMemberCode.Text));
                    MessageBox.Show("Add Successful.");

                    if (check == 1)
                    {
                        Reservation r = ReservationDAO.GetFirstReservation(c.BookNumber);
                        r.Status = true;
                        ReservationDAO.UpdateStatus(r);
                    }

                    if (dgvBorrowedBooks.Rows.Count >= 5)
                    {
                        display(0);
                        MessageBox.Show("The number of borrowed books is 5. You can not borrow anymore book.");
                    }
                }
                else
                {
                    MessageBox.Show("Error.");
                }
            }
            else
            {
                MessageBox.Show("Borrowed date has to be smaller than Due date.");
            }
        }