c#语言不会翻译 请解答
using System;using System.Web.UI.WebControls;
using System.Collections.Generic;
using BookManage.Model;
using BookManage.BLL;
public partial class Book_Manage : PageBase
{
public int book_category_id = 0;
private const string STRING_ROOT = "所有分类";
protected void Page_Load(object sender, EventArgs e)
{
base.CheckUserPopedom();
if (!Page.IsPostBack)
{
LoadTreeView();
BindGrid();
}
}
private void LoadTreeView()
{
BookManage.BLL.Book_Category newCategory = new BookManage.BLL.Book_Category();
IList<BookManage.Model.Book_CategoryInfo> data = newCategory.Get_All();
InitTreeView("0", (TreeNode)null, data);
this.tv_book_category.CollapseAll();
}
//InitTreeView 使用递归生成类别树
private void InitTreeView(string ParentId, TreeNode ParentNode, IList<BookManage.Model.Book_CategoryInfo> data)
{
if (ParentNode == null)//无根结点
{
TreeNode treeNode = new TreeNode();
treeNode.Value = "0";
treeNode.Text = STRING_ROOT;
treeNode.ToolTip = STRING_ROOT;
this.tv_book_category.Nodes.Add(treeNode);
InitTreeView(treeNode.Value, treeNode, data);
}
else
{
foreach (BookManage.Model.Book_CategoryInfo category in data)
{
TreeNode treeNode = new TreeNode();
if (ParentNode.Value.Equals(category.book_category_parent_id.ToString()) && !ParentId.Equals(category.book_category_id.ToString()))
{
{
treeNode.Value = category.book_category_id.ToString();
treeNode.Text = category.book_category_name;
treeNode.ToolTip = category.book_category_name;
ParentNode.ChildNodes.Add(treeNode);
InitTreeView(treeNode.Value, treeNode, data);
}
}
}
}
}
protected void tv_book_category_SelectedNodeChanged(object sender, EventArgs e)
{
this.book_category_id = Int32.Parse(this.tv_book_category.SelectedNode.Value);
}
//绑定信息
private void BindGrid()
{
try
{
this.book_category_id = Int32.Parse(this.tv_book_category.SelectedNode.Value);
Book newBook = new Book();
IList<BookInfo> data = newBook.Get_By_Keyword(this.hdf_keyword.Value, this.book_category_id);
gv_manage.DataSource = data;
gv_manage.DataBind();
}
catch
{
Book newBook = new Book();
IList<BookInfo> data = newBook.Get_By_Keyword(this.hdf_keyword.Value, 0);
gv_manage.DataSource = data;
gv_manage.DataBind();
}
}
protected void btn_search_Click(object sender, EventArgs e)
{
this.hdf_keyword.Value = this.txt_keyword.Text;
BindGrid();
}
protected void btn_del_Click(object sender, EventArgs e)
{
string ids = this.GetSelectedItemID("checkbox");
int flag = 1;
if (ids.Trim() != "")
{
try
{
string[] sResult = ids.Split(',');
foreach (string s in sResult)
{
int id = Int32.Parse(s);
Book newBook = new Book();
flag = 1 + newBook.Delete(id) - flag;//flag<=0时说明有删除失败
}
WebUtility.CheckOperating(flag, 1);
BindGrid();
}
catch
{
flag = 0;
WebUtility.CheckOperating(flag, 5);
}
}
}
//遍历GridView获得checked的ID
private string GetSelectedItemID(string controlID)
{
string selectedID = "";
for (int i = 0; i < this.gv_manage.Rows.Count; i++)
{
CheckBox cb = (CheckBox)this.gv_manage.Rows[i].Cells[0].FindControl(controlID);
if (cb.Checked)
{
selectedID += gv_manage.DataKeys[gv_manage.Rows[i].RowIndex].Value.ToString() + ",";
}
}
if (selectedID.Length > 0)
{
selectedID = selectedID.Substring(0, selectedID.Length - 1);
}
return selectedID;
}
protected void gv_manage_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
this.gv_manage.PageIndex = e.NewPageIndex;
BindGrid();
}
}