Initial commit
This commit is contained in:
59
SW/AssessmentMgmt/DB/MyDBObjects/db_connection.vb
Normal file
59
SW/AssessmentMgmt/DB/MyDBObjects/db_connection.vb
Normal file
@@ -0,0 +1,59 @@
|
||||
Imports System.IO
|
||||
Namespace DB
|
||||
''' <summary>
|
||||
''' Dynamische Datenbank-Verbindung aufbauen. Verwendet wird standardmässig Vertragsverwaltung.cfg.
|
||||
''' Sollen Datenbank-Verbindungen zur Auswahl angezeigt werden, werden sämntliche Datenbank-Verbindungsdateien
|
||||
''' mit dem Namen "Vertragsverwaltung....cfg" berücksichtigt
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Public Class DB_Connection
|
||||
|
||||
''' <summary>
|
||||
''' Liest sämtlcihe CFG-Dateien mit dem Namen "Vertragsverwaltung...". Sind meherere Dateien vorhanden,
|
||||
''' wird ein Auswahldialog zur Datenbank-Selektion angezeigt.
|
||||
''' Standardmässig wird Vertragsverwaltung.cfg als CFG-Datei benutzt.
|
||||
'''
|
||||
''' Die CFG-Datei ist verschlüsselt und wird über die Crypto-Funktionen entschlüsselt.
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Shared Sub New()
|
||||
Dim fc As Integer = 0
|
||||
If Globals.ConnectionFileName.Length = 0 Then
|
||||
Dim Dir As DirectoryInfo = New DirectoryInfo(Application.StartupPath)
|
||||
Try
|
||||
Dim f As New frmDatenbankauswahl()
|
||||
Dim ChildFile As FileInfo
|
||||
For Each ChildFile In Dir.GetFiles()
|
||||
If UCase(Left(ChildFile.Name, 14)) = "ASSESSMENTMGMT" And UCase(ChildFile.Extension) = ".CFG" Then
|
||||
f.ListBox1.Items.Add(ChildFile.Name)
|
||||
fc = fc + 1
|
||||
End If
|
||||
Next
|
||||
If fc > 1 Then
|
||||
f.ListBox1.SelectedIndex = 0
|
||||
f.ListBox1.Select()
|
||||
f.ShowDialog()
|
||||
Globals.ConnectionFileName = f.ListBox1.SelectedItem
|
||||
f.Dispose()
|
||||
End If
|
||||
Catch except As Exception
|
||||
fc = 0
|
||||
Exit Sub
|
||||
End Try
|
||||
End If
|
||||
If fc < 2 Then Globals.ConnectionFileName = "Assessmentmgmt.cfg"
|
||||
Dim ofile As System.IO.File
|
||||
Dim oread As System.IO.StreamReader
|
||||
oread = ofile.OpenText(Application.StartupPath + "\" + Globals.ConnectionFileName)
|
||||
sConnectionString = oread.ReadLine
|
||||
sConnectionString = Crypto.DecryptText(sConnectionString, "HutterundMueller")
|
||||
sConnectionString = Left(sConnectionString, Len(sConnectionString) - 1)
|
||||
Globals.sConnectionString = sConnectionString
|
||||
Globals.conn.sConnectionString = sConnectionString
|
||||
oread.Close()
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
|
||||
Reference in New Issue
Block a user