protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (Session["book"] != null)
            {
                ent_write             = bsn_write.SearchAuthorOfBook(Session["book"].ToString());
                ent_Auth              = bsn_author.checkAuthorForId(ent_write.IdAuthor);
                textName.Text         = ent_Auth.Name;
                textLastName.Text     = ent_Auth.LastName;
                textNationality.Text  = ent_Auth.Nationality;
                btnUpdateCont.Visible = true;
                insert          = 3;
                code            = Session["book"].ToString();
                Session["book"] = null;
            }
            else
            {
                if (Session["regis"] != null)
                {
                    btnNextEditorial.Visible = true;
                }
            }
            if (!IsPostBack)
            {
                rblAuthor.AutoPostBack = true;
            }
        }
Пример #2
0
        public EntClsAuthor CheckAuthorForId(int id)
        {
            EntClsAuthor obj_author     = new EntClsAuthor();
            string       storeProcedure = "AuthorforId";

            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 = "id";
                    param.Value         = id;
                    cmd.Parameters.Add(param);

                    con.Open();

                    using (DbDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.Read())
                        {
                            obj_author = new EntClsAuthor((string)dr["name"], (string)dr["lastName"], (string)dr["nationality"]);
                        }
                    }
                }
            }
            return(obj_author);
        }
        protected void btnUpdateCont_Click(object sender, EventArgs e)
        {
            if (insert == 1)
            {
                if (valNameAuthor())
                {
                    errorAuthor();
                }
                else
                {
                    Session["book"] = code;
                    bsn_author.insertAuthor(textName.Text, textLastName.Text, textNationality.Text);
                    ent_Auth = bsn_author.checkAuthor(textName.Text, textLastName.Text);
                    Session.Add("author", ent_Auth.Id);
                    Response.Redirect("EditorialOfBook.aspx");
                }
            }

            if (insert == 0)
            {
                Session["book"] = code;
                Session.Add("author", ent_Auth.Id);
                Response.Redirect("EditorialOfBook.aspx");
            }
            else
            {
                Session["book"] = code;
                ent_Auth        = bsn_author.checkAuthor(textName.Text, textLastName.Text);
                Session.Add("author", ent_Auth.Id);
                Response.Redirect("EditorialOfBook.aspx");
            }
        }
Пример #4
0
        protected void btnNextEditorial_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(textName.Text) || String.IsNullOrEmpty(textLastName.Text) || String.IsNullOrEmpty(textNationality.Text))
            {
                errorFull();
            }
            else
            {
                if (insert == 1)
                {
                    if (valNameAuthor())
                    {
                        clean();
                        errorAuthor();
                    }
                    else
                    {
                        bsn_author.insertAuthor(textName.Text, textLastName.Text, textNationality.Text);
                        ent_Auth = bsn_author.checkAuthor(textName.Text, textLastName.Text);
                        Session.Add("author", ent_Auth.Id);
                        Response.Redirect("EditorialOfBook.aspx");
                    }
                }

                if (insert == 0)
                {
                    Session.Add("author", ent_Auth.Id);
                    Response.Redirect("EditorialOfBook.aspx");
                }
            }
        }
Пример #5
0
        protected bool valNameAuthor()
        {
            EntClsAuthor author = bsn_author.checkAuthor(textName.Text, textLastName.Text);

            if (author.Name == null)
            {
                return(false);
            }
            return(true);
        }
Пример #6
0
        protected void showBook(EntClsBook ent_book)
        {
            txtTitle.Text = ent_book.Name;
            txtStock.Text = Convert.ToString(ent_book.Stock);
            txtCode.Text  = ent_book.Code;
            EntClsWrite  ent_write  = bsn_write.listWriteForCode(ent_book.Code);
            EntClsAuthor ent_author = bsn_auth.checkAuthorForId(ent_write.IdAuthor);

            txtAuthor.Text = ent_author.Name + ' ' + ent_author.LastName;
            txtStateB.Text = ent_book.StateB;
        }
        protected void ddlAuthor_SelectedIndexChanged(object sender, EventArgs e)
        {
            ent_Auth = bsn_author.checkAuthor(textName.Text, textLastName.Text);
            bsn_write.deleteWrite(ent_Auth.Id, code);
            int valor = Convert.ToInt32(ddlAuthor.SelectedValue);

            foreach (EntClsAuthor auth in lstAuthor)
            {
                if (auth.Id == valor)
                {
                    ent_Auth = auth;
                }
            }
            ShowAuthor(ent_Auth);
        }
        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);
        }
Пример #9
0
        protected void ShowBook(EntClsBook book)
        {
            textTitle.Text       = book.Name;
            textIsbn.Text        = book.Isbn;
            textDatePublish.Text = book.DatePublish;
            textStock.Text       = Convert.ToString(book.Stock);
            textState.Text       = book.StateB;
            EntClsCategory ent_categ = bsn_cate.listCategoryForid(book.IdCateg);

            textCategory.Text = ent_categ.Name;
            EntClsEditorial ent_edit = bsn_edit.checkEditorialForId(book.IdEdit);

            textEdit.Text = ent_edit.Name;
            EntClsWrite  ent_write  = bsn_write.listWriteForCode(book.Code);
            EntClsAuthor ent_author = bsn_auth.checkAuthorForId(ent_write.IdAuthor);

            textAuthor.Text = ent_author.Name + ' ' + ent_author.LastName;
        }
        protected void buttonCheckAuthor_Click(object sender, EventArgs e)
        {
            BsnClsAuthor bsn_author = new BsnClsAuthor();
            EntClsAuthor authorFind = bsn_author.checkAuthor(textNameAuth.Text, textLastName.Text);

            if (authorFind.Name == null)
            {
                textNationality.Enabled = true;
                change1 = 1;
            }
            else
            {
                textNameAuth.Text    = authorFind.Name;
                textLastName.Text    = authorFind.LastName;
                textNationality.Text = authorFind.Nationality;
            }
            buttonCheckAuthor.Enabled = false;
        }
 protected void rblAuthor_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (rblAuthor.SelectedItem.Text == "Nuevo")
     {
         ent_Auth = bsn_author.checkAuthor(textName.Text, textLastName.Text);
         bsn_write.deleteWrite(ent_Auth.Id, code);
         clean();
         textName.Enabled        = true;
         textLastName.Enabled    = true;
         textNationality.Enabled = true;
         insert = 1;
     }
     else
     {
         listAdd();
         ddlAuthor.AutoPostBack = true;
         insert = 0;
     }
 }
 protected void ShowAuthor(EntClsAuthor author)
 {
     textName.Text        = bsn_author.returnName(author.Name);
     textLastName.Text    = author.LastName;
     textNationality.Text = author.Nationality;
 }
        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();
            }
        }
Пример #14
0
 protected void ShowAuthor(EntClsAuthor objAuth)
 {
     textName.Text        = bsn_auth.returnName(objAuth.Name);
     textLastName.Text    = objAuth.LastName;
     textNationality.Text = objAuth.Nationality;
 }