This commit is contained in:
Digital Data - Marlon Schreiber
2018-02-06 10:28:02 +01:00
parent ef06120f13
commit 17946f1a19
68 changed files with 4065 additions and 3630 deletions

View File

@@ -483,8 +483,12 @@ Public Class ClassControlValues
' Durchlaufe alle Controls, die eine Abhängigheit haben
For Each row As DataRow In dt.Rows
Dim msg = String.Format(" >> Working on Depending Control-ID: {0}", row.Item("GUID").ToString)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
Dim DependingControlId As Integer = row.Item("GUID")
Dim DependingControlSQL As String = row.Item("SQL_COMMAND_2")
msg = String.Format(" >> SQL: {0}", DependingControlSQL)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
Dim DependingControl As Control = controls.OfType(Of Control)().Where(Function(c As Control)
Return DirectCast(c.Tag, ClassControlMetadata).Id = DependingControlId
End Function).SingleOrDefault()
@@ -492,6 +496,8 @@ Public Class ClassControlValues
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,
' von dem das aktuelle Control abhängt
@@ -512,30 +518,58 @@ Public Class ClassControlValues
' Jetzt lesen wir den Wert aus, der im SQL Command ersetzt werden soll
Select Case otherControlType
Case "CheckBox"
msg = String.Format(" >> CheckBox-CtrlID: {0}", otherControlId)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
value = DirectCast(otherControl, CheckBox).Checked
Case "TextBox"
msg = String.Format(" >> TextBox-CtrlID: {0}", otherControlId)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
value = DirectCast(otherControl, TextBox).Text
Case "CustomComboBox"
msg = String.Format(" >> CustomComboBox-CtrlID: {0}", otherControlId)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
value = DirectCast(otherControl, CustomComboBox).Text
Case "DateEdit"
msg = String.Format(" >> DateEdit-CtrlID: {0}", otherControlId)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
value = DirectCast(otherControl, DevExpress.XtraEditors.DateEdit).EditValue
End Select
' Jetzt ersetzen wir den Platzhalter im SQL Command
DependingControlSQL = regex.Replace(DependingControlSQL, value)
msg = String.Format(" >> DependingControlSQL: {0}", DependingControlSQL)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
Dim enableDT As DataTable = ClassDatabase.Return_Datatable(DependingControlSQL)
If IsNothing(enableDT) Then
msg = String.Format(">> enableDT is nothing!! CHECK SQL {0}." & vbNewLine, DependingControlSQL)
ClassLogger.Add(msg)
Continue For
End If
If enableDT.Rows.Count = 1 Then
Dim enabled As Boolean = CBool(enableDT.Rows(0).Item(0))
Dim enabled As Boolean = True
Try
enabled = CBool(enableDT.Rows(0).Item(0))
Catch ex As Exception
msg = String.Format(">> Could not convert value of tablecontent to boolean!! SQL {0} # tablecontent: {1}" & vbNewLine, DependingControlSQL, enableDT.Rows(0).Item(0).ToString)
ClassLogger.Add(msg)
End Try
DependingControl.Enabled = enabled
If enabled = False Then
msg = String.Format(" >> Control {0} will be disabled." & vbNewLine, DependingControlId.ToString)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
Else
msg = String.Format(" >> Control {0} will be enabled." & vbNewLine, DependingControlId.ToString)
If LogErrorsOnly = False Then ClassLogger.Add(msg, False)
End If
Else
ClassLogger.Add(" >> Attention in Enable_Depending_Controls: RowCount for enabling control was '" & enableDT.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & DependingControlSQL & "'")
End If
End If
Next
SW.done
sw.done
Catch ex As Exception
ClassLogger.Add("Unexpected Error in Enable_Depending_Controls: " & ex.Message, True)
MsgBox("Unexpected Error in Enable_Depending_Controls:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)