Example #1
0
 private void Displaying_BTN_Click(object sender, EventArgs e)    //Button to Display all Authors in the Displaying Author Panel
 {
     Author[] Authors;
     Authors = AuthorFunctions.Author_read();         //Calling the read function { For more details go to definition :) }
     if (Authors == null)
     {
         MessageBox.Show("There are no Authors to display");
     }
     else
     {
         string[] Lines = new string[(Authors.Length * 4) - 1];    //String Array to put each field in the the array + seperator between each record and -1 inorder not to put seperator in the last Line after the last record
         int      index = 0;
         for (int i = 0; i < Authors.Length; i++)
         {
             Lines[index++] = "Author ID: " + Authors[i].id.ToString();
             Lines[index++] = "Author Name: " + Authors[i].authorName.ToString();
             Lines[index++] = "Email: " + Authors[i].email.ToString();
             if (i != Authors.Length - 1)
             {
                 Lines[index++] = "----------------------------------------";   //To put seperator after each record except the last one
             }
         }
         AuthorsTextBos.Lines = Lines;
     }
 }
Example #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
            }
        }
Example #3
0
        private void AddingnewAuthor_Click(object sender, EventArgs e) //Button of Add in the new Author adding Panel
        {
            Author s;

            s.id         = authnum;
            s.authorName = name;
            s.email      = email;
            if (AuthorFunctions.Author_Checker(s))         //To call the Checker Function {Go to definition for more details :) }
            {
                MessageBox.Show("There was a conflict in Author ID and was unsuccssfully added Please try again");
            }
            else
            {
                AuthorFunctions.Write_Author(s);
                MessageBox.Show("Author was successfully added");
            }
            IDTextBox.Text    = "";
            NameTextBox.Text  = "";
            EmailTextBox.Text = "";
        }