Example #1
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(textCode.Text) || String.IsNullOrEmpty(textDate.Text) || String.IsNullOrEmpty(textIsbn.Text) || String.IsNullOrEmpty(textIsbn.Text) || String.IsNullOrEmpty(textStock.Text) || String.IsNullOrEmpty(textTitle.Text))
     {
         errorFull();
     }
     else
     {
         if (validTitle(textTitle.Text, 1))
         {
             errorTitle();
         }
         else
         {
             if (validIsbn(textIsbn.Text, 1))
             {
                 errorIsbn();
             }
             else
             {
                 int    idcateg = Convert.ToInt32(ddlCategory.SelectedValue);
                 string state   = ddlState.SelectedItem.Text;
                 bsn_book.updateBook(textCode.Text, textIsbn.Text, textTitle.Text, textDate.Text, idEditorial, idcateg, state, Convert.ToInt32(textStock.Text));
                 bsn_write.insertWrite(idAuthor, textCode.Text);
                 Session.Add("succe", 1);
                 Response.Redirect("BookView.aspx");
             }
         }
     }
 }
        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();
            }
        }