Exemple #1
0
        private void SearchForBooksButton(object sender, EventArgs e) //Search for Books
        {
            string        ISBNCode;
            BooksSearcher bs = new ManageBooks();

            if (bs.SearchForBookID(out ISBNCode) == DialogResult.OK)
            {
                textBox3.Text = ISBNCode;
            }
        }
        bool ValidateValues(out String err)
        {
            err = "";

            if (String.IsNullOrEmpty(TitleTextBox.Text) || TitleTextBox.Text.Length > 255)
            {
                err = "Enter Valid Title";
                return(false);
            }

            if (String.IsNullOrEmpty(AuthorTextBox.Text) || AuthorTextBox.Text.Length > 50)
            {
                err = "Enter Valid Author";
                return(false);
            }

            if (String.IsNullOrEmpty(PublisherTextBox.Text) || PublisherTextBox.Text.Length > 50)
            {
                err = "Enter Valid Publisher";
                return(false);
            }

            // ISBN has a specific string size
            if (String.IsNullOrEmpty(ISBNTextBox.Text) || !ManageBooks.IsValidISBN(ISBNTextBox.Text))
            {
                err = "Enter Valid ISBN (Exactly 10/13 Digits)";
                return(false);
            }

            if (String.IsNullOrEmpty(LanguageTextBox.Text) || LanguageTextBox.Text.Length > 13)
            {
                err = "Enter Valid Language";
                return(false);
            }

            if (String.IsNullOrEmpty(GenreTextBox.Text) || GenreTextBox.Text.Length > 20)
            {
                err = "Enter Valid Genre";
                return(false);
            }

            // No Negative Prices
            Double price;

            if (!Double.TryParse(BookCostTextBox.Text, out price) || price < 0)
            {
                err = "Enter Valid Price (Greater than or equal to 0)";
                return(false);
            }

            return(true);
        }
        private void ManageBooksButton_Click(object sender, EventArgs e)
        {
            // Instantiate a new Window
            ManageBooks manageBooksForm = new ManageBooks();

            manageBooksForm.IsLibrarian = true;

            // When the Manage Books form closes, Bring the Main window Back
            manageBooksForm.FormClosed += SubMenuForm_FormClosed;

            // Hide this form and Show the Manage Books Form
            this.Hide();
            manageBooksForm.Show();
        }