protected void grvbookcategorylist_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "editcategory") { #region 编辑 Panel1.Visible = true; ViewState["operate"] = "edit"; Categories category = CategoriesManager.GetCategoriesById(Convert.ToInt32(e.CommandArgument)); txtbookcategory.Text = category.Name; #endregion } if (e.CommandName == "deletecategory") { #region 除 ViewState["CategoryId"] = e.CommandArgument; if (CategoriesManager.FindCategoryIsBook(Convert.ToInt32(ViewState["CategoryId"]))) { CategoriesManager.DeleteCategoryById(Convert.ToInt32(ViewState["CategoryId"])); } else { mydiv.Visible = true; } BindData(); #endregion } }
protected void btnremove_Click(object sender, EventArgs e) { #region 移动图书 foreach (GridViewRow grv in grvbooklist.Rows) { CheckBox chb = (CheckBox)grv.FindControl("cbok"); if (chb.Checked == true) { int bookid = Convert.ToInt32(grvbooklist.DataKeys[grv.RowIndex].Value); int categoryid = Convert.ToInt32(ddlnewcategory.SelectedValue); Books book = Bookmanager.GetBookDetailById(bookid); book.Categories = CategoriesManager.GetCategoriesById(categoryid); Bookmanager.EditBook(book); } } BindData(); #endregion }
public Books GetBook(Books book) { #region 获取图书信息 book.Author = txtauthor.Text; book.ContentDescription = txtcontentdescription.Text; book.WordsCount = Convert.ToInt32(txtcount.Text); book.ISBN = txtISBN.Text; book.UnitPrice = Convert.ToDecimal(txtprice.Text); book.PublishDate = Convert.ToDateTime(txtpublishdate.Text); book.EditorComment = txtrecommand.Text; book.Title = txttitle.Text; book.TOC = ftbtoc.Text; book.AuthorDescription = authordescription.Text; book.Publishers = PublisherManager.GetPublishersById(Convert.ToInt32(ddlpublisher.SelectedValue)); book.Categories = CategoriesManager.GetCategoriesById(Convert.ToInt32(ddlcategory.SelectedValue)); return(book); #endregion }
protected void btnok_Click(object sender, EventArgs e) { if (ViewState["operate"].ToString() == "edit") { #region 更新 Categories category = CategoriesManager.GetCategoriesById(Convert.ToInt32(ViewState["categoryId"])); category.Name = txtbookcategory.Text.Trim(); CategoriesManager.UpdateCategory(category); Panel1.Visible = false; BindData(); #endregion } else { #region 添加 CategoriesManager.AddCategory(txtbookcategory.Text); Panel1.Visible = false; BindData(); #endregion } }