예제 #1
0
        protected void BookSubmitBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Book newBook = new BusinessLayer.Book();
            newBook.bkTitle = this.BookTitle.Text;
            if (!String.IsNullOrEmpty(this.BookPageCount.Text))
            {
                newBook.bkPageCount = Convert.ToInt32(this.BookPageCount.Text);
            }
            if (!String.IsNullOrEmpty(this.BookPrice.Text))
            {
                newBook.bkPrice = Convert.ToDouble(this.BookPrice.Text);
            }
            newBook.bkAuthorFirstName = this.BookAuthorFirstName.Text;
            newBook.bkAuthorLasstName = this.BookAuthorLastName.Text;
            newBook.bkTypeName        = this.BookTypeName.Text;

            string result = DataAccessLayer.Tools.InsertBook(newBook);

            if (result.Equals("1"))
            {
                UserMessage.Text = "Database Error.";
            }
            else if (result.Equals("0"))
            {
                UserMessage.Text = "Book Addition Successful, Thank You.";
                cleanupForm();
            }
        }
예제 #2
0
        protected void BorrowBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Student borrowingStudent = new BusinessLayer.Student();
            borrowingStudent.stId = Convert.ToInt32(this.StudentDropDown.Text);

            BusinessLayer.Book requestedBook = new BusinessLayer.Book();
            requestedBook.bkId = Convert.ToInt32(this.BookDropDown.Text);

            string result = DataAccessLayer.Tools.BorrowBook(borrowingStudent, requestedBook);

            if (result.Equals("1"))
            {
                UserMessage.Text = "Database Error.";
            }
            else if (result.Equals("0"))
            {
                UserMessage.Text = "Book Successfully Borrowed, Thank You.";
            }
            else if (result.Equals("MaxBooksLimitReached"))
            {
                UserMessage.Text = "This student has already borrowed 3 books.";
            }
            else if (result.Equals("BookNotAvailable"))
            {
                UserMessage.Text = "This book is not available at the moment.";
            }
        }
예제 #3
0
        protected void ReturnBtn_Click(object sender, EventArgs e)
        {
            BusinessLayer.Student returningStudent = new BusinessLayer.Student();
            returningStudent.stId = Convert.ToInt32(this.StudentDropDown.Text);

            BusinessLayer.Book returnedBook = new BusinessLayer.Book();
            if (this.StudentBookDropDown.Text == "")
            {
                UserMessage.Text = "Please select a Book to return";
                return;
            }
            returnedBook.bkId = Convert.ToInt32(this.StudentBookDropDown.Text);

            string result = DataAccessLayer.Tools.ReturnBook(returningStudent, returnedBook);

            if (result.Equals("1"))
            {
                UserMessage.Text = "Database Error.";
            }
            else if (result.Equals("0"))
            {
                UserMessage.Text = "Book Successfully Returned, Thank You.";
                this.StudentBookDropDown.Items.Remove(this.StudentBookDropDown.SelectedItem);
                // this.StudentDropDown.ClearSelection();
            }
        }