fix depending controls crashing because of missing tag for datetimepicker
This commit is contained in:
parent
ed5a1233ae
commit
3659055597
@ -284,14 +284,14 @@ Public Class ClassControls
|
||||
End Sub
|
||||
|
||||
Public Function AddTextBox(indexname As String, y As Integer, text As String, DataType As String) As TextBox
|
||||
Dim txt As New TextBox
|
||||
txt.Name = "txt" & indexname
|
||||
|
||||
txt.Size = New Size(260, 27)
|
||||
txt.Location = New Point(11, y)
|
||||
txt.Tag = New ControlMeta() With {
|
||||
.IndexName = indexname,
|
||||
.IndexType = DataType
|
||||
Dim txt As New TextBox With {
|
||||
.Name = "txt" & indexname,
|
||||
.Size = New Size(260, 27),
|
||||
.Location = New Point(11, y),
|
||||
.Tag = New ControlMeta() With {
|
||||
.IndexName = indexname,
|
||||
.IndexType = DataType
|
||||
}
|
||||
}
|
||||
|
||||
If text <> "" Then
|
||||
@ -340,6 +340,27 @@ Public Class ClassControls
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function AddDateTimePicker(indexname As String, y As Integer, DataType As String)
|
||||
Dim dtp As New DateTimePicker With {
|
||||
.Name = "dtp" & indexname,
|
||||
.Format = DateTimePickerFormat.Short,
|
||||
.Size = New Size(133, 27),
|
||||
.Location = New Point(11, y),
|
||||
.Tag = New ControlMeta() With {
|
||||
.IndexName = indexname,
|
||||
.IndexType = DataType
|
||||
}
|
||||
}
|
||||
|
||||
AddHandler dtp.ValueChanged, AddressOf OndtpChanged
|
||||
|
||||
Return dtp
|
||||
End Function
|
||||
Sub OndtpChanged()
|
||||
'offen was hier zu tun ist
|
||||
End Sub
|
||||
|
||||
Private Sub PrepareDependingControl(Control As Control)
|
||||
If TypeOf Control Is Label Then
|
||||
Exit Sub
|
||||
|
||||
@ -176,12 +176,24 @@ Public Class ClassPatterns
|
||||
Continue For
|
||||
End If
|
||||
|
||||
LOGGER.Debug("Getting control metadata..")
|
||||
LOGGER.Debug("Getting control metadata from object: [{0}]", oControl?.Tag?.ToString())
|
||||
|
||||
Dim oMeta = DirectCast(oControl.Tag, ClassControls.ControlMeta)
|
||||
If oControl.Tag Is Nothing Then
|
||||
LOGGER.Warn("No Metadata object found for control [{0}]. Skipping.", oControl.Name)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oMeta = TryCast(oControl.Tag, ClassControls.ControlMeta)
|
||||
|
||||
LOGGER.Debug("Metadata IndexName: [{0}]", oMeta.IndexName)
|
||||
LOGGER.Debug("Metadata IndexType: [{0}]", oMeta.IndexType)
|
||||
LOGGER.Debug("Checking Control Name matches..")
|
||||
|
||||
If oMeta Is Nothing Then
|
||||
LOGGER.Warn("No Metadata found for control [{0}]. Skipping.", oControl.Name)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
If oMeta.IndexName = controlName Then
|
||||
LOGGER.Debug("Control Name matches! Matching Control: [{0}]", controlName)
|
||||
|
||||
@ -194,6 +206,8 @@ Public Class ClassPatterns
|
||||
If oFoundControl IsNot Nothing Then
|
||||
Dim oValue As String = String.Empty
|
||||
|
||||
LOGGER.Debug("Found Control [{0}], continuing with setting value..", oFoundControl.Name)
|
||||
|
||||
If TypeOf oFoundControl Is TextBox Then
|
||||
Try
|
||||
oValue = DirectCast(oFoundControl, TextBox).Text
|
||||
@ -219,6 +233,8 @@ Public Class ClassPatterns
|
||||
Case "VARCHAR"
|
||||
Dim oWrapped = oLookupControl.SelectedValues.Select(Function(v) $"'{v}'")
|
||||
oValue = String.Join(",", oWrapped)
|
||||
Case Else
|
||||
LOGGER.Warn("Lookup Control with [{0}] is not supported!", oFoundType)
|
||||
End Select
|
||||
Else
|
||||
oValue = NotNull(oLookupControl.SelectedValues.Item(0), "")
|
||||
@ -228,10 +244,11 @@ Public Class ClassPatterns
|
||||
LOGGER.Warn("Control Value for LookupControl2 [{0}] could not be retrieved!", oFoundControl.Name)
|
||||
End Try
|
||||
Else
|
||||
LOGGER.Debug("Unknown Control type for type [{0}], setting value to empty string.", oFoundControl.Name)
|
||||
oValue = ""
|
||||
End If
|
||||
|
||||
LOGGER.Debug("Retrieved Value from Control [{0}] is: [{1}]", oFoundControl.Name, oValue)
|
||||
LOGGER.Debug("Retrieved Value from Control [{0}] is: [{1}]", controlName, oValue)
|
||||
|
||||
result = ReplacePattern(result, PATTERN_CTRL, oValue)
|
||||
Else
|
||||
|
||||
@ -83,20 +83,6 @@ Public Class frmIndex
|
||||
lbl.Location = New Point(11, ylbl)
|
||||
End Sub
|
||||
|
||||
Sub AddDateTimePicker(indexname As String, y As Integer)
|
||||
Dim dtp As New DateTimePicker
|
||||
dtp.Name = "dtp" & indexname
|
||||
dtp.Format = DateTimePickerFormat.Short
|
||||
dtp.Size = New Size(133, 27)
|
||||
pnlIndex.Controls.Add(dtp)
|
||||
dtp.Location = New Point(11, y)
|
||||
AddHandler dtp.ValueChanged, AddressOf OndtpChanged
|
||||
End Sub
|
||||
Sub OndtpChanged()
|
||||
'offen was hier zu tun ist
|
||||
End Sub
|
||||
|
||||
|
||||
Function Indexwert_checkValueDB(indexname As String, wert As String)
|
||||
Try
|
||||
Dim DR As DataRow
|
||||
@ -1596,9 +1582,9 @@ Public Class frmIndex
|
||||
|
||||
Private Sub LoadIndexe_Man()
|
||||
Try
|
||||
Dim anz As Integer = 1
|
||||
Dim ylbl As Integer = 11
|
||||
Dim y As Integer = 33
|
||||
Dim oControlCount As Integer = 1
|
||||
Dim oLabelPosition As Integer = 11
|
||||
Dim oControlPosition As Integer = 33
|
||||
Dim oControls As New ClassControls(pnlIndex, Me)
|
||||
|
||||
If DT_INDEXEMAN.Rows.Count = 0 Then
|
||||
@ -1606,61 +1592,64 @@ Public Class frmIndex
|
||||
LOGGER.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDokumentart.Text & " definiert")
|
||||
End If
|
||||
|
||||
For Each DR As DataRow In DT_INDEXEMAN.Rows
|
||||
Dim type = DR.Item("DATATYPE")
|
||||
Dim MultiSelect As Boolean = DR.Item("MULTISELECT")
|
||||
Dim AddNewItems As Boolean = DR.Item("VKT_ADD_ITEM")
|
||||
Dim PreventDuplicates As Boolean = DR.Item("VKT_PREVENT_MULTIPLE_VALUES")
|
||||
For Each oRow As DataRow In DT_INDEXEMAN.Rows
|
||||
Dim oDataType = oRow.Item("DATATYPE")
|
||||
Dim MultiSelect As Boolean = oRow.Item("MULTISELECT")
|
||||
Dim AddNewItems As Boolean = oRow.Item("VKT_ADD_ITEM")
|
||||
Dim PreventDuplicates As Boolean = oRow.Item("VKT_PREVENT_MULTIPLE_VALUES")
|
||||
Dim oControlName As String = oRow.Item("NAME")
|
||||
|
||||
If type <> "BOOLEAN" Then
|
||||
addLabel(DR.Item("NAME"), DR.Item("COMMENT").ToString, ylbl, anz)
|
||||
If oDataType <> "BOOLEAN" Then
|
||||
addLabel(oControlName, oRow.Item("COMMENT").ToString, oLabelPosition, oControlCount)
|
||||
End If
|
||||
|
||||
Dim DefaultValue = Check_HistoryValues(DR.Item("NAME"), DR.Item("DOKUMENTART"))
|
||||
Dim DefaultValue = Check_HistoryValues(oControlName, oRow.Item("DOKUMENTART"))
|
||||
If DefaultValue Is Nothing Then
|
||||
DefaultValue = DR.Item("DEFAULT_VALUE")
|
||||
DefaultValue = oRow.Item("DEFAULT_VALUE")
|
||||
End If
|
||||
Select Case type
|
||||
Select Case oDataType
|
||||
Case "BOOLEAN"
|
||||
Dim chk As CheckBox = oControls.AddCheckBox(DR.Item("NAME"), y, DefaultValue, DR.Item("COMMENT").ToString)
|
||||
Dim chk As CheckBox = oControls.AddCheckBox(oControlName, oControlPosition, DefaultValue, oRow.Item("COMMENT").ToString)
|
||||
If Not IsNothing(chk) Then
|
||||
pnlIndex.Controls.Add(chk)
|
||||
End If
|
||||
Case "INTEGER"
|
||||
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
|
||||
Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DR.Item("DATATYPE"), DefaultValue, AddNewItems, PreventDuplicates)
|
||||
If oRow.Item("SUGGESTION") = True And oRow.Item("SQL_RESULT").ToString.Length > 0 Then
|
||||
Dim oControl = oControls.AddVorschlag_ComboBox(oControlName, oControlPosition, oRow.Item("CONNECTION_ID"), oRow.Item("SQL_RESULT"), MultiSelect, oDataType, DefaultValue, AddNewItems, PreventDuplicates)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
Else
|
||||
'nur eine Textbox
|
||||
Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, DefaultValue, DR.Item("DATATYPE"))
|
||||
Dim oControl = oControls.AddTextBox(oControlName, oControlPosition, DefaultValue, oDataType)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
End If
|
||||
Case "VARCHAR"
|
||||
If DR.Item("SUGGESTION") = True And DR.Item("SQL_RESULT").ToString.Length > 0 Then
|
||||
Dim oControl = oControls.AddVorschlag_ComboBox(DR.Item("NAME"), y, DR.Item("CONNECTION_ID"), DR.Item("SQL_RESULT"), MultiSelect, DR.Item("DATATYPE"), DefaultValue, AddNewItems, PreventDuplicates)
|
||||
If oRow.Item("SUGGESTION") = True And oRow.Item("SQL_RESULT").ToString.Length > 0 Then
|
||||
Dim oControl = oControls.AddVorschlag_ComboBox(oControlName, oControlPosition, oRow.Item("CONNECTION_ID"), oRow.Item("SQL_RESULT"), MultiSelect, oDataType, DefaultValue, AddNewItems, PreventDuplicates)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
Else
|
||||
If DR.Item("NAME").ToString.ToLower = "dateiname" Then
|
||||
Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE), DR.Item("DATATYPE"))
|
||||
If oControlName.ToString.ToLower = "dateiname" Then
|
||||
Dim oControl = oControls.AddTextBox(oControlName, oControlPosition, System.IO.Path.GetFileNameWithoutExtension(CURRENT_WORKFILE), oDataType)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
Else
|
||||
Dim VORBELGUNG As String = DefaultValue
|
||||
Dim oControl = oControls.AddTextBox(DR.Item("NAME"), y, VORBELGUNG, DR.Item("DATATYPE"))
|
||||
Dim oControl = oControls.AddTextBox(oControlName, oControlPosition, VORBELGUNG, oDataType)
|
||||
If Not IsNothing(oControl) Then
|
||||
pnlIndex.Controls.Add(oControl)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Case "DATE"
|
||||
AddDateTimePicker(DR.Item("NAME"), y)
|
||||
Dim oPicker = oControls.AddDateTimePicker(oControlName, oControlPosition, oDataType)
|
||||
pnlIndex.Controls.Add(oPicker)
|
||||
|
||||
Case Else
|
||||
If USER_LANGUAGE = "de-DE" Then
|
||||
MsgBox("Bitte überprüfen Sie den Datentyp des hinterlegten Indexwertes!", MsgBoxStyle.Critical, "Achtung:")
|
||||
@ -1671,18 +1660,18 @@ Public Class frmIndex
|
||||
LOGGER.Warn(" - Datentyp nicht hinterlegt - LoadIndexe_Man")
|
||||
End Select
|
||||
|
||||
anz += 1
|
||||
ylbl += 50
|
||||
y += 50
|
||||
oControlCount += 1
|
||||
oLabelPosition += 50
|
||||
oControlPosition += 50
|
||||
'make y as height in fom
|
||||
Next
|
||||
Dim pnlHeight = y - 30
|
||||
Dim oPanelHeight = oControlPosition - 30
|
||||
|
||||
If pnlIndex.Height < pnlHeight Then
|
||||
If (Me.Height - 315) < pnlHeight Then
|
||||
Me.Height = (Me.Height - 315) + pnlHeight
|
||||
If pnlIndex.Height < oPanelHeight Then
|
||||
If (Me.Height - 315) < oPanelHeight Then
|
||||
Me.Height = (Me.Height - 315) + oPanelHeight
|
||||
End If
|
||||
pnlIndex.Height = pnlHeight
|
||||
pnlIndex.Height = oPanelHeight
|
||||
End If
|
||||
|
||||
SendKeys.Send("{TAB}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user