예제 #1
0
        private void AddNewAuthor()
        {
            if (Page.IsValid)
            {
                string firstName = txtFirstName.Text;
                string lastName = txtLastName.Text;
                string origin = ddlCountries.SelectedItem.Text;
                string photo = ddlPhotos.SelectedValue;
                string biography = txtBiography.Text;

                //Creates an instance of Author class
                Author author = new Author(firstName, lastName, origin, photo, biography);

                if (!author.CheckIfAuthorExists(firstName,lastName))
                {
                    //Appends a new author into database
                    author.AddAuthor(author);
                    lblNewAuthor.Text = firstName +" "+ lastName;
                    divSuccess.Visible = true;
                    divFail.Visible = false;
                    ClearTextFields();
                }
                else
                {
                    author = null;
                    divSuccess.Visible = false;
                    divFail.Visible = true;
                }
            }
        }