Esempio n. 1
0
        // Button search Student by student number.
        private void Button_SearchStudent_Click(object sender, EventArgs e)
        {
            if (this.textBox_EnrollmentNo.Text != string.Empty)
            {
                string    enrollmentNo = this.textBox_EnrollmentNo.Text.Trim();
                DataTable table        = issueBook.GetNotReturnedBooksByStudentNo(enrollmentNo, out string errorMessage);

                if (table.Rows.Count > 0)
                {
                    this.dataGridView_AllBooks.DataSource = table;
                    this.dataGridView_AllBooks.ClearSelection();
                }
                else
                {
                    if (errorMessage != string.Empty)
                    {
                        MessageBox.Show("No table found!"
                                        + Environment.NewLine
                                        + errorMessage,
                                        "Load Students and Books",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show("The student has no issued books!",
                                        "Load Students and Books",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            }
        }