'判断该窗体是否已经打开 
 
    Public Function OpenForm(ByVal myform As Form, ByVal MdiForm As Form) As Boolean 
 
        Dim form As Form 
 
        For Each form In MdiForm.MdiChildren 
 
            If form.Text = myform.Text Then 
 
                form.Activate() 
 
                Return True 
 
            End If 
 
        Next 
 
        Return False 
 
    End Function 
 

    

 

    
 
    '系统退出时的代码 
 
    Public Sub ExitSystem(ByVal Form_Name As String) 
 
        If Form_Name = "Exit" Then 
 
            '  If MsgBox("您真的要退出文件管理系统吗?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "退出系统") = MsgBoxResult.Yes Then 
 
            Application.Exit() 
 
            End 
 
            'End If 
 
        End If 
 
    End Sub 
 

    

 
 
 
    '判断字符是否为数字型,当为数字时返回True,不为时返回False 
 
    Public Function IsNumeric(ByVal strText As String) As Boolean 
 
        Dim charstr As Char 
 
        For Each charstr In strText 
 
            If Not Char.IsNumber(charstr) Then 
 
                Return False 
 
            End If 
 
        Next 
 
        Return True 
 
    End Function 
 

    

 
 
 
    '加密函数 
 
    Function EnPas(ByVal CodeStr As String) As String 
 
        Dim CodeLen As Integer = 30 
 
        Dim CodeSpace, Been, NewCodeInt As Integer 
 
        Dim EnPasStr As String = "" 
 
        Dim NewCode As String 
 
        CodeSpace = CodeLen - CodeStr.Length 
 
        If Not CodeSpace < 1 Then 
 
            For cecr As Integer = 1 To CodeSpace 
 
                CodeStr = CodeStr & Chr(21) 
 
            Next 
 
        End If 
 
        NewCodeInt = 1 
 
        NewCode = 1 
 
        For cecb As Integer = 1 To CodeLen 
 
            Been = CodeLen + Asc(CodeStr.Substring(cecb - 1, 1)) * cecb 
 
            NewCode = NewCode * Been 
 
        Next 
 
        CodeStr = NewCode 
 
        NewCode = Nothing 
 
        For cec As Integer = 1 To CodeStr.Length 
 
            Try 
 
                NewCode = NewCode & CfsCode(CodeStr.Substring(cec - 1, 3)) 
 
            Catch ex As Exception 
 
                Try 
 
                    NewCode = NewCode & CfsCode(CodeStr.Substring(cec - 1, 2)) 
 
                Catch exs As Exception 
 
                    NewCode = NewCode & CfsCode(CodeStr.Substring(cec - 1, 1)) 
 
                End Try 
 
            End Try 
 
        Next 
 
        For cec As Integer = 20 To NewCode.Length - 18 Step 2 
 
            EnPasStr = EnPasStr & NewCode.Substring(cec - 1, 1) 
 
        Next 
 
        Return EnPasStr 
 
    End Function 
 

      '加密子函数 
 
    Function CfsCode(ByVal Word As String) As String 
 
        Dim CfsCodeStr As String = "" 
 
        For cc As Integer = 1 To Word.Length 
 
            CfsCodeStr = CfsCodeStr & Asc(Word.Substring(cc - 1, 1)) 
 
        Next 
 
        CfsCodeStr = Hex(CfsCodeStr) 
 
        Return CfsCodeStr 
 
    End Function 
 

    

 
 
 
    '打开某一个程序              程序的路径 
 
    Public Function Openfile(ByVal FilePath As String) As Boolean 
 
        Try 
 
            System.Diagnostics.Process.Start(FilePath) 
 
            Return True 
 
        Catch ex As Exception 
 
            MsgBox(ex.Message) 
 
            Return False 
 
            Exit Function 
 
        End Try 
 

      End Function 

 

    

 

  #Region " XML文件操作部分(系统设置) " 
 
    Public Sub RendXml(ByVal filename As String) 
 
        Dim falg As Boolean = True 
 
        Dim fi As System.IO.FileInfo 
 
        fi = New System.IO.FileInfo(filename) 
 
        If fi.Exists Then 
 
            Dim doc As New XmlDocument 
 
            doc.Load(filename) 
 
            Dim nodeRoot = doc.DocumentElement 
 
            '连接数据库的IP、数据库名称、用户名、密码 
 
            Sys_Data_Source = nodeRoot.SelectSingleNode("Sys_Data_Source").InnerText 
 
            Sys_Data_Catalog = nodeRoot.SelectSingleNode("Sys_Data_Catalog").InnerText 
 
            Sys_Data_User = nodeRoot.SelectSingleNode("Sys_Data_User").InnerText 
 
            Sys_Data_Password = nodeRoot.SelectSingleNode("Sys_Data_Password").InnerText 
 
        Else 
 
            MessageBox.Show("系统初始化出错,请与系统管理员联系!!", "严重警告", MessageBoxButtons.OK, MessageBoxIcon.Error) 
 
            End 
 
        End If 
 
    End Sub 
 
#End Region