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="secordDrug"></param> /// <param name="parentNode"></param> private void MakeTreetwo(DataTable secordDrug, TreeListNode parentNode) { try { foreach (DataRow secdr in secordDrug.Rows) { TreeListNode node = null;// if (!m_HaveBindNode.Contains(secdr["categorythree"].ToString() + "2" + secdr["categorytwo"].ToString())) { node = treeList_Medicine.AppendNode(new object[] { secdr["categorythree"].ToString(), "Folder", secdr["categorythree"].ToString() }, parentNode); m_HaveBindNode.Add(secdr["categorythree"].ToString() + "2" + secdr["categorytwo"].ToString()); DataTable drug = m_SqlManger.GetMedicaineByThreeName(secdr["categorythree"].ToString()); MakeTreethree(drug, node); } } } catch (Exception ex) { MyMessageBox.Show(1, ex); } }