/// <summary>
        /// 
        /// </summary>
        /// <param name="strID"></param>
        /// <returns></returns>
        DIC_STRU GetStru_ByID( string strID )
        {
            SQL Sql = new SQL( CONNECT.SqlConnect );

            string strRet = "";

            string strSql = String.Format( "select * from {1} where {2}='{3}' ", Tab.ID, Tab.TAB, Tab.ID, strID );

            DataTable dt = Sql.ExecDataTable( strSql );
            Sql.Close();

            if( !SQL.IsValid( ref dt ) )
                return null;

            DIC_STRU stru = new DIC_STRU();

            DataRow dr = dt.Rows[0];
            stru.Dr2Stru( dr );

            return stru;
        }
        /// <summary>
        /// 只是追加 新子项,不删除旧有的子项。
        /// </summary>
        /// <param name="strFullPath"></param>
        /// <param name="strValue"></param>
        /// <returns></returns>
        public DIC_STRU Append( string strFullPath, string strValue )
        {
            DIC_STRU struFind = new DIC_STRU();
            if ( isExist( strFullPath, strValue, ref struFind ) )
                return struFind;

            DIC_STRU struParent = CreateNode( strFullPath );
            return AddChild( struParent, strValue );
        }
        private bool isExist( string strFullPath, string strValue , ref DIC_STRU struFind )
        {
            struFind = new DIC_STRU();

            List<DIC_STRU> listAll = GetAll_ByPath( strFullPath );
            foreach ( DIC_STRU stru in listAll )
            {
                if (stru.Name == strValue)
                {
                    struFind = stru;
                    return true;
                }
            }
            return false;
        }
 /// <summary>
 /// 一次添加多个子项目。
 /// </summary>
 /// <param name="struRoot"></param>
 /// <param name="strsName"></param>
 public void AddChildStrs( DIC_STRU struRoot, string[] strsName )
 {
     foreach( string strName in strsName )
     {
         AddChild( struRoot, strName, "" );
     }
 }
 public DIC_STRU AddChild( DIC_STRU struRoot, string strName )
 {
     return AddChild( struRoot, strName, "" );
 }
        public DIC_STRU AddChild( DIC_STRU struRoot, string strName, string strRemark )
        {
            if( struRoot == null || struRoot.ID.Trim() == String.Empty )
                return null;

            int nNo = GetChildMaxNo( struRoot.ID ) + 1;

            DIC_STRU stru = new DIC_STRU();
            stru.SetChild( struRoot.ID, strName, nNo, strRemark );
            stru.ID = Save( stru );
            return stru;
        }
 public DIC_STRU AddSubRoot( DIC_STRU struRoot, string strName )
 {
     return AddSubRoot( struRoot, strName, "" );
 }
        public string Save( DIC_STRU stru )
        {
            if( stru.Name.Trim() == "" )
                return "";

            return Orm.Save( stru );
        }
 public DIC_STRU AddRoot( string strRootName, string strRemark )
 {
     DIC_STRU stru = new DIC_STRU();
     stru.SetRoot( strRootName, strRemark );
     stru.ID = Save( stru );
     return stru;
 }
 public void Delete( DIC_STRU stru )
 {
     Bll.Delete( stru );
 }
 public string Save( DIC_STRU stru )
 {
     return Bll.Save( stru );
 }
        /// <summary>
        /// 把一个子项的序号往后移动。
        /// </summary>
        /// <param name="struCur"></param>
        /// <returns></returns>
        public bool ChildMove2Next( DIC_STRU struCur )
        {
            DIC_STRU struPre = GetNextChild( struCur );
            if( struPre == null )
                return false;

            string strTmp = struPre.OrderNo;
            struPre.OrderNo = struCur.OrderNo;
            struCur.OrderNo = strTmp;

            Save( struCur );
            Save( struPre );

            return true;
        }
        public DIC_STRU GetNextChild( DIC_STRU stru )
        {
            if( !stru.IsValid() )
                return null;

            string strParenID = stru.ParentID;
            if( strParenID == String.Empty )
                return null;

            string strCurNo = stru.OrderNo;

            SQL Sql = new SQL( CONNECT.SqlConnect );

            List<DIC_STRU> list = new List<DIC_STRU>();

            string strSql = String.Format( "select top 1 * from {0} where {1}='{2}' and {3}>{4} order by {3} ", Tab.TAB, Tab.ParentID, strParenID, Tab.OrderNo, strCurNo );

            DataTable dt = Sql.ExecDataTable( strSql );
            list = DIC_STRU.Dt2List( ref dt );

            Sql.Close();

            if( list == null || list.Count <= 0 )
                return null;

            return list[0];
        }
        DIC_STRU CreatePath( string strFullPath )
        {
            string[] strs = strFullPath.Split( new char[] { '/', '\\' } );
            if( strs.Length <= 0 )
                return null;

            DIC_STRU stru = new DIC_STRU();
            DIC_STRU struRoot = new DIC_STRU();
            string strPath = String.Empty;

            int n = 0;
            foreach( string str in strs )
            {
                if( n > 0 )
                    strPath += "/";
                strPath += str;

                stru = GetStru_ByPath( strPath );
                if( stru == null )
                {
                    if( n == 0 )
                        stru = AddRoot( strPath );
                    else
                        stru = AddSubRoot( struRoot, str );
                }

                if( stru == null )
                    return null;

                struRoot = stru;

                n++;
            }

            return stru;
        }
 public void Delete( DIC_STRU stru )
 {
     Delete_ByID( stru.ID );
 }
        public DIC_STRU AddSubRoot( DIC_STRU struRoot, string strName, string strRemark )
        {
            if( struRoot.ID.Trim() == String.Empty )
                return null;

            List<DIC_STRU> lst = GetAllChild( struRoot.ID );
            int nNo = lst.Count + 1;

            DIC_STRU stru = new DIC_STRU();
            stru.SetSubRoot( struRoot.ID, strName, nNo, strRemark );
            stru.ID = Save( stru );
            return stru;
        }
        static public List<DIC_STRU> Table2List( ref DataTable dt )
        {
            List<DIC_STRU> list = new List<DIC_STRU>();

            if( SQL.IsNotValid( ref dt ) )
                return list;

            foreach( DataRow dr in dt.Rows )
            {
                DIC_STRU stru = new DIC_STRU();
                stru.Dr2Stru( dr );
                list.Add( stru );
            }

            return list;
        }
        public string Save( DIC_STRU stru )
        {
            DataTable dt = GetBlank();
            DataRow dr = dt.Rows[0];
            stru.Stru2Dr( ref dr );

            SQL Sql = new SQL( CONNECT.SqlConnect );

            string strID = Sql.Save( ref dt );

            Sql.Close();

            return strID;
        }