Exemplo n.º 1
0
        //This method deals with issuing book
        private void IssueBookButton_Click(object sender, EventArgs e)
        {
            // Checks for empty values

            if (BookIDTextBox.Text != "" && StudentIDTextBox.Text != "")
            {
                int bookId;
                int studentID;
                // Checks whether input is integer


                if (int.TryParse(BookIDTextBox.Text, out bookId) && int.TryParse(StudentIDTextBox.Text, out studentID))
                {
                    DateTimePicker1.MinDate = DateTimePicker1.MaxDate = DateTime.Now;

                    String date = DateTimePicker1.Text;

                    LibraryDBClassProject.LibraryManagement libDataclass = new LibraryDBClassProject.LibraryManagement();
                    // Checks whether the record being inserted in the database

                    if (libDataclass.getSearchBookID(bookId).Rows.Count != 0)
                    {
                        if (libDataclass.checkBookStatus(bookId).Rows.Count != 0)
                        {
                            int x = libDataclass.issueBook(bookId, studentID, date);

                            if (x != 0)
                            {
                                ErrorLabel.Text = " Book Issued Successfully";
                            }

                            else
                            {
                                ErrorLabel.Text = " Invalid inputs. Please provide a valid Student ID.";
                            }
                        }
                        else
                        {
                            ErrorLabel.Text = " Book is already issued.";
                        }
                    }
                    else
                    {
                        ErrorLabel.Text = " Book does not exist";
                    }
                }

                else
                {
                    ErrorLabel.Text = " Input values should be numeric. Please provide numeric inputs.";
                }
            }
            else
            {
                ErrorLabel.Text = " Input values can not be blank. Please provide inputs.";
            }
        }
Exemplo n.º 2
0
        // method deals with returning books

        private void ReturnBookButton_Click(object sender, EventArgs e)
        {
            DateTimePickerReturn.MinDate = DateTimePickerReturn.MaxDate = DateTime.Now;
            string returnDate = DateTimePickerReturn.Text;
            int    bookID;

            // Checks for empty values

            if (ReturnIDTextBox.Text != "" && ReturnIDTextBox.Text != null)
            {
                // Checks whether input is integer

                if (int.TryParse(ReturnIDTextBox.Text, out bookID))

                {
                    LibraryDBClassProject.LibraryManagement libDataclass = new LibraryDBClassProject.LibraryManagement();
                    // Checks whether the record being inserted in the database


                    if (libDataclass.getSearchBookID(bookID).Rows.Count != 0)
                    {
                        if (libDataclass.checkBookStatus(bookID).Rows.Count == 0)
                        {
                            int x = libDataclass.returnBook(bookID, returnDate);
                            if (x > 0)
                            {
                                ErrorLabel.Text = "Book returned successfully";
                            }
                            else
                            {
                                ErrorLabel.Text = "Book has not issued to anyone";
                            }
                        }
                        else
                        {
                            ErrorLabel.Text = "Book already returned and availble to issue.";
                        }
                    }
                    else
                    {
                        ErrorLabel.Text = "Book does not exist";
                    }
                }
                else
                {
                    ErrorLabel.Text = "Book ID must be numeric. Please enter a valid ID";
                }
            }


            else
            {
                ErrorLabel.Text = "Book ID can not be blank. Please enter a valid ID";
            }
        }