Ejemplo n.º 1
0
        protected void AddReader_Click(object sender, EventArgs e)
        {
            if (ProcessGUI.IsNumeric(this.txtReaderId.Text))
            {
                Int64     readerId  = Int64.Parse(this.txtReaderId.Text);
                ReaderBLL readerBLL = new ReaderBLL();
                readerBLL       = ReaderDAL.getReaderByReaderId(readerId);
                this._readerBLL = readerBLL;
                if (readerBLL != null)
                {
                    this.lblReaderName.Text = readerBLL.Name;
                    this.lblReaderId.Text   = readerBLL.Code.ToString();
                    this.lblEmail.Text      = readerBLL.Email;
                    this.lblAddress.Text    = readerBLL.Address;
                    this.lblDayOfBirth.Text = readerBLL.Birthday.ToShortDateString();
                    this.lblPhone.Text      = readerBLL.Phone;
                    this.lblQuantity.Text   = "0";

                    int result = (DateTime.Compare(DateTime.Now, readerBLL.Enddate));
                    if (result > 0)
                    {
                        string script = "alert(\"This reader has expired!\");";
                        ScriptManager.RegisterStartupScript(this, GetType(),
                                                            "ServerControlScript", script, true);
                        this.lblStatus.Text = "Expired";
                    }
                    else
                    {
                        BorrowBookBLL borrowBookBLL = new BorrowBookBLL();
                        if (borrowBookBLL.checkBookBorrowMax(readerBLL))
                        {
                            this.lblStatus.Text   = "Good";
                            Session["readerName"] = readerBLL.Name;
                            Session["readerId"]   = readerBLL.Code;
                            Session["quantity"]   = borrowBookBLL.getBookQuantityCanBorrow(readerBLL);
                            this.lblQuantity.Text = borrowBookBLL.getBookQuantityCanBorrow(readerBLL).ToString();
                        }
                        else
                        {
                            string script = "alert(\"Reader has  borrowed maximum books!\");";
                            ScriptManager.RegisterStartupScript(this, GetType(),
                                                                "ServerControlScript", script, true);
                            this.lblStatus.Text = "Maximum";
                        }
                    }
                }
                else
                {
                    string script = "alert(\"Readers do not exist!\");";
                    ScriptManager.RegisterStartupScript(this, GetType(),
                                                        "ServerControlScript", script, true);
                }
            }
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        protected void btnAddBook_Click(object sender, EventArgs e)
        {
            BookTitleBLL  bookTitleBLL = new BookTitleBLL();
            BorrowBookBLL borrowBLL    = new BorrowBookBLL();

            if (ProcessGUI.IsNumeric(this.txtBookId.Text))
            {
                bookTitleBLL = borrowBLL.getBookTile(Int32.Parse(this.txtBookId.Text));
                if (bookTitleBLL != null)
                {
                    if (count <= Int32.Parse(Session["quantity"].ToString()))
                    {
                        if (count == 1)
                        {
                            this.lblBookTitleFirst.Text = bookTitleBLL.Name;
                            this.lblBookIdFirst.Text    = bookTitleBLL.BookTitleId.ToString();
                            this.lblIdFirst.Text        = this.txtBookId.Text;
                            count++;
                            Session["id1"]              = this.txtBookId.Text;
                            Session["bookId1"]          = this.lblBookIdFirst.Text;
                            Session["bookName1"]        = this.lblBookTitleFirst.Text;
                            this.btnRemoveFirst.Visible = true;
                        }
                        else if (count == 2)
                        {
                            this.lblBookTitleSecond.Text = bookTitleBLL.Name;
                            this.lblBookIdSecond.Text    = bookTitleBLL.BookTitleId.ToString();
                            this.lblIdSecond.Text        = this.txtBookId.Text;
                            count++;

                            Session["id2"]               = this.txtBookId.Text;
                            Session["bookId2"]           = this.lblBookIdSecond.Text;
                            Session["bookName2"]         = this.lblBookTitleSecond.Text;
                            this.btnRemoveSecond.Visible = true;
                        }
                        else if (count == 3)
                        {
                            this.lblBookTitleThird.Text = bookTitleBLL.Name;
                            this.lblBookIdThird.Text    = bookTitleBLL.BookTitleId.ToString();
                            this.lblIdThird.Text        = this.txtBookId.Text;
                            count++;
                            Session["id3"]              = this.txtBookId.Text;
                            Session["bookId3"]          = this.lblBookIdThird.Text;
                            Session["bookName3"]        = this.lblBookTitleThird.Text;
                            this.btnRemoveThird.Visible = true;
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void btn1_Click(object sender, EventArgs e)
        {
            BorrowBookBLL bll = new BorrowBookBLL();//需将BorrowBookBll类声明为public

            if (bll.judgeBookState(judge) == true)
            {
                if (bll.borrowBook(stuID, ID) && bll.changeBookState(ID))
                {
                    MessageBox.Show("借书成功!");
                }
            }
            else
            {
                MessageBox.Show("借书失败!");
            }
            this.Close();
        }
Ejemplo n.º 5
0
 public BorrowBookController(ApplicationDbContext context)
 {
     _borrowBookBLL = new BorrowBookBLL(context);
 }