protected EntClsAuthor registerBook()
        {
            int             itemSelec  = (ddlCategory.SelectedIndex) + 1;
            BsnClsBook      bsn_book   = new BsnClsBook();
            BsnClsEditorial bsn_edit   = new BsnClsEditorial();
            EntClsEditorial obj_edit   = bsn_edit.checkEditorial(textNameEdit.Text);
            int             idedit     = obj_edit.Id;
            int             stock      = Convert.ToInt16(textStock.Text);
            EntClsAuthor    obj_author = new EntClsAuthor();
            BsnClsAuthor    bsn_author = new BsnClsAuthor();

            obj_author = bsn_author.checkAuthor(textNameAuth.Text, textLastName.Text);
            bsn_book.insertBook(textTitle.Text, textCode.Text, textIsbn.Text, textDate.Text, Convert.ToInt16(textStock.Text), itemSelec, idedit, "Disponible", 1);
            return(obj_author);
        }
        protected void buttonCheckEditorial_Click(object sender, EventArgs e)
        {
            BsnClsEditorial bsn_editorial = new BsnClsEditorial();
            EntClsEditorial editFind      = bsn_editorial.checkEditorial(textNameEdit.Text);

            if (editFind.Name == null)
            {
                textCity.Enabled    = true;
                textCountry.Enabled = true;
                change2             = 1;
            }
            else
            {
                textNameEdit.Text = editFind.Name;
                textCountry.Text  = editFind.Country;
                textCity.Text     = editFind.City;
            }
            buttonCheckEditorial.Enabled = false;
        }
        protected void buttonRegister_Click(object sender, EventArgs e)
        {
            BsnClsBook bsn_Libro = new BsnClsBook();
            EntClsBook bookFind  = bsn_Libro.checkBook(textTitle.Text);

            if (bookFind.Code == null)
            {
                if (change1 == 1)
                {
                    BsnClsAuthor bsn_author = new BsnClsAuthor();
                    bsn_author.insertAuthor(textNameAuth.Text, textLastName.Text, textNationality.Text);
                }
                if (change2 == 1)
                {
                    BsnClsEditorial bsn_editorial = new BsnClsEditorial();
                    bsn_editorial.insertEditorial(textNameEdit.Text, textCountry.Text, textCity.Text);
                }
                EntClsSearch consulExist = new EntClsSearch();
                BsnClsSearch bsn_search  = new BsnClsSearch();
                consulExist = bsn_search.ForCodeBook(textCode.Text);
                if (consulExist.Book == null)
                {
                    //verificar que no se repita el isbn
                    consulExist = bsn_search.ForIsbnBook(textIsbn.Text);
                    if (consulExist.Book == null)
                    {
                        //verificar que no se repita el titulo
                        consulExist = bsn_search.ForNameBook(textTitle.Text);
                        if (consulExist.Book == null)
                        {
                            EntClsAuthor obj_Author = registerBook();
                            BsnClsWrite  bsn_write  = new BsnClsWrite();
                            bsn_write.insertWrite(obj_Author.Id, textCode.Text);
                            registerSucces();
                            clear();
                        }
                        else
                        {
                            string script = @"<script type='text/javascript'>
                            alert('Ya existe este libro ingrese otro');
                            </script>";
                            ScriptManager.RegisterStartupScript(this, typeof(Page), "BookAdmin", script, false);
                        }
                    }
                    else
                    {
                        string script = @"<script type='text/javascript'>
                    alert('Ya existe ese ISBN ingrese otro');
                    </script>";
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "BookAdmin", script, false);
                    }
                }
                else
                {
                    string script = @"<script type='text/javascript'>
                    alert('Ya existe ese codigo ingrese otro');
                    </script>";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "BookAdmin", script, false);
                }
            }
            else
            {
                registerFail();
            }
        }