load textbox if combobox is readonly in mass validator
This commit is contained in:
parent
ec8e6b76b9
commit
7a166c1f3a
@ -135,7 +135,7 @@ Public Class frmMassValidator
|
|||||||
Dim oCount = 0
|
Dim oCount = 0
|
||||||
|
|
||||||
For Each oControlRow As DataRow In DTCONTROLS.Rows
|
For Each oControlRow As DataRow In DTCONTROLS.Rows
|
||||||
Dim ctrl As Control
|
Dim oControl As Control
|
||||||
|
|
||||||
Select Case oControlRow.Item("CTRL_TYPE").ToString.ToUpper
|
Select Case oControlRow.Item("CTRL_TYPE").ToString.ToUpper
|
||||||
Case "TXT"
|
Case "TXT"
|
||||||
@ -146,161 +146,170 @@ Public Class frmMassValidator
|
|||||||
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus
|
AddHandler txt.LostFocus, AddressOf OnTextBoxLostFocus
|
||||||
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp
|
AddHandler txt.KeyUp, AddressOf OnTextBoxKeyUp
|
||||||
|
|
||||||
ctrl = txt
|
oControl = txt
|
||||||
Case "LBL"
|
Case "LBL"
|
||||||
LOGGER.Debug("Versuch LBL zu laden")
|
LOGGER.Debug("Versuch LBL zu laden")
|
||||||
ctrl = ClassControlCreator.CreateExistingLabel(oControlRow, False)
|
oControl = ClassControlCreator.CreateExistingLabel(oControlRow, False)
|
||||||
Case "CMB"
|
Case "CMB"
|
||||||
LOGGER.Debug("Versuch CMB zu laden")
|
LOGGER.Debug("Versuch CMB zu laden")
|
||||||
|
|
||||||
Dim cmb = ClassControlCreator.CreateExistingCombobox(oControlRow, False)
|
If oControlRow.Item("READ_ONLY") Then
|
||||||
|
Dim cmbReadonly = ClassControlCreator.CreateExistingTextbox(oControlRow, False)
|
||||||
|
oControl = cmbReadonly
|
||||||
|
Else
|
||||||
|
Dim cmb = ClassControlCreator.CreateExistingCombobox(oControlRow, False)
|
||||||
|
|
||||||
AddHandler cmb.SelectedValueChanged, AddressOf OnCmbselectedIndex
|
AddHandler cmb.SelectedValueChanged, AddressOf OnCmbselectedIndex
|
||||||
#Region "CONTROL LIST"
|
#Region "CONTROL LIST"
|
||||||
If ClassControlCreator.GET_CONTROL_PROPERTIES(DTCONTROLS, cmb.Name) = 0 Then
|
If ClassControlCreator.GET_CONTROL_PROPERTIES(DTCONTROLS, cmb.Name) = 0 Then
|
||||||
MsgBox("Unexpected Error in getting control-properties (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
|
MsgBox("Unexpected Error in getting control-properties (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
Dim CURR_SQL_PROVIDER As String
|
Dim CURR_SQL_PROVIDER As String
|
||||||
If CURRENT_CONTROL_ID > 0 Then
|
If CURRENT_CONTROL_ID > 0 Then
|
||||||
If CURR_CON_ID > 0 Then
|
If CURR_CON_ID > 0 Then
|
||||||
Dim commandsql = CURR_SELECT_CONTROL
|
Dim commandsql = CURR_SELECT_CONTROL
|
||||||
If commandsql <> "" Then
|
If commandsql <> "" Then
|
||||||
LOGGER.Debug("ConID > 0 And commandsql <> ''")
|
LOGGER.Debug("ConID > 0 And commandsql <> ''")
|
||||||
Dim connectionString As String
|
Dim connectionString As String
|
||||||
|
|
||||||
Dim ConRow As DataRow() = ClassControlCreator.GET_CONNECTION_INFO(CURR_CON_ID)
|
Dim ConRow As DataRow() = ClassControlCreator.GET_CONNECTION_INFO(CURR_CON_ID)
|
||||||
If ConRow Is Nothing Then
|
If ConRow Is Nothing Then
|
||||||
MsgBox("Unexpected Error in getting Coninfo (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
|
MsgBox("Unexpected Error in getting Coninfo (CMB load) - Check the log and inform Your sysadmin!", MsgBoxStyle.Critical)
|
||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
For Each row As DataRow In ConRow
|
For Each row As DataRow In ConRow
|
||||||
Select Case row("SQL_PROVIDER").ToString.ToLower
|
Select Case row("SQL_PROVIDER").ToString.ToLower
|
||||||
Case "ms-sql"
|
Case "ms-sql"
|
||||||
CURR_SQL_PROVIDER = "ms-sql"
|
CURR_SQL_PROVIDER = "ms-sql"
|
||||||
If row("USERNAME") = "WINAUTH" Then
|
If row("USERNAME") = "WINAUTH" Then
|
||||||
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog=" & row("DATENBANK") & ";Trusted_Connection=True;"
|
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog=" & row("DATENBANK") & ";Trusted_Connection=True;"
|
||||||
Else
|
Else
|
||||||
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog= " & row("DATENBANK") & ";User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
|
connectionString = "Data Source=" & row("SERVER") & ";Initial Catalog= " & row("DATENBANK") & ";User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
|
||||||
|
End If
|
||||||
|
LOGGER.Debug("ConnString Sql-Server: " & connectionString)
|
||||||
|
Case "oracle"
|
||||||
|
CURR_SQL_PROVIDER = "oracle"
|
||||||
|
Dim conn As New OracleConnectionStringBuilder
|
||||||
|
Dim connstr As String
|
||||||
|
If row("SERVER") <> "" And row("DATENBANK").GetType.ToString <> "system.dbnull" Then
|
||||||
|
connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & row("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
|
||||||
|
row("DATENBANK") & ")));User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
|
||||||
|
Else
|
||||||
|
conn.DataSource = row("SERVER")
|
||||||
|
conn.UserID = row("USERNAME")
|
||||||
|
conn.Password = row("PASSWORD")
|
||||||
|
conn.PersistSecurityInfo = True
|
||||||
|
conn.ConnectionTimeout = 120
|
||||||
|
connstr = conn.ConnectionString
|
||||||
|
End If
|
||||||
|
|
||||||
|
connectionString = connstr
|
||||||
|
Case Else
|
||||||
|
LOGGER.Info("ConnectionString-Type not integrated")
|
||||||
|
MsgBox("ConnectionString-Type not integrated", MsgBoxStyle.Critical)
|
||||||
|
Exit Sub
|
||||||
|
End Select
|
||||||
|
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
If connectionString Is Nothing = False And CURR_SQL_PROVIDER = "ms-sql" 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
|
||||||
|
|
||||||
|
|
||||||
|
'sql = ClassPatterns.ReplaceAllValues(sql, pnldesigner, aktivesDokument)
|
||||||
|
If clsPatterns.HasOnlySimplePatterns(CURR_SELECT_CONTROL) Then
|
||||||
|
CURR_SELECT_CONTROL = clsPatterns.ReplaceInternalValues(CURR_SELECT_CONTROL)
|
||||||
|
CURR_SELECT_CONTROL = clsPatterns.ReplaceControlValues(CURR_SELECT_CONTROL, pnldesigner)
|
||||||
|
|
||||||
|
sqlCnn = New SqlClient.SqlConnection(connectionString)
|
||||||
|
' Try
|
||||||
|
sqlCnn.Open()
|
||||||
|
sqlCmd = New SqlClient.SqlCommand(CURR_SELECT_CONTROL, sqlCnn)
|
||||||
|
adapter.SelectCommand = sqlCmd
|
||||||
|
adapter.Fill(NewDataset)
|
||||||
|
|
||||||
|
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
|
End If
|
||||||
LOGGER.Debug("ConnString Sql-Server: " & connectionString)
|
Catch ex As Exception
|
||||||
Case "oracle"
|
LOGGER.Error(ex)
|
||||||
CURR_SQL_PROVIDER = "oracle"
|
LOGGER.Info("Unexpected Error in running depending sql-command: " & ex.Message)
|
||||||
Dim conn As New OracleConnectionStringBuilder
|
Clipboard.SetText("Error: " & ex.Message & vbNewLine & "SQL: " & CURR_SELECT_CONTROL)
|
||||||
Dim connstr As String
|
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error in running depending sql-command:")
|
||||||
If row("SERVER") <> "" And row("DATENBANK").GetType.ToString <> "system.dbnull" Then
|
End Try
|
||||||
connstr = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=" & row("SERVER") & ")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=" &
|
End If
|
||||||
row("DATENBANK") & ")));User Id=" & row("USERNAME") & ";Password=" & row("PASSWORD") & ";"
|
Else
|
||||||
Else
|
LOGGER.Debug("Else Row 571")
|
||||||
conn.DataSource = row("SERVER")
|
|
||||||
conn.UserID = row("USERNAME")
|
|
||||||
conn.Password = row("PASSWORD")
|
|
||||||
conn.PersistSecurityInfo = True
|
|
||||||
conn.ConnectionTimeout = 120
|
|
||||||
connstr = conn.ConnectionString
|
|
||||||
End If
|
|
||||||
|
|
||||||
connectionString = connstr
|
|
||||||
Case Else
|
|
||||||
LOGGER.Info("ConnectionString-Type not integrated")
|
|
||||||
MsgBox("ConnectionString-Type not integrated", MsgBoxStyle.Critical)
|
|
||||||
Exit Sub
|
|
||||||
End Select
|
|
||||||
|
|
||||||
|
|
||||||
Next
|
|
||||||
|
|
||||||
If connectionString Is Nothing = False And CURR_SQL_PROVIDER = "ms-sql" 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
|
|
||||||
|
|
||||||
|
|
||||||
'sql = ClassPatterns.ReplaceAllValues(sql, pnldesigner, aktivesDokument)
|
|
||||||
If clsPatterns.HasOnlySimplePatterns(CURR_SELECT_CONTROL) Then
|
|
||||||
CURR_SELECT_CONTROL = clsPatterns.ReplaceInternalValues(CURR_SELECT_CONTROL)
|
|
||||||
CURR_SELECT_CONTROL = clsPatterns.ReplaceControlValues(CURR_SELECT_CONTROL, pnldesigner)
|
|
||||||
|
|
||||||
sqlCnn = New SqlClient.SqlConnection(connectionString)
|
|
||||||
' Try
|
|
||||||
sqlCnn.Open()
|
|
||||||
sqlCmd = New SqlClient.SqlCommand(CURR_SELECT_CONTROL, sqlCnn)
|
|
||||||
adapter.SelectCommand = sqlCmd
|
|
||||||
adapter.Fill(NewDataset)
|
|
||||||
|
|
||||||
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("Unexpected Error in running depending sql-command: " & ex.Message)
|
|
||||||
Clipboard.SetText("Error: " & ex.Message & vbNewLine & "SQL: " & CURR_SELECT_CONTROL)
|
|
||||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error in running depending sql-command:")
|
|
||||||
End Try
|
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
LOGGER.Debug("Else Row 571")
|
If CURR_CHOICE_LIST <> "" Then
|
||||||
End If
|
LOGGER.Debug("In add_ComboBox - AListe: " & CURR_CHOICE_LIST)
|
||||||
Else
|
Dim liste = WINDREAM.GetValuesfromAuswahlliste(CURR_CHOICE_LIST)
|
||||||
If CURR_CHOICE_LIST <> "" Then
|
If liste IsNot Nothing Then
|
||||||
LOGGER.Debug("In add_ComboBox - AListe: " & CURR_CHOICE_LIST)
|
cmb.Items.Add("")
|
||||||
Dim liste = WINDREAM.GetValuesfromAuswahlliste(CURR_CHOICE_LIST)
|
For Each index As String In liste
|
||||||
If liste IsNot Nothing Then
|
cmb.Items.Add(index)
|
||||||
cmb.Items.Add("")
|
Next
|
||||||
For Each index As String In liste
|
cmb.SelectedIndex = -1
|
||||||
cmb.Items.Add(index)
|
Else
|
||||||
Next
|
MsgBox("Resultliste windream is nothing!", MsgBoxStyle.Exclamation, CURR_CHOICE_LIST)
|
||||||
cmb.SelectedIndex = -1
|
End If
|
||||||
Else
|
|
||||||
MsgBox("Resultliste windream is nothing!", MsgBoxStyle.Exclamation, CURR_CHOICE_LIST)
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
End If
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
Dim maxWith As Integer = cmb.Width
|
Dim maxWith As Integer = cmb.Width
|
||||||
Using g As Graphics = Me.CreateGraphics
|
Using g As Graphics = Me.CreateGraphics
|
||||||
For Each oItem As Object In cmb.Items 'Für alle Einträge...
|
For Each oItem As Object In cmb.Items 'Für alle Einträge...
|
||||||
Dim g1 As Graphics = cmb.CreateGraphics
|
Dim g1 As Graphics = cmb.CreateGraphics
|
||||||
If g1.MeasureString(Text, cmb.Font).Width + 30 > maxWith Then
|
If g1.MeasureString(Text, cmb.Font).Width + 30 > maxWith Then
|
||||||
maxWith = g1.MeasureString(Text, cmb.Font).Width + 30
|
maxWith = g1.MeasureString(Text, cmb.Font).Width + 30
|
||||||
End If
|
End If
|
||||||
g1.Dispose()
|
g1.Dispose()
|
||||||
Next oItem
|
Next oItem
|
||||||
End Using
|
End Using
|
||||||
cmb.DropDownWidth = maxWith
|
cmb.DropDownWidth = maxWith
|
||||||
|
|
||||||
|
oControl = cmb
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ctrl = cmb
|
|
||||||
Case "DTP"
|
Case "DTP"
|
||||||
LOGGER.Debug("Versuch DTP zu laden")
|
LOGGER.Debug("Versuch DTP zu laden")
|
||||||
ctrl = ClassControlCreator.CreateExistingDatepicker(oControlRow, False)
|
oControl = ClassControlCreator.CreateExistingDatepicker(oControlRow, False)
|
||||||
Case "DGV"
|
Case "DGV"
|
||||||
LOGGER.Debug("Versuch DGV zu laden")
|
LOGGER.Debug("Versuch DGV zu laden")
|
||||||
Dim dgv = ClassControlCreator.CreateExistingDataGridView(oControlRow, False)
|
Dim dgv = ClassControlCreator.CreateExistingDataGridView(oControlRow, False)
|
||||||
|
|
||||||
AddHandler dgv.RowValidating, AddressOf onDGVRowValidating
|
AddHandler dgv.RowValidating, AddressOf onDGVRowValidating
|
||||||
|
|
||||||
ctrl = dgv
|
oControl = dgv
|
||||||
Case "CHK"
|
Case "CHK"
|
||||||
LOGGER.Debug("Versuch Checkbox zu laden")
|
LOGGER.Debug("Versuch Checkbox zu laden")
|
||||||
|
|
||||||
ctrl = ClassControlCreator.CreateExisingCheckbox(oControlRow, False)
|
oControl = ClassControlCreator.CreateExisingCheckbox(oControlRow, False)
|
||||||
Case "LINE"
|
Case "LINE"
|
||||||
LOGGER.Debug("Versuch Linie zu laden")
|
LOGGER.Debug("Versuch Linie zu laden")
|
||||||
|
|
||||||
ctrl = ClassControlCreator.CreateExistingLine(oControlRow, False)
|
oControl = ClassControlCreator.CreateExistingLine(oControlRow, False)
|
||||||
Case "LOOKUP"
|
Case "LOOKUP"
|
||||||
Dim lookup As LookupControl2 = ClassControlCreator.CreateExistingLookupControl(oControlRow, False)
|
Dim lookup As LookupControl2 = ClassControlCreator.CreateExistingLookupControl(oControlRow, False)
|
||||||
ctrl = lookup
|
oControl = lookup
|
||||||
lookup.PreventDuplicates = oControlRow.Item("VKT_PREVENT_MULTIPLE_VALUES")
|
lookup.PreventDuplicates = oControlRow.Item("VKT_PREVENT_MULTIPLE_VALUES")
|
||||||
lookup.AllowAddNewValues = oControlRow.Item("VKT_ADD_ITEM")
|
lookup.AllowAddNewValues = oControlRow.Item("VKT_ADD_ITEM")
|
||||||
lookup.MultiSelect = oControlRow.Item("MULTISELECT")
|
lookup.MultiSelect = oControlRow.Item("MULTISELECT")
|
||||||
@ -312,7 +321,7 @@ Public Class frmMassValidator
|
|||||||
''Wenn Multiselect false dann prüfen ob abhängiges Control
|
''Wenn Multiselect false dann prüfen ob abhängiges Control
|
||||||
If CBool(oControlRow.Item("MULTISELECT")) = False Then
|
If CBool(oControlRow.Item("MULTISELECT")) = False Then
|
||||||
Dim filteredData As DataTable = DTCONTROLS.Clone()
|
Dim filteredData As DataTable = DTCONTROLS.Clone()
|
||||||
Dim oExpression = $"SQL_UEBERPRUEFUNG like '%#CTRL#{ctrl.Name}%'"
|
Dim oExpression = $"SQL_UEBERPRUEFUNG like '%#CTRL#{oControl.Name}%'"
|
||||||
DTCONTROLS.Select(oExpression).CopyToDataTable(filteredData, LoadOption.PreserveChanges)
|
DTCONTROLS.Select(oExpression).CopyToDataTable(filteredData, LoadOption.PreserveChanges)
|
||||||
If filteredData.Rows.Count = 1 Then
|
If filteredData.Rows.Count = 1 Then
|
||||||
AddHandler lookup.SelectedValuesChanged, AddressOf onLookUp1
|
AddHandler lookup.SelectedValuesChanged, AddressOf onLookUp1
|
||||||
@ -329,14 +338,14 @@ Public Class frmMassValidator
|
|||||||
Where r.CONTROL_ID = oControlRow.Item("GUID")
|
Where r.CONTROL_ID = oControlRow.Item("GUID")
|
||||||
Select r).ToList()
|
Select r).ToList()
|
||||||
|
|
||||||
ctrl = ClassControlCreator.CreateExistingGridControl(oControlRow, columns, False)
|
oControl = ClassControlCreator.CreateExistingGridControl(oControlRow, columns, False)
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
If ctrl IsNot Nothing AndAlso TypeOf ctrl IsNot Label Then
|
If oControl IsNot Nothing AndAlso TypeOf oControl IsNot Label Then
|
||||||
ctrl.TabIndex = oCount
|
oControl.TabIndex = oCount
|
||||||
End If
|
End If
|
||||||
|
|
||||||
pnldesigner.Controls.Add(ctrl)
|
pnldesigner.Controls.Add(oControl)
|
||||||
|
|
||||||
oCount += 1
|
oCount += 1
|
||||||
Next
|
Next
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user