| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:谁来帮我写点注释
只看楼主 加入收藏
andy560225
Rank: 1
来 自:天上
等 级:新手上路
帖 子:72
专家分:0
注 册:2008-10-29
收藏
 问题点数:0 回复次数:0 
谁来帮我写点注释
刚刚找个源码
正是我想要的
可是有点看不懂
希望有人帮忙写的注释

private void Form1_Load(object sender, System.EventArgs e)
        {
            this.lvwSchool.Columns.Add("学号",80,HorizontalAlignment.Center);
            this.lvwSchool.Columns.Add("姓名",100,HorizontalAlignment.Center);
            this.lvwSchool.Columns.Add("成绩",105,HorizontalAlignment.Center);
            this.lvwSchool.View = View.Details;

            cnn = new SqlConnection("server = .; uid = sa; pwd = ; database = school");
            adp = new SqlDataAdapter();

            cmm = new SqlCommand("select xh from Class1",cnn);
            dsxh = new DataSet("school");
            adp.SelectCommand = cmm;
            adp.Fill(dsxh,"Class1");

            TreeNode node1 = new TreeNode(dsxh.DataSetName);
            this.tvwSchool.Nodes.Add(node1);

            node1 = new TreeNode(dsxh.Tables["Class1"].TableName);
            this.tvwSchool.Nodes[0].Nodes.Add(node1);
            foreach(DataRow r in dsxh.Tables["Class1"].Rows)
            {
                node1 = new TreeNode(r["xh"].ToString());
                this.tvwSchool.Nodes[0].Nodes[0].Nodes.Add(node1);
            }

            cmm = new SqlCommand("select xh from Class2",cnn);
            adp.SelectCommand = cmm;
            adp.Fill(dsxh,"Class2");
            TreeNode node2 = new TreeNode(dsxh.Tables["Class2"].TableName);
            this.tvwSchool.Nodes[0].Nodes.Add(node2);
            foreach(DataRow r in dsxh.Tables["Class2"].Rows)
            {
                node2 = new TreeNode(r["xh"].ToString());
                this.tvwSchool.Nodes[0].Nodes[1].Nodes.Add(node2);
            }
        }

        private void tvwSchool_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            this.lvwSchool.Items.Clear();
            if(tvwSchool.SelectedNode.Parent != null && tvwSchool.SelectedNode.Nodes.Count != 0)
            {
                string bj = tvwSchool.SelectedNode.Text;
                cmm = new SqlCommand("select * from " + bj + "",cnn);
                ds = new DataSet("school");
                adp.SelectCommand = cmm;
                adp.Fill(ds,"Class");
                for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    lstItem = new ListViewItem(ds.Tables[0].Rows[i][0].ToString());
                    for(int j = 0; j < ds.Tables[0].Columns.Count - 1; j++)
                    {
                        lstItem.SubItems.Add(ds.Tables[0].Rows[i][j + 1].ToString());
                    }
                    lvwSchool.Items.Add(lstItem);
                }
            }
            else if(tvwSchool.SelectedNode.Parent != null && tvwSchool.SelectedNode.Nodes.Count == 0)
            {
                string xh = tvwSchool.SelectedNode.Text;
                string bj = tvwSchool.SelectedNode.Parent.Text;
                cmm = new SqlCommand("select * from " + bj +" where xh = '" + xh +"'",cnn);
                adp.SelectCommand = cmm;
                ds = new DataSet("school");
                adp.Fill(ds,"Class");
                for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    lstItem = new ListViewItem(ds.Tables[0].Rows[i][0].ToString());
                    for(int j = 0; j < ds.Tables[0].Columns.Count - 1; j++)
                    {
                        lstItem.SubItems.Add(ds.Tables[0].Rows[i][j + 1].ToString());
                    }
                    lvwSchool.Items.Add(lstItem);
                }
            }
搜索更多相关主题的帖子: 注释 
2008-11-26 14:23
快速回复:谁来帮我写点注释
数据加载中...
 
   



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

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