Example #1
0
        public EntClsSearch searchBook(string name)
        {
            EntClsSearch objSearch      = new EntClsSearch();
            string       storeProcedure = "ForNameBook";

            using (DbConnection con = dpf.CreateConnection())
            {
                con.ConnectionString = constr;
                using (DbCommand cmd = dpf.CreateCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandText = storeProcedure;
                    cmd.CommandType = CommandType.StoredProcedure;
                    DbParameter param = cmd.CreateParameter();
                    param.DbType        = DbType.String;
                    param.ParameterName = "name";
                    param.Value         = name;
                    cmd.Parameters.Add(param);
                    con.Open();

                    using (DbDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            objSearch = new EntClsSearch((string)dr["code"], (string)dr["NameBook"], (string)dr["stateB"], (int)dr["stock"], (string)dr["nameEdit"], (string)dr["nameAuth"], (string)dr["lastName"]);
                        }
                    }
                }
            }
            return(objSearch);
        }
Example #2
0
        protected void btnReturnBook_Click(object sender, EventArgs e)
        {
            bsn_returnBook.UpdateStateLoan(Convert.ToInt32(textticket.Text));
            EntClsSearch ent_returnbook = bsn_returnBook.searchBook(textNameBook.Text);
            int          Newstock       = bsn_returnBook.UpdateStock(ent_returnbook.Stock);

            bsn_returnBook.UpdateStockBook(ent_returnbook.Codigo, Newstock);

            returnBookMessage();
            btnReturnBook.Enabled = false;
        }
Example #3
0
        public EntClsSearch queryForIsbnName()
        {
            EntClsSearch resultQuery = new EntClsSearch();
            BsnClsSearch bsn_search  = new BsnClsSearch();

            resultQuery = bsn_search.ForIsbnBook(searchvalue);
            if (resultQuery.Book == null)
            {
                return(null);
            }
            return(resultQuery);
        }
Example #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["search"].ToString() == "")
     {
         Response.Redirect("principal.aspx");
     }
     else
     {
         searchvalue = Session["search"].ToString();
         List <EntClsSearch> result = new List <EntClsSearch>();
         result = queryForNameEditorial();
         if (result == null)
         {
             result = queryForBookName();
             if (result == null)
             {
                 result = queryForOnlyLastNameAuthor();
                 if (result == null)
                 {
                     result = queryForOnlyNameAuthor();
                     if (result == null)
                     {
                         EntClsSearch onlyOneAnsw = new EntClsSearch();
                         onlyOneAnsw = queryForIsbnName();
                         if (onlyOneAnsw == null)
                         {
                             onlyOneAnsw = queryForCodeName();
                             if (onlyOneAnsw == null)
                             {
                                 result = queryForAuthorCompleteName();
                                 if (result == null)
                                 {
                                     errorMessage();
                                 }
                                 else
                                 {
                                     loadGrid(result);
                                 }
                             }
                             else
                             {
                                 Response.Write(onlyOneAnsw.Book);
                                 Response.Write(onlyOneAnsw.State);
                                 Response.Write(onlyOneAnsw.Stock);
                                 Response.Write(onlyOneAnsw.Editorial);
                                 Response.Write(onlyOneAnsw.Author);
                                 Response.Write(onlyOneAnsw.LastNameAuthor);
                             }
                         }
                         else
                         {
                             Response.Write(onlyOneAnsw.Book);
                             Response.Write(onlyOneAnsw.State);
                             Response.Write(onlyOneAnsw.Stock);
                             Response.Write(onlyOneAnsw.Editorial);
                             Response.Write(onlyOneAnsw.Author);
                             Response.Write(onlyOneAnsw.LastNameAuthor);
                         }
                     }
                     else
                     {
                         loadGrid(result);
                     }
                 }
                 else
                 {
                     loadGrid(result);
                 }
             }
             else
             {
                 loadGrid(result);
             }
         }
         else
         {
             loadGrid(result);
         }
     }
 }
        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();
            }
        }