Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int  add = (int)Session["add"];
            Copy c   = new Copy();

            c.BookNumber     = int.Parse(txtBookNumber.Text);
            c.SequenceNumber = CopyDAO.GetSequenceNumberMax(c.BookNumber) + 1;
            c.Type           = txtType.Text[0];
            if (txtPrice.Text == "")
            {
                c.Price = 0;
            }
            else
            {
                c.Price = int.Parse(txtPrice.Text);
            }
            if (add == 1)
            {
                c.CopyNumber = CopyDAO.GetCopyNumberMax() + 1;
                CopyDAO.Insert(c);
            }
            else
            {
                c.CopyNumber = (int)Session["copyNumber"];
                CopyDAO.Update(c);
            }

            ObjectDataSource1.Select();
            GridView1.DataBind();
            displayButtons(1);
        }
Exemple #2
0
        private void btnCopyEdit_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            if (btn.Text == "Edit")
            {
                if (!isCopySelected())
                {
                    return;
                }
                if (txtType.Text[0] == 'B')
                {
                    MessageBox.Show("Can't edit borrwed copy!");
                    return;
                }
                displayCopyButtons(3);
            }
            else
            {
                c = new Copy(int.Parse(txtCopyBookNumber.Text), int.Parse(txtCopyNumber.Text)
                             , int.Parse(txtSequenceNumber.Text), txtType.Text[0], double.Parse(txtPrice.Text));
                CopyDAO.Update(c);
                ViewCopies();
                displayCopyButtons(1);
            }
        }
Exemple #3
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 :< ";
            }
        }
        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);
        }
Exemple #5
0
        private void Return(CirculatedCopy cc)
        {
            CirculatedCopyDAO.Update(cc);
            Copy c = CopyDAO.GetCopy(cc.CopyNumber);

            // update type = 'A' in copy
            c.Type = 'A';
            CopyDAO.Update(c);
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Copy c = new Copy();

            c.BookNumber     = int.Parse(txtBookNum.Text);
            c.SequenceNumber = CopyDAO.GetSeqNumMaxOfBook(c.BookNumber) + 1;

            ///Set Type
            if (!(txtType.Text[0].Equals('A')))
            {
                if (!(txtType.Text[0].Equals('R')))
                {
                    lblError.Text    = "Type must be A or R";
                    lblError.Visible = true;
                    return;
                }
            }
            c.Type = txtType.Text[0];

            //Set Price
            if (txtPrice.Text == "")
            {
                c.Price = 0;
            }
            else
            {
                if (DAO.checkFloat(txtPrice.Text))
                {
                    c.Price = float.Parse(txtPrice.Text);
                }
                else
                {
                    lblError.Text    = "Price must in range 0-999.999.999";
                    lblError.Visible = true;
                    return;
                }
            }



            if (check == 1)
            {
                CopyDAO.Insert(c);
                clear();
                displayButtons(1);
            }

            if (check == 2)
            {
                c.CopyNumber = (int)Session["copyNumber"];
                CopyDAO.Update(c);
                clear();
                displayButtons(1);
            }
            ObjectDataSource1.Select();
            GridView1.DataBind();
        }
Exemple #7
0
        private void Return(CirculatedCopy cc)
        {
            CirculatedCopyDAO.Update(cc);

            Copy c = CopyDAO.GetCopy(cc.CopyNumber);

            // if copy is reference
            if (c.Type == 'R')
            {
                return;
            }
            // update type = 'A' in copy
            c.Type = 'A';
            CopyDAO.Update(c);
        }
        private void Return(CirculatedCopy cc)
        {
            if (CirculatedCopyDAO.Update(cc))
            {
                showMessageError("Return completed <3");

                Copy c = CopyDAO.GetCopy(cc.CopyNumber);

                // update type = 'A' in copy
                c.Type = 'A';
                CopyDAO.Update(c);
            }
            else
            {
                showMessageError("Return Fail :<");
            }
        }
Exemple #9
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);
        }
Exemple #10
0
        //button save
        protected void Button5_Click(object sender, EventArgs e)
        {
            //edit
            if (checkEditBook == true)
            {
                //book
                if (copyExist == false)
                {
                    if (txtTitle.Text.Trim().Length == 0)
                    {
                        lbErrorTitleAdd.Text    = "Please input title";
                        lbErrorTitleAdd.Visible = true;
                        return;
                    }
                    bo.Title     = txtTitle.Text;
                    bo.Authors   = txtAuthor.Text;
                    bo.Publisher = txtPublisher.Text;

                    if (!BookDAO.Update(bo))
                    {
                        return;
                    }
                    btSaveBook.Enabled   = false;
                    btCancelBook.Enabled = false;
                }
                else
                {
                    //copy
                    if (txtTypecopy.Text.Trim().Length == 0)
                    {
                        lbErrorCopies.Text    = "Please iput type A/F";
                        lbErrorCopies.Visible = true;
                        return;
                    }
                    co.Type = char.Parse(txtTypecopy.Text.ToUpper());
                    if (co.Type != 'A' && co.Type != 'F')
                    {
                        lbErrorCopies.Text    = "Please iput type A/F";
                        lbErrorCopies.Visible = true;
                        return;
                    }
                    co.Price      = double.Parse(txtPrice.Text);
                    co.BookNumber = int.Parse(GridView2.SelectedRow.Cells[3].Text);
                    co.CopyNumber = int.Parse(GridView2.SelectedRow.Cells[2].Text);
                    if (!CopyDAO.Update(co))
                    {
                        return;
                    }
                    btSaveCopies.Enabled   = false;
                    btCancelCopies.Enabled = false;

                    txtTypecopy.ReadOnly = true;
                    txtPrice.ReadOnly    = true;
                }
            }

            //add
            if (checkAddBook == true)
            {
                if (copyExist == false)
                {
                    if (txtTitle.Text.Trim().Length == 0)
                    {
                        lbErrorTitleAdd.Text    = "Please input title";
                        lbErrorTitleAdd.Visible = true;
                        return;
                    }
                    bo            = new Book();
                    bo.BookNumber = BookDAO.GetBookNumberMax() + 1;
                    bo.Title      = txtTitle.Text;
                    bo.Authors    = txtAuthor.Text;
                    bo.Publisher  = txtPublisher.Text;
                    if (!BookDAO.Insert(bo))
                    {
                        return;
                    }
                    foreach (TextBox tb in GetTextBoxes())
                    {
                        tb.ReadOnly = true;
                    }
                    btSaveBook.Enabled   = false;
                    btCancelBook.Enabled = false;
                }
                else
                {
                    if (txtTypecopy.Text.Trim().Length == 0)
                    {
                        lbErrorCopies.Text    = "Please iput type A/F";
                        lbErrorCopies.Visible = true;
                        return;
                    }
                    String type = txtTypecopy.Text.Trim().ToUpper();
                    if (!type.Equals("A") && !type.Equals("F"))
                    {
                        lbErrorCopies.Text    = "Please iput type A/F";
                        lbErrorCopies.Visible = true;
                        return;
                    }
                    co                = new Copy();
                    co.CopyNumber     = CopyDAO.GetCopyNumberMax() + 1;
                    co.BookNumber     = Int32.Parse(txtBookNumberCopies.Text);
                    co.SequenceNumber = CopyDAO.GetSequenceNumberMax(co.BookNumber) + 1;
                    co.Type           = char.Parse(type);
                    if (co.Type != 'A' && co.Type != 'F')
                    {
                        co.Price = double.Parse(txtPrice.Text.Trim().Length == 0 ? "0" : txtPrice.Text.Trim());
                    }
                    if (!CopyDAO.Insert(co))
                    {
                        return;
                    }
                }

                btSaveCopies.Enabled   = false; // save
                btCancelCopies.Enabled = false; // cancel
            }


            foreach (TextBox tb in GetTextBoxes())
            {
                if (!checkEditBook)
                {
                    tb.Text = "";
                }
                tb.ReadOnly = true;
            }

            checkAddBook  = false;
            checkEditBook = false;



            reload();
        }