Beispiel #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);
                }
            }
        }
Beispiel #2
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
                        {
                        }
                    }
                }
            }
        }