|
窗体1的代码如下
[code=csharp] public void itemtypelistshow()
{
treeView1.Nodes.Clear();
string SQL = "select * from ItemType";
DataSet ds = new DataSet();
Helper.HelperSQL.ExecuteSelectCmmond(SQL, ds);
int n = ds.Tables[0].Rows.Count;
for (int i = 0; i < n; i++)
{
string itemtypeid = ds.Tables[0].Rows["ItemTypeName"].ToString();
treeView1.Nodes.Add(itemtypeid );
// treeView1.SelectedNode.Nodes.Add(ds.Tables[0].Rows["ItemTypeName"].ToString());
string ddd = ds.Tables[0].Rows["ItemTypeId"].ToString();
string SQL1 = "select * from ItemBrand where ItemTypeId='"+ddd +"'";
DataSet ds2 = new DataSet();
Helper.HelperSQL.ExecuteSelectCmmond(SQL1, ds2);
int J = ds2.Tables[0].Rows.Count;
//下面添加父节点.子节点 tree.view操作
for (int K = 0; K < J; K++)
{
string ItemBrandName = ds2.Tables[0].Rows[K]["ItemBrandName"].ToString();
string eee = ds2.Tables[0].Rows[K]["ItemBrandId"].ToString();
treeView1.Nodes.Nodes.Add(ItemBrandName);
string SQL3 = "select * from ItemList where ItemBrandId='" + eee + "'";
DataSet ds3 = new DataSet();
Helper.HelperSQL.ExecuteSelectCmmond(SQL3, ds3);
}
}
}
[/code] |
|