JJ 02.06
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
Imports DevExpress.XtraEditors.Controls
|
Imports DevExpress.XtraEditors.Controls
|
||||||
|
Imports System.Text.RegularExpressions
|
||||||
|
|
||||||
Public Class ClassControlValues
|
Public Class ClassControlValues
|
||||||
|
|
||||||
@@ -442,6 +443,12 @@ Public Class ClassControlValues
|
|||||||
MsgBox("Unexpected Error in LoadControlValuesListWithPlaceholders:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
MsgBox("Unexpected Error in LoadControlValuesListWithPlaceholders:" & vbNewLine & ex.Message, MsgBoxStyle.Critical)
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
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)
|
Public Shared Sub Enable_Depending_Controls(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection, entity_ID As Integer)
|
||||||
Try
|
Try
|
||||||
If controls.Count = 0 Then
|
If controls.Count = 0 Then
|
||||||
@@ -460,6 +467,7 @@ Public Class ClassControlValues
|
|||||||
Exit Sub
|
Exit Sub
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
' Durchlaufe alle Controls, die eine Abhängigheit haben
|
||||||
For Each row As DataRow In dt.Rows
|
For Each row As DataRow In dt.Rows
|
||||||
Dim DependingControlId As Integer = row.Item("GUID")
|
Dim DependingControlId As Integer = row.Item("GUID")
|
||||||
Dim DependingControlSQL As String = row.Item("SQL_COMMAND_2")
|
Dim DependingControlSQL As String = row.Item("SQL_COMMAND_2")
|
||||||
@@ -467,8 +475,8 @@ Public Class ClassControlValues
|
|||||||
Return DirectCast(c.Tag, ClassControlMetadata).Id = DependingControlId
|
Return DirectCast(c.Tag, ClassControlMetadata).Id = DependingControlId
|
||||||
End Function).SingleOrDefault()
|
End Function).SingleOrDefault()
|
||||||
|
|
||||||
Dim regex As New System.Text.RegularExpressions.Regex("(@(\d+)@)")
|
Dim regex As New Regex("(@(\d+)@)")
|
||||||
Dim match As System.Text.RegularExpressions.Match = regex.Match(DependingControlSQL)
|
Dim match As Match = regex.Match(DependingControlSQL)
|
||||||
|
|
||||||
If match.Success Then
|
If match.Success Then
|
||||||
' Wir suchen aus dem SQL Befehl die ControlId heraus,
|
' 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'
|
' Jetzt holen wir uns den Wert von dem 'OtherControl'
|
||||||
' und geben seinen Value zusammen mit dem dependingControl weiter
|
' 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
|
Select Case otherControlType
|
||||||
Case "CheckBox"
|
Case "CheckBox"
|
||||||
value = DirectCast(otherControl, CheckBox).Checked
|
value = DirectCast(otherControl, CheckBox).Checked
|
||||||
@@ -496,7 +505,45 @@ Public Class ClassControlValues
|
|||||||
value = DirectCast(otherControl, DevExpress.XtraEditors.DateEdit).EditValue
|
value = DirectCast(otherControl, DevExpress.XtraEditors.DateEdit).EditValue
|
||||||
End Select
|
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
|
End If
|
||||||
Next
|
Next
|
||||||
|
|||||||
@@ -1330,6 +1330,9 @@ Public Class frmConstructor_Main
|
|||||||
#Region "DetailView - Toolstrip"
|
#Region "DetailView - Toolstrip"
|
||||||
|
|
||||||
Private Sub tsButtonAdd_Click(sender As Object, e As EventArgs) Handles tsButtonAdd.Click
|
Private Sub tsButtonAdd_Click(sender As Object, e As EventArgs) Handles tsButtonAdd.Click
|
||||||
|
' Vor dem Hinzufügen muss der EditMode auf jeden Fall ausgeschaltet werden!!
|
||||||
|
DisableEditMode()
|
||||||
|
|
||||||
'Wenn es eine Parent_ID gibt aber kein PArent_Datensatz ausgewählt wurde muss dies nachgeholt werden
|
'Wenn es eine Parent_ID gibt aber kein PArent_Datensatz ausgewählt wurde muss dies nachgeholt werden
|
||||||
If PARENT_ID > 0 Then
|
If PARENT_ID > 0 Then
|
||||||
If PARENT_SKIPPED = True And PARENT_RECORDID = 0 Then
|
If PARENT_SKIPPED = True And PARENT_RECORDID = 0 Then
|
||||||
@@ -1375,10 +1378,10 @@ Public Class frmConstructor_Main
|
|||||||
' Den Record anlegen, damit wir eine RECORD_ID bekommen
|
' Den Record anlegen, damit wir eine RECORD_ID bekommen
|
||||||
ClassControlCommandsUI.CreateRecord(ENTITY_ID)
|
ClassControlCommandsUI.CreateRecord(ENTITY_ID)
|
||||||
' Die RECORD_ID auslesen und setzen
|
' Die RECORD_ID auslesen und setzen
|
||||||
Dim NewRecordId As Integer = ClassControlCommandsUI.GetLastRecord()
|
NEW_RECORD_ID = ClassControlCommandsUI.GetLastRecord()
|
||||||
CURRENT_RECORD_ID = NewRecordId
|
CURRENT_RECORD_ID = NEW_RECORD_ID
|
||||||
RECORD_ID = NewRecordId
|
RECORD_ID = NEW_RECORD_ID
|
||||||
SELECTED_RECORD_ID = NewRecordId
|
SELECTED_RECORD_ID = NEW_RECORD_ID
|
||||||
If PARENT_ID > 0 And PARENT_RECORDID > 0 Then
|
If PARENT_ID > 0 And PARENT_RECORDID > 0 Then
|
||||||
If ClassControlCommandsUI.ConnectRecord(PARENT_RECORDID, CURRENT_RECORD_ID, "INSERT RECORD") = False Then
|
If ClassControlCommandsUI.ConnectRecord(PARENT_RECORDID, CURRENT_RECORD_ID, "INSERT RECORD") = False Then
|
||||||
MsgBox("Unexpected Error in Connect Record - Please check the logfile and inform the admin!", MsgBoxStyle.Critical)
|
MsgBox("Unexpected Error in Connect Record - Please check the logfile and inform the admin!", MsgBoxStyle.Critical)
|
||||||
@@ -1388,7 +1391,7 @@ Public Class frmConstructor_Main
|
|||||||
ClassControlValues.LoadDefaultValues(ENTITY_ID, SELECTED_RECORD_ID, pnlDetails.Controls, CURRENT_PARENT_ID, ENTITY_ID)
|
ClassControlValues.LoadDefaultValues(ENTITY_ID, SELECTED_RECORD_ID, pnlDetails.Controls, CURRENT_PARENT_ID, ENTITY_ID)
|
||||||
|
|
||||||
' Das StatusLabel aktualisieren
|
' Das StatusLabel aktualisieren
|
||||||
Update_Record_Label(NewRecordId)
|
Update_Record_Label(NEW_RECORD_ID)
|
||||||
' Im gegensatz zu EnableEditMode muss hier nur der save button enabled werden
|
' Im gegensatz zu EnableEditMode muss hier nur der save button enabled werden
|
||||||
tsButtonSave.Enabled = True
|
tsButtonSave.Enabled = True
|
||||||
' Muss aktiviert werden, sonst funktionieren die Combobox Abhängigkeits Events nicht
|
' Muss aktiviert werden, sonst funktionieren die Combobox Abhängigkeits Events nicht
|
||||||
@@ -1557,13 +1560,7 @@ Public Class frmConstructor_Main
|
|||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
If CtrlCommandUI.IsInsert Then
|
tsButtonCancel.Visible = False
|
||||||
tsButtonSave.Enabled = False
|
|
||||||
tsButtonCancel.Visible = False
|
|
||||||
Else
|
|
||||||
' DisableEditMode()
|
|
||||||
End If
|
|
||||||
|
|
||||||
CtrlCommandUI.IsInsert = False
|
CtrlCommandUI.IsInsert = False
|
||||||
EDIT_STATE = EditState.None
|
EDIT_STATE = EditState.None
|
||||||
RECORD_CHANGED = False
|
RECORD_CHANGED = False
|
||||||
|
|||||||
Reference in New Issue
Block a user