load textbox if combobox is readonly
This commit is contained in:
parent
a2268dc7fa
commit
e2ea5583ae
@ -622,146 +622,152 @@ Public Class frmValidator
|
||||
oMyControl = ClassControlCreator.CreateExistingLabel(oControlRow, False)
|
||||
Case "CMB"
|
||||
LOGGER.Debug("Versuch CMB zu laden")
|
||||
If oControlRow.Item("READ_ONLY") Then
|
||||
Dim cmbReadonly = ClassControlCreator.CreateExistingTextbox(oControlRow, False)
|
||||
oMyControl = cmbReadonly
|
||||
Else
|
||||
Dim cmb = ClassControlCreator.CreateExistingCombobox(oControlRow, False)
|
||||
|
||||
Dim cmb = ClassControlCreator.CreateExistingCombobox(oControlRow, False)
|
||||
|
||||
AddHandler cmb.SelectedValueChanged, AddressOf OnCmbselectedIndex
|
||||
AddHandler cmb.GotFocus, Sub(sender As Control, e As EventArgs)
|
||||
If DirectCast(cmb.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
|
||||
cmb.BackColor = Color.Lime
|
||||
End If
|
||||
End Sub
|
||||
AddHandler cmb.LostFocus, Sub(sender As Control, e As EventArgs)
|
||||
If DirectCast(cmb.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
|
||||
cmb.BackColor = Color.White
|
||||
End If
|
||||
End Sub
|
||||
AddHandler cmb.SelectedValueChanged, AddressOf OnCmbselectedIndex
|
||||
AddHandler cmb.GotFocus, Sub(sender As Control, e As EventArgs)
|
||||
If DirectCast(cmb.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
|
||||
cmb.BackColor = Color.Lime
|
||||
End If
|
||||
End Sub
|
||||
AddHandler cmb.LostFocus, Sub(sender As Control, e As EventArgs)
|
||||
If DirectCast(cmb.Tag, ClassControlCreator.ControlMetadata).ReadOnly = False Then
|
||||
cmb.BackColor = Color.White
|
||||
End If
|
||||
End Sub
|
||||
#Region "CONTROL LIST"
|
||||
|
||||
Dim ControlID = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetGUID(CURRENT_ProfilGUID, cmb.Name)
|
||||
LOGGER.Debug("In add_ComboBox - GUID: " & ControlID)
|
||||
If ControlID > 0 Then
|
||||
LOGGER.Debug(" >>ControlID > 0")
|
||||
Dim ConID = Me.TBPM_PROFILE_CONTROLSTableAdapter.cmdgetConnectionID(ControlID)
|
||||
If ConID Is Nothing = False Then
|
||||
Dim commandsql = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetSQL(ControlID)
|
||||
LOGGER.Debug("ConID Is Nothing = False")
|
||||
If ConID > 0 And commandsql <> "" Then
|
||||
LOGGER.Debug("CConID > 0 And TBPM_PROFILE_CONTROLSTableAdapter.cmdGetSQL(ControlID)")
|
||||
Dim connectionString As String
|
||||
TBDD_CONNECTIONTableAdapter.FillByID(DD_DMSLiteDataSet.TBDD_CONNECTION, ConID)
|
||||
Dim DTConnection As DataTable = DD_DMSLiteDataSet.TBDD_CONNECTION
|
||||
Dim drConnection As DataRow
|
||||
For Each drConnection In DTConnection.Rows
|
||||
Select Case drConnection.Item("SQL_PROVIDER").ToString.ToLower
|
||||
Case "ms-sql"
|
||||
If drConnection.Item("USERNAME") = "WINAUTH" Then
|
||||
connectionString = "Data Source=" & drConnection.Item("SERVER") & ";Initial Catalog=" & drConnection.Item("DATENBANK") & ";Trusted_Connection=True;"
|
||||
Else
|
||||
connectionString = "Data Source=" & drConnection.Item("SERVER") & ";Initial Catalog= " & drConnection.Item("DATENBANK") & ";User Id=" & drConnection.Item("USERNAME") & ";Password=" & drConnection.Item("PASSWORD") & ";"
|
||||
End If
|
||||
LOGGER.Debug("ConnString Sql-Server: " & connectionString)
|
||||
Case "oracle"
|
||||
Dim conn As New OracleConnectionStringBuilder
|
||||
Dim connstr As String
|
||||
If drConnection.Item("SERVER") <> "" And drConnection.Item("DATENBANK").GetType.ToString <> "system.dbnull" Then
|
||||
connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & drConnection.Item("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
|
||||
drConnection.Item("DATENBANK") & ")));User Id=" & drConnection.Item("USERNAME") & ";Password=" & drConnection.Item("PASSWORD") & ";"
|
||||
Else
|
||||
conn.DataSource = drConnection.Item("SERVER")
|
||||
conn.UserID = drConnection.Item("USERNAME")
|
||||
conn.Password = drConnection.Item("PASSWORD")
|
||||
conn.PersistSecurityInfo = True
|
||||
conn.ConnectionTimeout = 120
|
||||
connstr = conn.ConnectionString
|
||||
End If
|
||||
Dim ControlID = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetGUID(CURRENT_ProfilGUID, cmb.Name)
|
||||
LOGGER.Debug("In add_ComboBox - GUID: " & ControlID)
|
||||
If ControlID > 0 Then
|
||||
LOGGER.Debug(" >>ControlID > 0")
|
||||
Dim ConID = Me.TBPM_PROFILE_CONTROLSTableAdapter.cmdgetConnectionID(ControlID)
|
||||
If ConID Is Nothing = False Then
|
||||
Dim commandsql = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetSQL(ControlID)
|
||||
LOGGER.Debug("ConID Is Nothing = False")
|
||||
If ConID > 0 And commandsql <> "" Then
|
||||
LOGGER.Debug("CConID > 0 And TBPM_PROFILE_CONTROLSTableAdapter.cmdGetSQL(ControlID)")
|
||||
Dim connectionString As String
|
||||
TBDD_CONNECTIONTableAdapter.FillByID(DD_DMSLiteDataSet.TBDD_CONNECTION, ConID)
|
||||
Dim DTConnection As DataTable = DD_DMSLiteDataSet.TBDD_CONNECTION
|
||||
Dim drConnection As DataRow
|
||||
For Each drConnection In DTConnection.Rows
|
||||
Select Case drConnection.Item("SQL_PROVIDER").ToString.ToLower
|
||||
Case "ms-sql"
|
||||
If drConnection.Item("USERNAME") = "WINAUTH" Then
|
||||
connectionString = "Data Source=" & drConnection.Item("SERVER") & ";Initial Catalog=" & drConnection.Item("DATENBANK") & ";Trusted_Connection=True;"
|
||||
Else
|
||||
connectionString = "Data Source=" & drConnection.Item("SERVER") & ";Initial Catalog= " & drConnection.Item("DATENBANK") & ";User Id=" & drConnection.Item("USERNAME") & ";Password=" & drConnection.Item("PASSWORD") & ";"
|
||||
End If
|
||||
LOGGER.Debug("ConnString Sql-Server: " & connectionString)
|
||||
Case "oracle"
|
||||
Dim conn As New OracleConnectionStringBuilder
|
||||
Dim connstr As String
|
||||
If drConnection.Item("SERVER") <> "" And drConnection.Item("DATENBANK").GetType.ToString <> "system.dbnull" Then
|
||||
connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & drConnection.Item("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
|
||||
drConnection.Item("DATENBANK") & ")));User Id=" & drConnection.Item("USERNAME") & ";Password=" & drConnection.Item("PASSWORD") & ";"
|
||||
Else
|
||||
conn.DataSource = drConnection.Item("SERVER")
|
||||
conn.UserID = drConnection.Item("USERNAME")
|
||||
conn.Password = drConnection.Item("PASSWORD")
|
||||
conn.PersistSecurityInfo = True
|
||||
conn.ConnectionTimeout = 120
|
||||
connstr = conn.ConnectionString
|
||||
End If
|
||||
|
||||
connectionString = connstr
|
||||
Case Else
|
||||
LOGGER.Info(" - ConnectionType nicht integriert")
|
||||
MsgBox("ConnectionType nicht integriert", MsgBoxStyle.Critical, "Bitte Konfiguration Connection überprüfen!")
|
||||
End Select
|
||||
Next
|
||||
If connectionString Is Nothing = False Then
|
||||
Try
|
||||
Dim sqlCnn As SqlClient.SqlConnection
|
||||
Dim sqlCmd As SqlClient.SqlCommand
|
||||
Dim adapter As New SqlClient.SqlDataAdapter
|
||||
Dim NewDataset As New DataSet
|
||||
Dim i As Integer
|
||||
Dim sql As String
|
||||
|
||||
|
||||
sql = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetSQL(ControlID)
|
||||
|
||||
'sql = ClassPatterns.ReplaceAllValues(sql, pnldesigner, CURRENT_WMFILE)
|
||||
|
||||
'If ClassPatterns.HasOnlySimplePatterns(sql) Then
|
||||
If clsPatterns.HasOnlySimplePatterns(sql) Then
|
||||
sql = clsPatterns.ReplaceInternalValues(sql)
|
||||
sql = clsPatterns.ReplaceControlValues(sql, pnldesigner)
|
||||
LOGGER.Debug(">>> sql after HasOnlySimplePatterns: " & sql)
|
||||
sqlCnn = New SqlClient.SqlConnection(connectionString)
|
||||
' Try
|
||||
sqlCnn.Open()
|
||||
sqlCmd = New SqlClient.SqlCommand(sql, sqlCnn)
|
||||
adapter.SelectCommand = sqlCmd
|
||||
adapter.Fill(NewDataset)
|
||||
Dim msg As String
|
||||
For i = 0 To NewDataset.Tables(0).Rows.Count - 1
|
||||
cmb.Items.Add(NewDataset.Tables(0).Rows(i).Item(0))
|
||||
Next
|
||||
adapter.Dispose()
|
||||
sqlCmd.Dispose()
|
||||
sqlCnn.Close()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
LOGGER.Info(" - Unvorhergesehener Fehler bei GetValues SQL - Fehler: " & vbNewLine & ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei GetValues SQL:")
|
||||
End Try
|
||||
End If
|
||||
Else
|
||||
LOGGER.Debug("Else Row 571")
|
||||
End If
|
||||
Else
|
||||
LOGGER.Debug("AListe Handling")
|
||||
Dim AListe As String = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetChoiceListName(ControlID)
|
||||
LOGGER.Debug("In add_ComboBox - AListe: " & AListe)
|
||||
If AListe Is Nothing = False Then
|
||||
'Dim liste = _windreamPM.GetValuesfromAuswahlliste(AListe)
|
||||
Dim liste = WINDREAM.GetValuesfromAuswahlliste(AListe)
|
||||
If liste IsNot Nothing Then
|
||||
cmb.Items.Add("")
|
||||
For Each index As String In liste
|
||||
cmb.Items.Add(index)
|
||||
connectionString = connstr
|
||||
Case Else
|
||||
LOGGER.Info(" - ConnectionType nicht integriert")
|
||||
MsgBox("ConnectionType nicht integriert", MsgBoxStyle.Critical, "Bitte Konfiguration Connection überprüfen!")
|
||||
End Select
|
||||
Next
|
||||
cmb.SelectedIndex = -1
|
||||
If connectionString Is Nothing = False Then
|
||||
Try
|
||||
Dim sqlCnn As SqlClient.SqlConnection
|
||||
Dim sqlCmd As SqlClient.SqlCommand
|
||||
Dim adapter As New SqlClient.SqlDataAdapter
|
||||
Dim NewDataset As New DataSet
|
||||
Dim i As Integer
|
||||
Dim sql As String
|
||||
|
||||
|
||||
sql = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetSQL(ControlID)
|
||||
|
||||
'sql = ClassPatterns.ReplaceAllValues(sql, pnldesigner, CURRENT_WMFILE)
|
||||
|
||||
'If ClassPatterns.HasOnlySimplePatterns(sql) Then
|
||||
If clsPatterns.HasOnlySimplePatterns(sql) Then
|
||||
sql = clsPatterns.ReplaceInternalValues(sql)
|
||||
sql = clsPatterns.ReplaceControlValues(sql, pnldesigner)
|
||||
LOGGER.Debug(">>> sql after HasOnlySimplePatterns: " & sql)
|
||||
sqlCnn = New SqlClient.SqlConnection(connectionString)
|
||||
' Try
|
||||
sqlCnn.Open()
|
||||
sqlCmd = New SqlClient.SqlCommand(sql, sqlCnn)
|
||||
adapter.SelectCommand = sqlCmd
|
||||
adapter.Fill(NewDataset)
|
||||
Dim msg As String
|
||||
For i = 0 To NewDataset.Tables(0).Rows.Count - 1
|
||||
cmb.Items.Add(NewDataset.Tables(0).Rows(i).Item(0))
|
||||
Next
|
||||
adapter.Dispose()
|
||||
sqlCmd.Dispose()
|
||||
sqlCnn.Close()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
LOGGER.Info(" - Unvorhergesehener Fehler bei GetValues SQL - Fehler: " & vbNewLine & ex.Message)
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler bei GetValues SQL:")
|
||||
End Try
|
||||
End If
|
||||
Else
|
||||
MsgBox("Resultliste windream is nothing!", MsgBoxStyle.Exclamation, AListe)
|
||||
LOGGER.Debug("Else Row 571")
|
||||
End If
|
||||
Else
|
||||
MsgBox("AListe from database is nothing!", MsgBoxStyle.Exclamation, AListe)
|
||||
LOGGER.Debug("AListe Handling")
|
||||
Dim AListe As String = TBPM_PROFILE_CONTROLSTableAdapter.cmdGetChoiceListName(ControlID)
|
||||
LOGGER.Debug("In add_ComboBox - AListe: " & AListe)
|
||||
If AListe Is Nothing = False Then
|
||||
'Dim liste = _windreamPM.GetValuesfromAuswahlliste(AListe)
|
||||
Dim liste = WINDREAM.GetValuesfromAuswahlliste(AListe)
|
||||
If liste IsNot Nothing Then
|
||||
cmb.Items.Add("")
|
||||
For Each index As String In liste
|
||||
cmb.Items.Add(index)
|
||||
Next
|
||||
cmb.SelectedIndex = -1
|
||||
Else
|
||||
MsgBox("Resultliste windream is nothing!", MsgBoxStyle.Exclamation, AListe)
|
||||
End If
|
||||
Else
|
||||
MsgBox("AListe from database is nothing!", MsgBoxStyle.Exclamation, AListe)
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
|
||||
|
||||
End If
|
||||
#End Region
|
||||
|
||||
Dim maxWith As Integer = cmb.Width
|
||||
Using g As Graphics = Me.CreateGraphics
|
||||
For Each oItem As Object In cmb.Items 'Für alle Einträge...
|
||||
Dim g1 As Graphics = cmb.CreateGraphics
|
||||
If g1.MeasureString(Text, cmb.Font).Width + 30 > maxWith Then
|
||||
maxWith = g1.MeasureString(Text, cmb.Font).Width + 30
|
||||
End If
|
||||
g1.Dispose()
|
||||
Next oItem
|
||||
End Using
|
||||
cmb.DropDownWidth = maxWith
|
||||
Dim maxWith As Integer = cmb.Width
|
||||
Using g As Graphics = Me.CreateGraphics
|
||||
For Each oItem As Object In cmb.Items 'Für alle Einträge...
|
||||
Dim g1 As Graphics = cmb.CreateGraphics
|
||||
If g1.MeasureString(Text, cmb.Font).Width + 30 > maxWith Then
|
||||
maxWith = g1.MeasureString(Text, cmb.Font).Width + 30
|
||||
End If
|
||||
g1.Dispose()
|
||||
Next oItem
|
||||
End Using
|
||||
cmb.DropDownWidth = maxWith
|
||||
|
||||
oMyControl = cmb
|
||||
End If
|
||||
|
||||
|
||||
oMyControl = cmb
|
||||
|
||||
Case "DTP"
|
||||
LOGGER.Debug("Versuch DTP zu laden")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user