You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.8 KiB

Imports System.IO
Namespace EDOKA
Public Class DB_Connection
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, 5)) = "EDOKA" 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
'release 5.5
If Globals.ConnectionFileName.Length = 0 And Globals.Connection_Overwritten = False Then
If fc < 2 Then Globals.ConnectionFileName = "edokaconn.cfg"
Globals.ConnectionFileName = Application.StartupPath + "\" + Globals.ConnectionFileName
End If
Dim ofile As System.IO.File
Dim oread As System.IO.StreamReader
oread = ofile.OpenText(Globals.ConnectionFileName)
'MsgBox(Globals.ConnectionFileName)
sConnectionString = oread.ReadLine
sConnectionString = Crypto.DecryptText(sConnectionString, "HutterundMueller")
sConnectionString = Left(sConnectionString, Len(sConnectionString) - 1)
Globals.sConnectionString = sConnectionString
oread.Close()
Globals.conn.sConnectionString = Globals.sConnectionString
If Globals.Connection_Overwritten = False Then Check_DBConn_Overwrite()
'If fc < 2 Then Globals.ConnectionFileName = "edokaconn.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
'oread.Close()
'Globals.conn.sConnectionString = Globals.sConnectionString
'Check_DBConn_Overwrite()
End Sub
Shared Sub Check_DBConn_Overwrite()
Dim clsma As New edokaDB.clsMyMitarbeiter
Dim tgnummer As String = clsma.Get_Username
Dim ConnectionFile As String
ConnectionFile = DivFnkt.Check_Connectionchange(tgnummer)
If ConnectionFile <> "" Then
Globals.ConnectionFileName = ConnectionFile
Dim ofile As System.IO.File
Dim oread As System.IO.StreamReader
oread = ofile.OpenText(Globals.ConnectionFileName)
sConnectionString = oread.ReadLine
sConnectionString = Crypto.DecryptText(sConnectionString, "HutterundMueller")
sConnectionString = Left(sConnectionString, Len(sConnectionString) - 1)
Globals.sConnectionString = sConnectionString
Globals.conn.sConnectionString = Globals.sConnectionString
oread.Close()
Globals.Connection_Overwritten = True
End If
End Sub
End Class
End Namespace