table查询功能

  //分别将 省份 地区 站点绑定到treeview
        private void   BindTreeView_Zone_Station(TreeView Tree_View)
        {
            //声明一个dataset
            DataSet Zone_StationSet = Huo_PiaoClass.Select_Zone_StationInfo();
            //声明省份表
            DataTable ShengFen_Table = Zone_StationSet.Tables[0];
            //声明地区表
            DataTable DiQu_table = Zone_StationSet.Tables[1];
            //声明车站表
            DataTable Station_Table = Zone_StationSet.Tables[2];
            //循环省份表里的所有项
            foreach (DataRow Shen_fenRow in ShengFen_Table.Rows)
            {
                //声明省份名称
                string Shen_FenName = Shen_fenRow["ShengFenMingCheng_QiTaGuo"].ToString().Trim();
                //将省份增加到根结点
                TreeNode ShenFenNode = new TreeNode(Shen_FenName);
                //设置根结点的名称值为省份代码
                ShenFenNode.Name = Shen_fenRow["ShengFenDaiMa"].ToString().Trim();
                //将该结点添加到Tree_View中
                Tree_View.Nodes.Add(ShenFenNode);
              
                //循环将地区信息添加到省份结点中
                foreach (DataRow Zone_Row in DiQu_table.Select("ShengFenDaiMa=" + Shen_fenRow["ShengFenDaiMa"].ToString().Trim(), "ShengFenDaiMa"))
                {
                    //声明地区名称
                    string Di_QuName = Zone_Row["DiQuMingCheng"].ToString().Trim();
                    //声明地区结点
                    TreeNode ZoneNode = new TreeNode(Di_QuName);
                    //绑定地区代码
                    ZoneNode.Name = Zone_Row["DiQuDaiMa"].ToString().Trim();
                    //将地区作为子结点添加到相应的父结点中
                    ShenFenNode.Nodes.Add(ZoneNode);
                    //循环将站点信息添加到地区结点中
                    foreach (DataRow Station_Row in Station_Table.Select("DiQuDaiMa=" + Zone_Row["DiQuDaiMa"].ToString().Trim(), "DiQuDaiMa"))
                    {
                        //声明站点名称
                        string Station_Name = Station_Row["CheDuiMingCheng"].ToString().Trim();
                        //声明站点结点
                        TreeNode Station_Node = new TreeNode(Station_Name);
                        //绑定站点(车队代码)
                        Station_Node.Name = Station_Row["CheDuiDaiMa"].ToString().Trim();
                        //将站点添加到地区结点中
                        ZoneNode.Nodes.Add(Station_Node);

                    }
                }
            }
           
        }

你可能感兴趣的:(String,tree,table,dataset)