| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1115 人关注过本帖
标题:c#语言不会翻译 请解答
只看楼主 加入收藏
xsz9223344
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2009-11-5
收藏
 问题点数:0 回复次数:8 
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();
    }
}
搜索更多相关主题的帖子: 解答 语言 翻译 
2009-11-05 11:28
jedypjd
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:9
帖 子:1096
专家分:4969
注 册:2009-7-27
收藏
得分:0 
解答什么

天涯无岁月,歧路有风尘,百年浑似醉,是非一片云
2009-11-05 12:23
xsz9223344
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2009-11-5
收藏
得分:0 
回复 2楼 jedypjd
不会翻译
2009-11-05 13:17
zhaoxili
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:327
专家分:479
注 册:2009-1-3
收藏
得分:0 
翻译什么啊?  呵呵  不会是把程序翻译成中文吧?  哈哈
2009-11-07 22:34
夜龙魂
Rank: 2
等 级:论坛游民
帖 子:130
专家分:65
注 册:2009-9-24
收藏
得分:0 
意思就是第一次加载
LoadTreeView();
BindGrid();
调用这2个方法
分别是显示树菜单和邦定数据库
2009-11-09 17:37
C之魂
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2009-5-3
收藏
得分:0 
说清楚啊...
2009-11-11 19:10
xiangxiao
Rank: 2
来 自:北京
等 级:论坛游民
帖 子:30
专家分:38
注 册:2009-10-14
收藏
得分:0 
这种问题没法回答!
2009-11-11 19:54
mengfp
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:45
专家分:141
注 册:2009-8-5
收藏
得分:0 
晕死
2009-11-12 13:19
xslslx
Rank: 2
等 级:论坛游民
帖 子:58
专家分:65
注 册:2009-11-10
收藏
得分:0 
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();//执行LoadTreeView()方法或称函数
            BindGrid();//执行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();
    }
}
以上注解希望你满意,由于时间关系,无法仔细分析,如果有不正确的地方希望不要介意o(∩_∩)o...哈哈

老师的学生,学生的老师
2009-11-13 09:50
快速回复:c#语言不会翻译 请解答
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016139 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved