Esempio n. 1
0
        // method deals with finding a book

        private void FindBookButton_Click(object sender, EventArgs e)
        {
            string bookTitle = SearchBookIDTextBox.Text;

            // Checks for empty values

            if (bookTitle != null && bookTitle != "")
            {
                try
                {
                    LibraryDBClassProject.LibraryManagement libDataclass = new LibraryDBClassProject.LibraryManagement();
                    // Checks whether the record being available in the database

                    if (libDataclass.getSearchBooks(bookTitle).Rows.Count != 0)
                    {
                        BooksDataGridView.DataSource = libDataclass.getSearchBooks(bookTitle);
                    }
                    else
                    {
                        ErrorLabel.Text = " Please enter a valid Book Id to search";
                    }
                }
                catch (Exception ex)
                {
                    ErrorLabel.Text = ex.Message + " An Error Occurred";
                }
            }
            else
            {
                ErrorLabel.Text = "Book Title can not be blank";
            }
        }
Esempio n. 2
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.";
            }
        }
Esempio n. 3
0
        // method deals with displaying issued books to students
        private void SearchIssuedBooksButton_Click(object sender, EventArgs e)
        {
            int studentId;

            // Checks for empty values

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

                if (int.TryParse(StudentIdTextBox.Text, out studentId))
                {
                    try
                    {
                        LibraryDBClassProject.LibraryManagement libDataclass = new LibraryDBClassProject.LibraryManagement();
                        // Checks whether the record being inserted in the database


                        if (libDataclass.getSearchStudentID(studentId).Rows.Count != 0)
                        {
                            if (libDataclass.getSearchIssuedBooks(studentId).Rows.Count != 0)
                            {
                                ReturnBooksDataGridView.DataSource = libDataclass.getSearchIssuedBooks(studentId);

                                ErrorLabel.Text = libDataclass.DBError;
                            }
                            else
                            {
                                ErrorLabel.Text = "No books has been issued.";
                                ReturnBooksDataGridView.ClearSelection();
                            }
                        }
                        else
                        {
                            ErrorLabel.Text = "Student ID doesnt not exist.";
                            ReturnBooksDataGridView.ClearSelection();
                        }
                    }


                    catch (Exception ex)
                    {
                        ErrorLabel.Text = ex.Message + " An Error Occurred";
                    }
                }
                else
                {
                    ErrorLabel.Text = "Student ID must be numeric. Please enter a valid ID";
                    ReturnBooksDataGridView.ClearSelection();
                }
            }
            else
            {
                ErrorLabel.Text = "Student ID can not be blank. Please enter a valid ID";
                ReturnBooksDataGridView.ClearSelection();
            }
        }
Esempio n. 4
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";
            }
        }
        // Displays all issued books

        private void ViewIssuedBooks_Load(object sender, EventArgs e)
        {
            try
            {
                LibraryDBClassProject.LibraryManagement libDataclass = new LibraryDBClassProject.LibraryManagement();

                ViewIssuedBooksDataGridView.DataSource = libDataclass.getIssuedBooks();
                ErrorLabel.Text = libDataclass.DBError;
            }
            catch (Exception ex)
            {
                ErrorLabel.Text = ex.Message + " An Error Occurred";
            }
        }
Esempio n. 6
0
        private void SeaerchStudentBooksbutton_Click(object sender, EventArgs e)
        {
            int StudentId;

            if (StudentIDTextBox.Text != "" && StudentIDTextBox.Text != null)
            {
                if (int.TryParse(StudentIDTextBox.Text, out StudentId))
                {
                    try
                    {
                        LibraryDBClassProject.LibraryManagement libDataclass = new LibraryDBClassProject.LibraryManagement();
                        if (libDataclass.getSearchStudentID(StudentId).Rows.Count != 0)
                        {
                            if (libDataclass.getStudentIssuedBooks(StudentId).Rows.Count != 0)
                            {
                                SearchIssuedDataGridView.DataSource = libDataclass.getStudentIssuedBooks(StudentId);

                                errorLabel1.Text = libDataclass.DBError;
                            }
                            else
                            {
                                errorLabel1.Text = " No Books is issued to this student";
                            }
                        }
                        else
                        {
                            errorLabel1.Text = " Student ID does not exist. Please enter a valid student ID";
                        }
                    }
                    catch (Exception ex)
                    {
                        errorLabel1.Text = ex.Message + " An Error Occurred";
                    }
                }
                else
                {
                    errorLabel1.Text = " Student Id must be numeric. Please enter a valid student ID";
                }
            }
            else
            {
                errorLabel1.Text = " Student Id can not be blank. Please enter a valid student ID";
            }
        }