示例#1
0
        private void price_Validating(object sender, CancelEventArgs e)
        {
            if (BookPropertyValidator.ValidatePrice(priceTextBox.Text))
            {
                e.Cancel = false;

                if (!String.IsNullOrWhiteSpace(priceTextBox.Text))
                {
                    priceTextBox.BackColor = Color.FromArgb(154, 208, 208);
                }
            }

            else
            {
                e.Cancel = true;
                priceTextBox.BackColor = Color.FromArgb(214, 140, 140);
                MessageBox.Show("Invalid price.\nSample: 59,95");
                invalidPriceLabel.Visible = true;
            }
        }
示例#2
0
        private void genre_Validating(object sender, CancelEventArgs e)
        {
            if (BookPropertyValidator.ValidateAuthor(genreTextBox.Text))
            {
                e.Cancel = false;

                if (!String.IsNullOrWhiteSpace(genreTextBox.Text))
                {
                    genreTextBox.BackColor = Color.FromArgb(154, 208, 208);
                }
            }

            else
            {
                e.Cancel = true;
                genreTextBox.BackColor = Color.FromArgb(214, 140, 140);
                MessageBox.Show("Invalid genre.\nSample: Fantasy");
                invaledGenreLabel.Visible = true;
            }
        }
示例#3
0
        private void title_Validating(object sender, CancelEventArgs e)
        {
            if (BookPropertyValidator.ValidateAuthor(titleTextBox.Text))
            {
                e.Cancel = false;

                if (!String.IsNullOrWhiteSpace(titleTextBox.Text))
                {
                    titleTextBox.BackColor = Color.FromArgb(154, 208, 208);
                }
            }

            else
            {
                e.Cancel = true;
                titleTextBox.BackColor = Color.FromArgb(214, 140, 140);
                MessageBox.Show("Invalid title.\nSample: Midnight Rain");
                invalidTitleLabel.Visible = true;
            }
        }
示例#4
0
        private void publishdate_Validating(object sender, CancelEventArgs e)
        {
            if (BookPropertyValidator.ValidateDate(publishdateTextBox.Text))
            {
                e.Cancel = false;

                if (!String.IsNullOrWhiteSpace(publishdateTextBox.Text))
                {
                    publishdateTextBox.BackColor = Color.FromArgb(154, 208, 208);
                }
            }

            else
            {
                e.Cancel = true;
                publishdateTextBox.BackColor = Color.FromArgb(214, 140, 140);
                MessageBox.Show("Invalid publish date.\nSample: mm/dd/yy e.g. 12/30/2000");
                invalidPublishDateLabel.Visible = true;
            }
        }
示例#5
0
        private void author_Validating(object sender, CancelEventArgs e)
        {
            if (BookPropertyValidator.ValidateAuthor(authorTextBox.Text))
            {
                e.Cancel = false;

                if (!String.IsNullOrWhiteSpace(authorTextBox.Text))
                {
                    authorTextBox.BackColor = Color.FromArgb(154, 208, 208);
                }
            }

            else
            {
                e.Cancel = true;
                authorTextBox.BackColor = Color.FromArgb(214, 140, 140);
                MessageBox.Show("Invalid author.\nSample: Surname, Forename\nRalls, Kim");
                invalidAuthorLabel.Visible = true;
                authorSampleLabel.Visible  = true;
            }
        }