jj: Add form to connect to db

This commit is contained in:
Jonathan Jenne 2018-06-12 13:49:13 +02:00
parent 2ca9c7e29d
commit d2d24d1d13
6 changed files with 838 additions and 0 deletions

View File

@ -51,6 +51,9 @@
<ApplicationIcon>user.ico</ApplicationIcon> <ApplicationIcon>user.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="DD_LIB_Standards">
<HintPath>P:\Visual Studio Projekte\Bibliotheken\DD_LIB_Standards.dll</HintPath>
</Reference>
<Reference Include="DevExpress.Data.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Data.v15.2, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Printing.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Printing.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Reference Include="DevExpress.Sparkline.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" /> <Reference Include="DevExpress.Sparkline.v15.2.Core, Version=15.2.16.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
@ -92,6 +95,12 @@
<Compile Include="ApplicationEvents.vb" /> <Compile Include="ApplicationEvents.vb" />
<Compile Include="ClassActiveDirectory.vb" /> <Compile Include="ClassActiveDirectory.vb" />
<Compile Include="ClassDragDrop.vb" /> <Compile Include="ClassDragDrop.vb" />
<Compile Include="frmConfigDatabase.Designer.vb">
<DependentUpon>frmConfigDatabase.vb</DependentUpon>
</Compile>
<Compile Include="frmConfigDatabase.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmADImport_Groups.Designer.vb"> <Compile Include="frmADImport_Groups.Designer.vb">
<DependentUpon>frmADImport_Groups.vb</DependentUpon> <DependentUpon>frmADImport_Groups.vb</DependentUpon>
</Compile> </Compile>
@ -111,6 +120,7 @@
<DependentUpon>frmMain.vb</DependentUpon> <DependentUpon>frmMain.vb</DependentUpon>
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="ModuleRuntime.vb" />
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb"> <Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
@ -136,6 +146,9 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="frmConfigDatabase.resx">
<DependentUpon>frmConfigDatabase.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmADImport_Groups.resx"> <EmbeddedResource Include="frmADImport_Groups.resx">
<DependentUpon>frmADImport_Groups.vb</DependentUpon> <DependentUpon>frmADImport_Groups.vb</DependentUpon>
</EmbeddedResource> </EmbeddedResource>

View File

@ -0,0 +1,248 @@
Imports System.IO
Imports DD_LIB_Standards
Module ModuleRuntime
Public MyConnectionString As String
Public ConfigPath As String = Path.Combine(Application.UserAppDataPath, "UserConfig.xml")
Public rowresult
Public Function SaveMySettingsValue(name As String, value As String, type As String)
Try
Dim DT As DataTable
If type = "ConfigMain" Then
DT = GetTablefromXML(ConfigPath)
End If
If Not DT Is Nothing Then
For Each Row As DataRow In DT.Rows
If Row.Item("ConfigName") = name Then
Row.Item("Value") = value
End If
Next
DT.AcceptChanges()
DT.WriteXml(ConfigPath)
Else
MsgBox("Setting could not be saved! Check logfile.", MsgBoxStyle.Critical)
End If
Catch ex As Exception
MsgBox("Error in SaveConfigValue" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
Return True
End Function
Private Function GetTablefromXML(path As String)
Try
Dim DS As New DataSet
DS.ReadXml(path)
Return DS.Tables(0)
Catch ex As Exception
MsgBox("Error in GetTablefromXML" & vbNewLine & ex.Message & vbNewLine & "ConfigPath: " & vbNewLine & path, MsgBoxStyle.Critical)
clsLogger.Add("Error in GetTablefromXML: " & ex.Message, True)
clsLogger.Add(">> ConfigPath: " & ConfigPath, False)
Return Nothing
End Try
End Function
Public Function MySettings_Load()
Try
Dim DT As DataTable
'if file doesn't exist, create the file with its default xml table
If Not File.Exists(ConfigPath) Then
clsLogger.Add(">> ConfigFile was created in: " & ConfigPath, False)
DT = CreateConfigTable()
DT.WriteXml(ConfigPath)
clsLogger.Add(">> Defaultvalues were saved.", False)
End If
DT = GetTablefromXML(ConfigPath)
If DT Is Nothing Then
MsgBox("Configuration could not be loaded!! Check LogFile!", MsgBoxStyle.Critical)
Return False
End If
For Each Row As DataRow In DT.Rows
rowresult &= Row.Item("ConfigName")
Select Case Row.Item("ConfigName")
Case "MyConnectionString"
Dim connstring As String
'Den ConnectonString mit verschlüsseltem PW laden
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.ConnectionString = Row.Item("Value")
If Not csb.ConnectionString = "" Then
If csb.ConnectionString.Contains("Password=") Then
'sa-
'Jetzt das Passwort entschlüsseln
Dim PWplainText As String
Dim wrapper As New clsEncryption("!35452didalog=")
' DecryptData throws if the wrong password is used.
Try
PWplainText = wrapper.DecryptData(csb.Password)
connstring = Row.Item("Value").ToString.Replace(csb.Password, PWplainText)
Catch ex As Exception
clsLogger.Add("- the Password '" & csb.Password & "' could not be decrypted", False)
connstring = ""
End Try
Else
'Windows-Auth
connstring = Row.Item("Value").ToString
End If
MyConnectionString = connstring
Else
MyConnectionString = ""
End If
End Select
Next
'update 1.1
If rowresult.Contains("WD_ShowDocs") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "WD_ShowDocs"
newRow("Value") = "False"
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("Sett_ConstructorStart") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "Sett_ConstructorStart"
newRow("Value") = "0"
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("FWSCAN_started") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "FWSCAN_started"
newRow("Value") = "False"
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("Task_Popup_minutes") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "Task_Popup_minutes"
newRow("Value") = "2"
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("PATH_ADDON") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "PATH_ADDON"
newRow("Value") = ""
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("MyProxyConnectionString") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "MyProxyConnectionString"
newRow("Value") = ""
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("MyLinkedServer") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "MyLinkedServer"
newRow("Value") = ""
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
If rowresult.Contains("MyFormsDesign") = False Then
Dim newRow As DataRow = DT.NewRow()
newRow("ConfigName") = "MyFormsDesign"
newRow("Value") = ""
DT.Rows.Add(newRow)
DT.WriteXml(ConfigPath)
End If
Catch ex As Exception
MsgBox("Error in LoadMyConfig" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
clsLogger.Add("Error in LoadMyConfig: " & ex.Message, True)
Return False
End Try
Return True
End Function
Private Function CreateConfigTable() As DataTable
Try
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
table.TableName = "MyConfig"
' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID",
GetType(System.Int32))
idColumn.AutoIncrement = True
idColumn.AutoIncrementSeed = 0
idColumn.AutoIncrementStep = 1
table.Columns.Add("ConfigName", GetType(System.String))
table.Columns.Add("Value", GetType(System.String))
'Set the ID column as the primary key column.
table.PrimaryKey = New DataColumn() {idColumn}
Dim newRow As DataRow = table.NewRow()
newRow("ConfigName") = "MyConnectionString"
newRow("Value") = ""
table.Rows.Add(newRow)
Dim newRow1 As DataRow = table.NewRow()
newRow1("ConfigName") = "LogErrorsOnly"
newRow1("Value") = "True"
table.Rows.Add(newRow1)
Dim newRow2 As DataRow = table.NewRow()
newRow2("ConfigName") = "Sett_TaskOverviewKeepInFront"
newRow2("Value") = "True"
table.Rows.Add(newRow2)
Dim newRow3 As DataRow = table.NewRow()
newRow3("ConfigName") = "Sett_LoadWD_Docs"
newRow3("Value") = "True"
table.Rows.Add(newRow3)
Dim newRow7 As DataRow = table.NewRow()
newRow7("ConfigName") = "WD_IndexDeleteDocs"
newRow7("Value") = "False"
table.Rows.Add(newRow7)
Dim newRow8 As DataRow = table.NewRow()
newRow8("ConfigName") = "WD_ShowDocs"
newRow8("Value") = "False"
table.Rows.Add(newRow8)
Dim newRow9 As DataRow = table.NewRow()
newRow9("ConfigName") = "Sett_ConstructorStart"
newRow9("Value") = "0"
table.Rows.Add(newRow9)
Dim newRow10 As DataRow = table.NewRow()
newRow10("ConfigName") = "FWSCAN_started"
newRow10("Value") = "False"
table.Rows.Add(newRow10)
Dim newRow11 As DataRow = table.NewRow()
newRow11("ConfigName") = "Task_Popup_minutes"
newRow11("Value") = "2"
table.Rows.Add(newRow11)
Dim newRow12 As DataRow = table.NewRow()
newRow12("ConfigName") = "WAN_ENVIRONMENT"
newRow12("Value") = "False"
table.Rows.Add(newRow12)
Dim newRow13 As DataRow = table.NewRow()
newRow13("ConfigName") = "PATH_ADDON"
newRow13("Value") = ""
Dim newRow14 As DataRow = table.NewRow()
newRow14("ConfigName") = "MyProxyConnectionString"
newRow14("Value") = ""
table.Rows.Add(newRow14)
Dim newRow15 As DataRow = table.NewRow()
newRow15("ConfigName") = "MyLinkedServer"
newRow15("Value") = ""
table.Rows.Add(newRow15)
Dim newRow16 As DataRow = table.NewRow()
newRow16("ConfigName") = "MyFormsDesign"
newRow16("Value") = ""
table.AcceptChanges()
clsLogger.Add(">> CreateConfigTable su...", False)
Return table
Catch ex As Exception
MsgBox("Error in CreateConfigTable" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
End Module

View File

@ -0,0 +1,265 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmConfigDatabase
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Wird vom Windows Form-Designer benötigt.
Private components As System.ComponentModel.IContainer
'Hinweis: Die folgende Prozedur ist für den Windows Form-Designer erforderlich.
'Das Bearbeiten ist mit dem Windows Form-Designer möglich.
'Das Bearbeiten mit dem Code-Editor ist nicht möglich.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmConfigDatabase))
Me.lblLinkedServer = New System.Windows.Forms.Label()
Me.txtLinkedServer = New System.Windows.Forms.TextBox()
Me.rbConn_Proxy = New System.Windows.Forms.RadioButton()
Me.rbConnDefault = New System.Windows.Forms.RadioButton()
Me.chkbxUserAut = New System.Windows.Forms.CheckBox()
Me.Label5 = New System.Windows.Forms.Label()
Me.cmbDatenbank = New System.Windows.Forms.ComboBox()
Me.Label4 = New System.Windows.Forms.Label()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.txtActualConnection = New System.Windows.Forms.TextBox()
Me.txtServer = New System.Windows.Forms.TextBox()
Me.txtUser = New System.Windows.Forms.TextBox()
Me.txtPasswort = New System.Windows.Forms.TextBox()
Me.BtnConnect = New System.Windows.Forms.Button()
Me.btndeleteProxy = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'lblLinkedServer
'
Me.lblLinkedServer.AutoSize = True
Me.lblLinkedServer.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.lblLinkedServer.Location = New System.Drawing.Point(9, 180)
Me.lblLinkedServer.Name = "lblLinkedServer"
Me.lblLinkedServer.Size = New System.Drawing.Size(116, 13)
Me.lblLinkedServer.TabIndex = 69
Me.lblLinkedServer.Text = "Name/IP Proxy-Server:"
Me.lblLinkedServer.Visible = False
'
'txtLinkedServer
'
Me.txtLinkedServer.Location = New System.Drawing.Point(12, 196)
Me.txtLinkedServer.Name = "txtLinkedServer"
Me.txtLinkedServer.Size = New System.Drawing.Size(288, 20)
Me.txtLinkedServer.TabIndex = 68
Me.txtLinkedServer.Visible = False
'
'rbConn_Proxy
'
Me.rbConn_Proxy.AutoSize = True
Me.rbConn_Proxy.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.rbConn_Proxy.Location = New System.Drawing.Point(144, 18)
Me.rbConn_Proxy.Name = "rbConn_Proxy"
Me.rbConn_Proxy.Size = New System.Drawing.Size(108, 17)
Me.rbConn_Proxy.TabIndex = 66
Me.rbConn_Proxy.Text = "Proxy Connection"
Me.rbConn_Proxy.UseVisualStyleBackColor = True
'
'rbConnDefault
'
Me.rbConnDefault.AutoSize = True
Me.rbConnDefault.Checked = True
Me.rbConnDefault.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.rbConnDefault.Location = New System.Drawing.Point(12, 18)
Me.rbConnDefault.Name = "rbConnDefault"
Me.rbConnDefault.Size = New System.Drawing.Size(116, 17)
Me.rbConnDefault.TabIndex = 65
Me.rbConnDefault.TabStop = True
Me.rbConnDefault.Text = "Default Connection"
Me.rbConnDefault.UseVisualStyleBackColor = True
'
'chkbxUserAut
'
Me.chkbxUserAut.AutoSize = True
Me.chkbxUserAut.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.chkbxUserAut.Location = New System.Drawing.Point(514, 60)
Me.chkbxUserAut.Name = "chkbxUserAut"
Me.chkbxUserAut.Size = New System.Drawing.Size(151, 17)
Me.chkbxUserAut.TabIndex = 64
Me.chkbxUserAut.Text = "Windows-Authentifizierung"
Me.chkbxUserAut.UseVisualStyleBackColor = True
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label5.Location = New System.Drawing.Point(9, 139)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(135, 13)
Me.Label5.TabIndex = 63
Me.Label5.Text = "Aktueller ConnectionString:"
'
'cmbDatenbank
'
Me.cmbDatenbank.FormattingEnabled = True
Me.cmbDatenbank.Location = New System.Drawing.Point(12, 106)
Me.cmbDatenbank.Name = "cmbDatenbank"
Me.cmbDatenbank.Size = New System.Drawing.Size(288, 21)
Me.cmbDatenbank.TabIndex = 56
'
'Label4
'
Me.Label4.AutoSize = True
Me.Label4.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label4.Location = New System.Drawing.Point(9, 86)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(63, 13)
Me.Label4.TabIndex = 61
Me.Label4.Text = "Datenbank:"
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label1.Location = New System.Drawing.Point(9, 38)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 13)
Me.Label1.TabIndex = 58
Me.Label1.Text = "Server-Name:"
'
'Label2
'
Me.Label2.AutoSize = True
Me.Label2.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label2.Location = New System.Drawing.Point(303, 38)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(78, 13)
Me.Label2.TabIndex = 59
Me.Label2.Text = "Benutzername:"
'
'Label3
'
Me.Label3.AutoSize = True
Me.Label3.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.Label3.Location = New System.Drawing.Point(427, 38)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(53, 13)
Me.Label3.TabIndex = 60
Me.Label3.Text = "Passwort:"
'
'txtActualConnection
'
Me.txtActualConnection.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.txtActualConnection.BackColor = System.Drawing.Color.WhiteSmoke
Me.txtActualConnection.Location = New System.Drawing.Point(12, 155)
Me.txtActualConnection.Name = "txtActualConnection"
Me.txtActualConnection.ReadOnly = True
Me.txtActualConnection.Size = New System.Drawing.Size(457, 20)
Me.txtActualConnection.TabIndex = 62
'
'txtServer
'
Me.txtServer.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtServer.Location = New System.Drawing.Point(12, 58)
Me.txtServer.Name = "txtServer"
Me.txtServer.Size = New System.Drawing.Size(288, 20)
Me.txtServer.TabIndex = 53
'
'txtUser
'
Me.txtUser.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtUser.Location = New System.Drawing.Point(306, 58)
Me.txtUser.Name = "txtUser"
Me.txtUser.Size = New System.Drawing.Size(118, 20)
Me.txtUser.TabIndex = 54
'
'txtPasswort
'
Me.txtPasswort.ForeColor = System.Drawing.SystemColors.WindowText
Me.txtPasswort.Location = New System.Drawing.Point(430, 58)
Me.txtPasswort.Name = "txtPasswort"
Me.txtPasswort.Size = New System.Drawing.Size(64, 20)
Me.txtPasswort.TabIndex = 55
Me.txtPasswort.UseSystemPasswordChar = True
'
'BtnConnect
'
Me.BtnConnect.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.BtnConnect.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.BtnConnect.Location = New System.Drawing.Point(306, 102)
Me.BtnConnect.Name = "BtnConnect"
Me.BtnConnect.Size = New System.Drawing.Size(253, 25)
Me.BtnConnect.TabIndex = 57
Me.BtnConnect.Text = "Verbindung zur Datenbank herstellen"
Me.BtnConnect.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.BtnConnect.UseVisualStyleBackColor = True
'
'btndeleteProxy
'
Me.btndeleteProxy.Image = CType(resources.GetObject("btndeleteProxy.Image"), System.Drawing.Image)
Me.btndeleteProxy.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft
Me.btndeleteProxy.ImeMode = System.Windows.Forms.ImeMode.NoControl
Me.btndeleteProxy.Location = New System.Drawing.Point(562, 153)
Me.btndeleteProxy.Name = "btndeleteProxy"
Me.btndeleteProxy.Size = New System.Drawing.Size(97, 23)
Me.btndeleteProxy.TabIndex = 67
Me.btndeleteProxy.Text = "Lösche Proxy"
Me.btndeleteProxy.TextAlign = System.Drawing.ContentAlignment.MiddleRight
Me.btndeleteProxy.UseVisualStyleBackColor = True
Me.btndeleteProxy.Visible = False
'
'frmConfigDatabase
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(710, 235)
Me.Controls.Add(Me.lblLinkedServer)
Me.Controls.Add(Me.txtLinkedServer)
Me.Controls.Add(Me.btndeleteProxy)
Me.Controls.Add(Me.rbConn_Proxy)
Me.Controls.Add(Me.rbConnDefault)
Me.Controls.Add(Me.chkbxUserAut)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.cmbDatenbank)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.txtActualConnection)
Me.Controls.Add(Me.txtServer)
Me.Controls.Add(Me.txtUser)
Me.Controls.Add(Me.txtPasswort)
Me.Controls.Add(Me.BtnConnect)
Me.Name = "frmConfigDatabase"
Me.Text = "ConfigDatabase"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents lblLinkedServer As Label
Friend WithEvents txtLinkedServer As TextBox
Friend WithEvents btndeleteProxy As Button
Friend WithEvents rbConn_Proxy As RadioButton
Friend WithEvents rbConnDefault As RadioButton
Friend WithEvents chkbxUserAut As CheckBox
Friend WithEvents Label5 As Label
Friend WithEvents cmbDatenbank As ComboBox
Friend WithEvents Label4 As Label
Friend WithEvents Label1 As Label
Friend WithEvents Label2 As Label
Friend WithEvents Label3 As Label
Friend WithEvents txtActualConnection As TextBox
Friend WithEvents txtServer As TextBox
Friend WithEvents txtUser As TextBox
Friend WithEvents txtPasswort As TextBox
Friend WithEvents BtnConnect As Button
End Class

View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btndeleteProxy.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGOfPtRkwAAACBjSFJNAAB6
JQAAgIMAAPn/AACA6QAAdTAAAOpgAAA6mAAAF2+SX8VGAAAACXBIWXMAAAsTAAALEwEAmpwYAAACLUlE
QVQ4T52TvY/ScBjHuVIRKHA9JAgnL+VoC7TX0kLLS6EvFBTa0uj5J7gYF+PsfpOTMrg4ORgHY+LCYJwc
TYyJiYuDLu7GxHgxd/Hnr5fA8TZcrsmnzfN9nufTNPnVBwDw2ZYljGzr3ciyTNu2EC87L75eb+DvD67f
hU9g9vt/HNs5cMaOf9Owohro7YNbe8PhjfuzzBOgkDuabk6bbRXoxuBkNLIeus6yhKyIwY5umo5tHxmG
+Wwu8G5QkIa0jN5gqnR1oOkGuOk6b1x3jHl9uaWGhpb1UtXNY1luPmJ4KbIkmAElAcgD3egfa5oJxq77
oq3ovKJoE7XbBbwoTWhG2F7cWRJ4dFR1S9fNCvykT41mB9TqjSOxXvtJM9zrYokLrc4vFYtUBcngq9Lf
tqICvlr7RhQr8U1za4FHXZIIurT/mePFf1AEJLkFGJb7uml2LRBrcp4us1+g4KRcYV8lkmkplyenglgH
VIm9tzq/VJRZLpUlih9yBQrAt79Pp3bjkVgM244nsPwe/VQQ6r8pRsgu7pwtC61grkA/T10r/NrnxB8s
V2VmvQiOB0MhLMZVxY/pDPEkU6DnZ2Qu2M0STjJFAIpmAUmXD0NY9PQMzEBRPwJzkiSp71F8J1/ipNMj
f9rE8XggkUgexq9cBXmi+DYYjtCRGL72T+D4jr/RaE+waFgu8c0zgUcmT9UuBS4/9m0hmh9Fo7N8FXih
CIKE5/Vi8yJsDM8P8P0HLGwR4Wl3ICYAAAAASUVORK5CYII=
</value>
</data>
</root>

View File

@ -0,0 +1,133 @@
Imports System.IO
Imports DD_LIB_Standards
Public Class frmConfigDatabase
Private ConnectionChanged As Boolean = False
Private Sub frmConfigDatabase_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Not MyConnectionString = String.Empty Then
ConnectionChanged = False
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.ConnectionString = MyConnectionString
Dim constr = MyConnectionString
If Not MyConnectionString.Contains("Trusted") Then
constr = constr.Replace(csb.Password, "XXXXX")
txtUser.Text = csb.UserID
chkbxUserAut.Checked = False
Else
chkbxUserAut.Checked = True
End If
Try
txtServer.Text = csb.DataSource
cmbDatenbank.Text = csb.InitialCatalog
Catch ex As Exception
End Try
txtActualConnection.Text = constr
End If
End Sub
Sub Load_Databases()
Try
Me.Cursor = Cursors.WaitCursor
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.DataSource = Me.txtServer.Text
csb.IntegratedSecurity = False
csb.UserID = Me.txtUser.Text
csb.Password = Me.txtPasswort.Text
Dim con As String
If chkbxUserAut.Checked Then
con = "Data Source=" & Me.txtServer.Text & ";Trusted_Connection=True;"
Else
'con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";"
con = "Server=" & Me.txtServer.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";"
End If
Dim connection As New SqlClient.SqlConnection(con) 'csb.ConnectionString)
connection.Open()
Dim cmd As New SqlClient.SqlCommand("sp_databases", connection)
cmd.CommandType = CommandType.StoredProcedure
' Ausführen und Ergebnis in einer ListBox anzeigen
Dim dr As SqlClient.SqlDataReader = cmd.ExecuteReader
If dr.HasRows Then
cmbDatenbank.Items.Clear()
Do While dr.Read
cmbDatenbank.Items.Add(dr("Database_Name"))
Loop
cmbDatenbank.DroppedDown = True
Else
MsgBox("The standard-databases could not be retrieved. The default database will be set!" & vbNewLine & "Check rights in sql-server for user: " & Me.txtUser.Text, MsgBoxStyle.Exclamation)
End If
connection.Close()
Catch ex As Exception
If ex.Message.ToLower.Contains("he standard-databases") Or ex.Message.ToLower.Contains("ie standard-datenbanken") Then
cmbDatenbank.Text = "DD_ECM"
End If
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in Load Databases:")
End Try
Cursor = Cursors.Default
End Sub
Private Sub BtnConnect_Click(sender As Object, e As EventArgs) Handles BtnConnect.Click
Try
Dim con As String
If chkbxUserAut.Checked Then
con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";Trusted_Connection=True;Application Name=DD UserManager"
Else
con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & Me.txtPasswort.Text & ";Application Name=DD ADDI-Client"
End If
Dim connection As New SqlClient.SqlConnection(con) 'csb.ConnectionString)
'während Verbindungsaufbau Sanduhr-Mauszeiger
Cursor = Cursors.WaitCursor
connection.Open()
Cursor = Cursors.Default
'DialogResult = Windows.Forms.DialogResult.OK
Dim result As MsgBoxResult
Dim msg = "Die Verbindung wurde erfolgreich aufgebaut!" & vbNewLine & "Möchten Sie diese Verbindung nun in der Anwendung speichern?"
result = MessageBox.Show(msg, "Database-Connection", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.Yes Then
ConnectionChanged = True
'Set the construction string
If rbConnDefault.Checked Then
MyConnectionString = con
'csb.ConnectionString
clsDatabase.Init(MyConnectionString)
End If
My.Settings.Save()
If chkbxUserAut.Checked = False Then
Dim wrapper As New clsEncryption("!35452didalog=")
Dim cipherText As String = wrapper.EncryptData(Me.txtPasswort.Text)
Dim pw As String = cipherText
con = "Server=" & Me.txtServer.Text & ";Database=" & Me.cmbDatenbank.Text & ";User Id=" & Me.txtUser.Text & ";Password=" & pw & ";"
End If
If rbConnDefault.Checked Then
SaveMySettingsValue("MyConnectionString", con, "ConfigMain")
Else
SaveMySettingsValue("MyProxyConnectionString", con, "ConfigMain")
End If
Dim csb As New SqlClient.SqlConnectionStringBuilder
csb.ConnectionString = MyConnectionString
Dim constr = connection.ConnectionString
If chkbxUserAut.Checked = False Then
constr = constr.Replace(csb.Password, "XXXXX")
End If
Me.txtActualConnection.Text = constr
End If
Catch ex As Exception
Cursor = Cursors.Default
MsgBox("Error in Connectionbuild: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation)
End Try
End Sub
Private Sub cmbDatenbank_MouseClick(sender As Object, e As MouseEventArgs) Handles cmbDatenbank.MouseClick
Load_Databases()
End Sub
End Class

View File

@ -1,6 +1,7 @@
Imports DevExpress.XtraGrid Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid.Views.Grid
Imports DDUserManager.UserDataSet Imports DDUserManager.UserDataSet
Imports DD_LIB_Standards
''' <summary> ''' <summary>
''' Anmerkungen: ''' Anmerkungen:
@ -12,6 +13,17 @@ Public Class frmMain
Private DragDropManager As ClassDragDrop = Nothing Private DragDropManager As ClassDragDrop = Nothing
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
InitDatabase()
TBDD_CLIENTTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_CLIENT_USERTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_GROUPSTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_GROUPS_CLIENTTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_GROUPS_MODULESTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_GROUPS_USERTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_MODULESTableAdapter.Connection.ConnectionString = MyConnectionString
TBDD_USERTableAdapter.Connection.ConnectionString = MyConnectionString
If TBDD_USERTableAdapter.IsUserManagerAdmin(Environment.UserName) = 1 Then If TBDD_USERTableAdapter.IsUserManagerAdmin(Environment.UserName) = 1 Then
Dim userRow As TBDD_USERRow = GetCurrentUserRow(Environment.UserName) Dim userRow As TBDD_USERRow = GetCurrentUserRow(Environment.UserName)
tsLabelUser.Text = $"Angemeldeter Benutzer: {userRow.USERNAME}" tsLabelUser.Text = $"Angemeldeter Benutzer: {userRow.USERNAME}"
@ -45,6 +57,36 @@ Public Class frmMain
End If End If
End Sub End Sub
Public Function InitDatabase()
Try
Dim dbResult As Boolean
MySettings_Load()
clsDatabase.GUI = True
If MyConnectionString <> String.Empty Then
dbResult = clsDatabase.Init(MyConnectionString)
Else
frmConfigDatabase.ShowDialog()
dbResult = clsDatabase.Init(MyConnectionString)
End If
clsDatabase.Init(MyConnectionString)
If dbResult = False Then
If clsLogger.LOGG_MSG <> String.Empty Then
Throw New Exception("Error while Initializing database:" & vbNewLine & clsLogger.LOGG_MSG)
Else
Throw New Exception("Find more information in the logfile.")
End If
End If
Return True
Catch ex As Exception
MsgBox("Unexpected Error in Init Database:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
Return False
End Try
End Function
Private Sub btnImportUsers_Click(sender As Object, e As EventArgs) Handles btnImportUsers.Click Private Sub btnImportUsers_Click(sender As Object, e As EventArgs) Handles btnImportUsers.Click
Dim frm As New frmADImport_Users() Dim frm As New frmADImport_Users()
frm.ShowDialog() frm.ShowDialog()