public EntClsCategory listCategoryForid(int id) { EntClsCategory objcategory = new EntClsCategory(); string storeProcedure = "ListCategoryforid"; 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()) { objcategory = new EntClsCategory((int)dr["ID"], (string)dr["name"], (string)dr["descriptionC"]); } } } } return(objcategory); }
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 Page_Load(object sender, EventArgs e) { if (Session["admin"] == null) { Response.Redirect("Login.aspx"); } if (Session["edit"] == null || Session["author"] == null) { Response.Redirect("Autor.aspx"); } if (Session["book"] != null) { btnUpdate.Visible = true; btnRegister.Visible = false; btnUpdate.Enabled = true; ent_book = bsn_book.SearchBook(Session["book"].ToString()); textTitle.Text = ent_book.Name; textCode.Text = ent_book.Code; textCode.Enabled = false; textDate.Text = ent_book.DatePublish; textIsbn.Text = ent_book.Isbn; textStock.Text = Convert.ToString(ent_book.Stock); ent_category = bsn_category.listCategoryForid(ent_book.IdCateg); Session["book"] = null; } else { if (Session["regis"] != null) { btnRegister.Enabled = true; btnUpdate.Visible = false; } } idEditorial = Convert.ToInt32(Session["edit"].ToString()); idAuthor = Convert.ToInt32(Session["author".ToString()]); if (!IsPostBack) { loadDropDownList(); ddlCategory.AutoPostBack = true; ddlState.AutoPostBack = true; } }