Exemplo n.º 1
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();
            }
        }
Exemplo n.º 2
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";
            }
        }