This commit is contained in:
JenneJ
2016-06-02 15:42:22 +02:00
parent f60d30572c
commit 212185deb3
2 changed files with 60 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
Imports DevExpress.XtraEditors.Controls
Imports System.Text.RegularExpressions
Public Class ClassControlValues
@@ -442,6 +443,12 @@ Public Class ClassControlValues
MsgBox("Unexpected Error in LoadControlValuesListWithPlaceholders:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
''' <summary>
''' Sucht alle Controls in der aktuellen Entität, die eine Abhängigkeit besitzen
''' </summary>
''' <remarks></remarks>
Public Shared Sub Enable_Depending_Controls(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection, entity_ID As Integer)
Try
If controls.Count = 0 Then
@@ -460,6 +467,7 @@ Public Class ClassControlValues
Exit Sub
End If
' Durchlaufe alle Controls, die eine Abhängigheit haben
For Each row As DataRow In dt.Rows
Dim DependingControlId As Integer = row.Item("GUID")
Dim DependingControlSQL As String = row.Item("SQL_COMMAND_2")
@@ -467,8 +475,8 @@ Public Class ClassControlValues
Return DirectCast(c.Tag, ClassControlMetadata).Id = DependingControlId
End Function).SingleOrDefault()
Dim regex As New System.Text.RegularExpressions.Regex("(@(\d+)@)")
Dim match As System.Text.RegularExpressions.Match = regex.Match(DependingControlSQL)
Dim regex As New Regex("(@(\d+)@)")
Dim match As Match = regex.Match(DependingControlSQL)
If match.Success Then
' Wir suchen aus dem SQL Befehl die ControlId heraus,
@@ -483,8 +491,9 @@ Public Class ClassControlValues
' Jetzt holen wir uns den Wert von dem 'OtherControl'
' und geben seinen Value zusammen mit dem dependingControl weiter
Dim value As Object
Dim value As Object = Nothing
' Jetzt lesen wir den Wert aus, der im SQL Command ersetzt werden soll
Select Case otherControlType
Case "CheckBox"
value = DirectCast(otherControl, CheckBox).Checked
@@ -496,7 +505,45 @@ Public Class ClassControlValues
value = DirectCast(otherControl, DevExpress.XtraEditors.DateEdit).EditValue
End Select
CtrlBuilder.Enable_Controls(DependingControl, dt, value)
' Jetzt ersetzen wir den Platzhalter im SQL Command
DependingControlSQL = regex.Replace(DependingControlSQL, value)
Dim enableDT As DataTable = ClassDatabase.Return_Datatable(DependingControlSQL)
Dim type = DependingControl.GetType().Name
' Jetzt wird basierend auf dem Ergebnis das DependingControl aktiviert/deaktiviert
Select Case type
Case "DateEdit"
Try
Dim enabled As Boolean = CBool(enableDT.Rows(0).Item(0))
DependingControl.Enabled = enabled
Catch ex As Exception
ClassLogger.Add("Unexpected Error in EnableControls - DateEdit: " & ex.Message, True)
End Try
Case "CustomComboBox"
Try
Dim enabled As Boolean = CBool(enableDT.Rows(0).Item(0))
DependingControl.Enabled = enabled
Catch ex As Exception
ClassLogger.Add("Unexpected Error in EnableControls - CustomComboBox: " & ex.Message, True)
End Try
Case "TextBox"
Try
Dim enabled As Boolean = CBool(enableDT.Rows(0).Item(0))
DependingControl.Enabled = enabled
Catch ex As Exception
ClassLogger.Add("Unexpected Error in EnableControls - TextBox: " & ex.Message, True)
End Try
Case "CheckBox"
Try
Dim enabled As Boolean = CBool(enableDT.Rows(0).Item(0))
DependingControl.Enabled = enabled
Catch ex As Exception
ClassLogger.Add("Unexpected Error in EnableControls - Checkbox: " & ex.Message, True)
End Try
End Select
End If
Next