private void MakeTree() { DataTable rootDrug; DataTable secordDrug; DataTable drug; rootDrug = m_SqlManger.GetMedicineTreeOne(); //第一级 foreach (DataRow dr in rootDrug.Rows) { TreeListNode parentNode = null;// parentNode = treeList_Medicine.AppendNode(new object[] { dr["categorytwo"].ToString(), dr["categorytwo"].ToString() }, null); secordDrug = m_SqlManger.GetMedicaineTreeSec(dr["categorytwo"].ToString()); //第二级 foreach (DataRow secdr in secordDrug.Rows) { TreeListNode node = null;// node = treeList_Medicine.AppendNode(new object[] { secdr["categorythree"].ToString(), secdr["categorythree"].ToString() }, parentNode); drug = m_SqlManger.GetMedicaineByThreeName(secdr["categorythree"].ToString()); foreach (DataRow threedr in drug.Rows) { TreeListNode threenode = null;// threenode = treeList_Medicine.AppendNode(new object[] { threedr["Name"].ToString(), threedr["ID"].ToString() }, node); threenode.Tag = threedr["id"].ToString(); } } } }
/// <summary> /// 正常加载树一级节点 /// 王冀 2012 10 31 /// </summary> /// <param name="rootDrug"></param> private void MakeTreeone(DataTable rootDrug) { try { foreach (DataRow dr in rootDrug.Rows) { TreeListNode parentNode = null;// if (!m_HaveBindNode.Contains(dr["categorytwo"].ToString() + "1")) { parentNode = treeList_Medicine.AppendNode(new object[] { dr["categorytwo"].ToString(), "Folder", dr["categorytwo"].ToString() }, null); m_HaveBindNode.Add(dr["categorytwo"].ToString() + "1"); DataTable secordDrug = m_SqlManger.GetMedicaineTreeSec(dr["categorytwo"].ToString()); MakeTreetwo(secordDrug, parentNode); } } } catch (Exception ex) { MyMessageBox.Show(1, ex); } }