/// <summary> /// 删除节点 /// </summary> /// <param name="Node"></param> public void DeleteNode(ContractBoiNode Node) { //已删除过,则返回 if (!NodeList.Contains(Node)) { return; } // RecursionDeleteNode(Node); List <ContractBoiNode> lstChildren = Node.Children.ToList(); for (int i = lstChildren.Count - 1; i >= 0; i--) { DeleteNode(lstChildren[i]); } if (NodeList.Contains(Node)) { NodeList.Remove(Node); } if (updateList.Contains(Node)) { updateList.Remove(Node); } String strCode = null; int iCode = 0; if (Node.ParentBoiNode != null) { //删除节点的序号 int iIndex = Node.ParentBoiNode.Children.IndexOf(Node); //删除节点不是最后一个 if (iIndex < Node.ParentBoiNode.Children.Count - 1) { //移除节点 Node.ParentBoiNode.Children.Remove(Node); for (int i = iIndex; i < Node.ParentBoiNode.Children.Count; i++) { //对后面的节点的序号 统一减1 strCode = Node.ParentBoiNode.Children[i].ItemCode; iCode = System.Convert.ToInt32(strCode.Substring(strCode.Length - 3, 3)); iCode = iCode - 1; strCode = Node.ParentBoiNode.ItemCode + iCode.ToString().PadLeft(3, '0'); ChangeCode(Node.ParentBoiNode.Children[i], strCode); } } else { Node.ParentBoiNode.Children.Remove(Node); } CalcParentNode(Node.ParentBoiNode); } else { int iIndex = RootList.IndexOf(Node); //删除节点不是最后一个 if (iIndex < RootList.Count - 1) { //移除节点 RootList.Remove(Node); for (int i = iIndex; i < RootList.Count; i++) { //对后面的节点的序号 统一减1 strCode = RootList[i].ItemCode; iCode = System.Convert.ToInt32(strCode); iCode = iCode - 1; strCode = iCode.ToString().PadLeft(2, '0'); ChangeCode(RootList[i], strCode); } } else { RootList.Remove(Node); } } if (ListChanged != null) { ListChanged(); } }