Exemple #1
0
 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
     }
 }
Exemple #2
0
        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
            }
        }
Exemple #3
0
 private void button2_Click_1(object sender, EventArgs e) //Displaying Button for Books
 {
     Book[] BookArray;                                    //Array of struct of book
     BookArray = BooksFunctions.read();                   //calling read() function
     if (BookArray == null)
     {
         MessageBox.Show("There are no Books to Display");      //If the Books File was empty
     }
     else
     {
         string[] Lines = new string[(BookArray.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 < BookArray.Length; i++)                  //Loop to put each field in the string array inorder to display them
         {
             Lines[index++] = "Serial Number: " + BookArray[i].serialNo;
             Lines[index++] = "Book Name: " + BookArray[i].bookName;
             Lines[index++] = "Publish Year: " + BookArray[i].publishYear;
             Lines[index++] = "Author Number: " + BookArray[i].authorNo;
             if (i != BookArray.Length - 1)
             {
                 Lines[index++] = "----------------------------------------";   //to handle the last record inorder not to display seperator line after the last record
             }
         }
         textBox1.Lines = Lines;                                                //function textBox1.Lines is to put each single element in the array in a single line
     }
 }
Exemple #4
0
        private void btn_Click(object sender, EventArgs e)  //Button of Adding new Book in the File
        {
            Book h;

            h.serialNo    = serial;
            h.bookName    = name;
            h.publishYear = year;
            h.authorNo    = authnum;
            if (BooksFunctions.Book_Checker(h))            //To Check if there was a conflict in the Serial Number
            {
                MessageBox.Show("There was a conflict in the Book serial number and was unsuccessfully added Please try again");
            }
            else
            {
                BooksFunctions.write(h);
                MessageBox.Show("Book successfully added");
            }
            AuthorNumTextBox.Text   = "";
            SerialTextBox.Text      = "";
            PublishYearTextBox.Text = "";
            BookNameTextBox.Text    = "";
            btn.Enabled             = false;  //To disable the Button of Add after adding the new book
        }