예제 #1
0
        private void borrow(CirculatedCopy cc, Copy c, Reservation r)
        {
            // Insert borrow record
            if (cc == null)
            {
                return;
            }
            CirculatedCopyDAO.Insert(cc);

            // update type = 'B' at Copy
            if (c == null)
            {
                return;
            }
            c.Type = 'B';
            CopyDAO.Update(c);


            // update status = 'A' at Reservation
            if (r == null)
            {
                return;
            }
            r.Status = 'A';
            ReserveDAO.Update(r);
        }
예제 #2
0
        private void borrow(CirculatedCopy cc, Copy c, Reservation r)
        {
            // Insert borrow record
            if (cc == null)
            {
                return;
            }
            if (CirculatedCopyDAO.Insert(cc))
            {
                txtDueDate.Text = Calendar1.SelectedDate.AddDays(14).ToString("dd/MM/yyyy");
                // update type = 'B' at Copy
                c = (Copy)Session["copy"];
                if (c == null)
                {
                    return;
                }
                c.Type = 'B';
                CopyDAO.Update(c);


                // update status = 'A' at Reservation
                r = (Reservation)Session["reser"];
                if (r == null)
                {
                    return;
                }
                r.Status = 'A';
                ReserveDAO.Update(r);
            }
            else
            {
                lblError.Text = cc.BorrowedDate.ToString("yyyy-MM-dd hh:mm:ss");
                lblError.Text = "Borrow Fail :< ";
            }
        }
예제 #3
0
        private errorBorrow checkCondition(int borrowerNumber, int copyNumber, out Copy c, out Reservation r)
        {
            c = null;
            r = null;


            c = CopyDAO.GetCopy(copyNumber);
            if (c == null)
            {
                return(errorBorrow.CopyNotExist);
            }
            if (c.Type == 'A')
            {
                return(errorBorrow.CopyReferenced);
            }
            if (c.Type == 'B')
            {
                return(errorBorrow.CopyBorrowed);
            }

            // Check if this book is reserved by others and you are not at the first of the reservation list
            int bookNumber = c.BookNumber;

            r = ReserveDAO.GetFirstReservation(bookNumber);
            if (r != null && r.BorrowerNumber != borrowerNumber)
            {
                return(errorBorrow.CopyReserved);
            }

            return(errorBorrow.OK);
        }
예제 #4
0
        private void View()
        {
            DataTable dt = ReserveDAO.GetReservation(int.Parse(txtBorrowerNumber.Text));

            GridView1.DataSource = dt;
            GridView1.DataBind();
            lblNumberReservedBooks.Text = dt.Rows.Count.ToString();
        }
예제 #5
0
        protected void btReserve_Click(object sender, EventArgs e)
        {
            Reservation rs = new Reservation(int.Parse(txtMemberCode.Text), int.Parse(txtBookNumber.Text), Calendar1.SelectedDate);

            ReserveDAO.Insert(rs);

            View();

            displayButtons(1);
        }
예제 #6
0
        protected void btnReserve_Click(object sender, EventArgs e)
        {
            Reservation re = new Reservation();

            re.BorrowerNumber = int.Parse(txtBorrowerNumber.Text);
            re.BookNumber     = int.Parse(txtBookNumber.Text);
            re.Date           = Convert.ToDateTime(Calendar1.SelectedDate.ToString());
            re.Status         = 'R';
            ReserveDAO.Insert(re);
            View();
            txtBookNumber.Text = "";
            displayButtons(1);
        }
예제 #7
0
        protected void btnBorrow_Click(object sender, EventArgs e)
        {
            DateTime receiveDate = Calendar1.SelectedDate;
            DateTime dueDate     = Calendar1.SelectedDate.AddDays(14);

            CirculatedCopy cc = new CirculatedCopy(int.Parse(txtCopyNumber.Text), int.Parse(txtBorrowerNumber.Text),
                                                   receiveDate, dueDate);

            c = CopyDAO.GetCopy(int.Parse(txtCopyNumber.Text));
            r = r = ReserveDAO.GetFirstReservation(c.BookNumber);
            borrow(cc, c, r);

            showData();
            displayButtons(1);
        }
        protected void btnReserve_Click(object sender, EventArgs e)
        {
            int      borrowerNum = int.Parse(txtBorrowerNumber.Text);
            Borrower borrower    = BorrowerDAO.GetBorrower(borrowerNum);

            Reservation rv = new Reservation(int.Parse(txtBorrowerNumber.Text), int.Parse(txtBookNumber.Text), Calendar1.SelectedDate);

            if (ReserveDAO.Insert(rv))
            {
                View(borrower);
                btnReserve.Enabled = false;
            }
            else
            {
                lblError.Text = "Reserve queue failse! ";
            }
        }
예제 #9
0
        private void View()
        {
            DataTable dt = new ReserveDAO().SelectDS(int.Parse(txtMemberCode.Text), 'R');

            dataGridView1.DataSource = dt;
            this.dataGridView1.Columns["date"].DefaultCellStyle.Format = "dd/MM/yyyy";
            int n = dataGridView1.Rows.Count - 1;

            if (n < 0)
            {
                lbNumberOfReservedBooks.Text = "0";
            }
            else
            {
                lbNumberOfReservedBooks.Text = n.ToString();
            }
        }
예제 #10
0
        private void View()
        {
            DataTable dt = ReserveDAO.SelectDS(int.Parse(txtMemberCode.Text), 'R');

            GridView1.DataSource = dt;
            GridView1.DataBind();
            int n = GridView1.Rows.Count;

            if (n < 0)
            {
                lbNumberOfReservedBooks.Text = "0";
            }
            else
            {
                lbNumberOfReservedBooks.Text = n.ToString();
            }
        }
예제 #11
0
        protected void btnCheckMember_Click(object sender, EventArgs e)
        {
            int borrowerNum;

            if (DAO.checkInt(txtBorrowerNumber.Text) == false)
            {
                lblError.Text = "Borrower number must be a integer!";

                /*MessageBox.Show("");
                 * txtMemberCode.Focus();*/
                return;
            }
            borrowerNum = int.Parse(txtBorrowerNumber.Text);
            Borrower borrower = BorrowerDAO.GetBorrower(borrowerNum);

            if (borrower != null)
            {
                txtName.Text = borrower.Name; //display name
                View(borrower);
                //MessageBox.Show("R".Equals("R") + "");
                if (ReserveDAO.GetLastReserveOfBorrower(int.Parse(txtBorrowerNumber.Text)) != null &&
                    ReserveDAO.GetLastReserveOfBorrower(int.Parse(txtBorrowerNumber.Text)).Status.ToString().Equals("R"))    //mean the last record still R
                {
                    //have a book in reserve
                    /* MessageBox.Show("Oops! you have book in reserve queue! You can't reserve book until it's over");*/
                    lblError.Text           = "Oops! you have book in reserve queue! You can't reserve book until it's over";
                    btnChkCondition.Enabled = false;
                    txtBookNumber.Enabled   = false;
                    btnReserve.Enabled      = false;
                }
                else
                {
                    lblError.Text           = " ";
                    btnChkCondition.Enabled = true;
                    txtBookNumber.Enabled   = true;
                }
            }
            else
            {
                lblError.Text = "Oops, ID is not exist! Check again!";
            }
        }
예제 #12
0
        private void borrow(CirculatedCopy cc, Copy c, Reservation r)
        {
            // Insert borrow record
            if (cc == null)
            {
                return;
            }
            CirculatedCopyDAO.Insert(cc);

            // update type = 'B' at Copy
            c      = CopyDAO.GetCopy(Int32.Parse(txtCopyNumber.Text));
            c.Type = 'B';
            CopyDAO.Update(c);


            // update status = 'A' at Reservation
            if (r == null)
            {
                return;
            }
            r.Status = 'A';
            ReserveDAO.Update(r);
        }
예제 #13
0
        private void View(Borrower borrower)
        {
            DataTable dt = new DataTable();

            dt = ReserveDAO.GetDataTableReserve(borrower.BorrowerNumber);

/*            foreach (DataRow dr in dt.Rows)
 *          {
 *              dr[3] = DateTime.Parse((dr[3].ToString())).ToString("dd/MM/yyyy");
 *          }*/
            DataView dv = new DataView(dt);

            GridView1.DataSource = dv;
            GridView1.DataBind();

            try
            {
                GridViewRow row = GridView1.Rows[0];
                row.Cells[3].Text = DateTime.Parse((row.Cells[3].Text.ToString())).ToString("dd/MM/yyyy");
            }
            catch
            {
            }
        }
예제 #14
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public ReserveBLL(LoggingSessionInfo pUserInfo)
 {
     this.CurrentUserInfo = pUserInfo;
     this._currentDAO     = new ReserveDAO(pUserInfo);
 }