private void button1_Click_2(object sender, EventArgs e) //Searching Button in the Author Name Search Panel { Book[] books; string num = AuthorFunctions.Searching_Author(name); books = BooksFunctions.Search(num, 2); //To call the Searching Function() if (books == null) { MessageBox.Show("Author name has no books available"); aftersearch.Text = ""; } else { string[] Lines = new string[(books.Length * 5) - 1]; //Array of strings to Put each field in a line with a seperator between each record int index = 0; for (int i = 0; i < books.Length; i++) //Loop to put each field in the string array inorder to display them { Lines[index++] = "Serial Number: " + books[i].serialNo; Lines[index++] = "Book Name: " + books[i].bookName; Lines[index++] = "Publish Year: " + books[i].publishYear; Lines[index++] = "Author Number: " + books[i].authorNo; if (i != books.Length - 1) { Lines[index++] = "----------------------------------------"; //to handle the last record inorder not to display seperator line after the last record } } aftersearch.Lines = Lines; //function aftersearch.Lines is to put each single element in the array in a single line } }
private void BTN_Searching_Click(object sender, EventArgs e) //Searching for Publish Year Button { Book[] books; books = BooksFunctions.Search(yearsearch, 1); //to call searching function of the book by the Publish Year if (books == null) { MessageBox.Show("This Book is not found"); TXT_Searching.Text = ""; } else { string[] Lines = new string[(books.Length * 5) - 1]; //Array of strings to Put each field in a line with a seperator between each record int index = 0; for (int i = 0; i < books.Length; i++) //Loop to put each field in the string array inorder to display them { Lines[index++] = "Serial Number: " + books[i].serialNo; Lines[index++] = "Book Name: " + books[i].bookName; Lines[index++] = "Publish Year: " + books[i].publishYear; Lines[index++] = "Author Number: " + books[i].authorNo; if (i != books.Length - 1) //to handle the last record inorder not to display seperator line after the last record { Lines[index++] = "----------------------------------------"; } } TXT_Searching.Lines = Lines; //function Searching.Lines is to put each single element in the array in a single line SearchingTextBox.Focus(); //To Handle a problem occurred when Displaying The Books inorder to change the mouse focus after displaying } }