示例#1
0
        /// <summary>
        /// Check Out button event handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCheckOut_Click(object sender, EventArgs e)
        {
            int selectedBookID = 0;

            if (!String.IsNullOrWhiteSpace(Request.QueryString["bookID"]))
            {
                selectedBookID = int.Parse(Request.QueryString["bookID"]);
            }
            else
            {
                Utilities.Utilities.setPageMessage("Please select a book.", Utilities.Utilities.severity.error, Page.Master);
                return;
            }

            BusinessLogicDBOperations dbOperations = new BusinessLogicDBOperations();


            string   bookName     = txtName.Text;
            string   mobileNo     = txtMobile.Text;
            string   nationalID   = txtNationalID.Text;
            DateTime checkOutDate = DateTime.Parse(lblCheckOutDate.Text);
            DateTime returnDate   = DateTime.Parse(lblReturnDate.Text);

            var book = dbOperations.RetrieveBooksList().Where(x => x.BookID == selectedBookID).FirstOrDefault();

            if (book != null && book.CheckOutStatusID == 1) // CheckOutStatusID 1 is check in
            {
                int result = dbOperations.CheckOut(selectedBookID,
                                                   bookName,
                                                   mobileNo,
                                                   nationalID,
                                                   checkOutDate,
                                                   returnDate
                                                   );

                if (result == 0)
                {
                    Utilities.Utilities.setPageMessage("Encountered an error while checking out.", Utilities.Utilities.severity.error, Page.Master);
                    return;
                }

                Utilities.Utilities.setPageMessage("Book has been checked out in the name of " + txtName.Text, Utilities.Utilities.severity.info, Page.Master);

                displayBookCheckOutHistory(selectedBookID);
            }
            else
            {
                Utilities.Utilities.setPageMessage("Book is already checkout", Utilities.Utilities.severity.error, Page.Master);
            }
        }
示例#2
0
        private void DisplayBookInfo(int BookID)
        {
            try
            {
                BusinessLogicDBOperations dbOperations = new BusinessLogicDBOperations();
                Book book = dbOperations.RetrieveBooksList(BookID).Where(x => x.BookID == BookID).FirstOrDefault();

                if (book != null)
                {
                    lblBookTitle.Text     = book.Title;
                    lblCheckInStatus.Text = book.CheckOutStatusDescription;
                    lblCoverPrice.Text    = book.CoverPrice.ToString("N0");
                    lblISBN.Text          = book.ISBN;
                    lblName.Text          = "";
                    lblPublishYear.Text   = book.PublishYear;

                    //Get book borrower history
                    BusinessLogicDBOperations dbBorrowers = new BusinessLogicDBOperations();
                    List <Borrower>           borrowers   = dbOperations.RetrieveBookCheckOutHistory(BookID);

                    if (book.CheckOutStatusID == 1)
                    {
                        Borrower borrower = borrowers.LastOrDefault();
                        if (borrower != null)
                        {
                            lblName.Text = borrower.Name;
                        }
                    }
                    else
                    {
                        lblName.Text = "Book is checked in.";
                    }

                    HistoryList.DataSource = borrowers;
                    HistoryList.DataBind();
                }
                else
                {
                    Utilities.Utilities.setPageMessage("Book is either already checked in or was not found.",
                                                       Utilities.Utilities.severity.error, Page.Master);
                    return;
                }
            }
            catch (Exception ex)
            {
                BusinessLogicDBOperations dbOperations = new BusinessLogicDBOperations();
                dbOperations.ErrorLog(ex.Message, Request.Url.AbsoluteUri);
            }
        }
示例#3
0
        private void displayBooks()
        {
            BusinessLogicDBOperations dbOp = new BusinessLogicDBOperations();

            try
            {
                List <Book> books = dbOp.RetrieveBooksList();

                BooksList.DataSource = books;
                BooksList.DataBind();
            }
            catch (Exception ex)
            {
                Utilities.Utilities.setPageMessage(ex.Message, Utilities.Utilities.severity.error, Page.Master);
                return;
            }
        }
示例#4
0
        private void DisplayBooks()
        {
            try
            {
                BusinessLogicDBOperations dbOp = new BusinessLogicDBOperations();
                List <Book> books = dbOp.RetrieveBooksList();

                BooksList.DataSource = books;
                BooksList.DataBind();
            }
            catch (Exception ex)
            {
                Utilities.Instance.SetPageMessage(ex.Message, Utilities.Severity.Error, Page.Master);
                btnCheckIn.Enabled  = false;
                btnCheckOut.Enabled = false;
                btnDetails.Enabled  = false;
                return;
            }
        }