This commit is contained in:
JenneJ
2016-08-24 15:06:55 +02:00
parent 08a93d1338
commit 8cac2cf09e
4 changed files with 128 additions and 33 deletions

View File

@@ -163,16 +163,64 @@ Public Class ClassControlBuilder
Public Sub OnTextBoxFocus(sender As Object, ByVal e As EventArgs)
Dim box As TextBox = sender
box.BackColor = Color.LemonChiffon
box.SelectAll()
If CURRENT_RECORD_ENABLED = False Then Exit Sub
CURRENT_TEXTBOX_SELECTED_TEXT = DirectCast(sender, TextBox).Text
End Sub
Public Sub OnTextBoxLostFocus(sender As Object, ByVal e As EventArgs)
Dim box As TextBox = sender
box.BackColor = Color.White
End Sub
Public Sub OnTextBoxTextChanged(sender As Object, ByVal e As EventArgs)
If CURRENT_RECORD_ENABLED = False Then Exit Sub
CURRENT_RECORD_ENABLED = False
Try
Dim control As Control = DirectCast(sender, Control)
Dim textbox As TextBox = DirectCast(control, TextBox)
Dim controlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
CONTROL_ID = controlId
Dim expression As String
expression = "ENTITY_ID = " & CURRENT_FORM_ID
Dim foundControls() As DataRow
' Use the Select method to find all rows matching the filter.
foundControls = CURRENT_DT_TBPMO_ENTITY_RIGHT_CONTROLS.Select(expression)
Dim i As Integer
Dim NODE_CONFIG_ID
' Check if control is one of rightcontrols
For i = 0 To foundControls.GetUpperBound(0)
If foundControls(i)("CONTROL_ID") = CONTROL_ID Then
RIGHT_CONTROL_CHANGED = True
Dim msg = MSG_RIGHTMODULE_DE
If USER_LANGUAGE <> "de-DE" Then
msg = MSG_RIGHTMODULE_EN_US
End If
Dim result As MsgBoxResult
result = MessageBox.Show(msg, "Confirmation needed:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.No Then
CtrlBuilder.ControlsChanged.Remove(controlId)
' Y U NO WORK??
Dim text = CURRENT_TEXTBOX_SELECTED_TEXT
textbox.Text = text
CURRENT_RECORD_ENABLED = True
Exit Sub
End If
End If
Next
Catch ex As Exception
If ex.Message.Contains("Objektverweis") Or ex.Message.Contains("reference not set") Then
Else
MsgBox("Error in OnTextBoxLostFocus - " & CONTROL_ID.ToString & ": " & ex.Message, MsgBoxStyle.Critical)
End If
Finally
CURRENT_RECORD_ENABLED = True
End Try
End Sub
Public Sub OnComboBoxFocus(sender As Object, ByVal e As EventArgs)
Dim combo As CustomComboBox = sender
combo.BackColor = Color.LemonChiffon
@@ -489,16 +537,20 @@ Public Class ClassControlBuilder
Dim control As Control = DirectCast(sender, Control)
Dim controlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
CURRENT_COMBOBOX_SELECTED_INDEX = DirectCast(control, CustomComboBox).SelectedIndex
CURRENT_COMBOBOX_SELECTED_TEXT = DirectCast(control, CustomComboBox).Text
Catch ex As Exception
MsgBox("Error in OnComboBoxFocused - " & CONTROL_ID.ToString & ": " & ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
Public Sub OnComboBoxValueChanged(sender As Object, ByVal e As EventArgs)
If CURRENT_RECORD_ENABLED = False Then Exit Sub
' Verhindert, dass OnComboBoxFocues unkontrolliert feuert!
CURRENT_RECORD_ENABLED = False
Try
Dim control As Control = DirectCast(sender, Control)
Dim combo As CustomComboBox = DirectCast(control, CustomComboBox)
Dim controlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
CONTROL_ID = controlId
@@ -513,9 +565,35 @@ Public Class ClassControlBuilder
For i = 0 To foundControls.GetUpperBound(0)
If foundControls(i)("CONTROL_ID") = CONTROL_ID Then
RIGHT_CONTROL_CHANGED = True
Exit For
Dim msg = MSG_RIGHTMODULE_DE
If USER_LANGUAGE <> "de-DE" Then
msg = MSG_RIGHTMODULE_EN_US
End If
Dim result As MsgBoxResult
result = MessageBox.Show(msg, "Confirmation needed:", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If result = MsgBoxResult.No Then
CtrlBuilder.ControlsChanged.Remove(controlId)
' Y U NO WORK??
Dim text = CURRENT_COMBOBOX_SELECTED_TEXT
combo.SelectedIndex = -1
combo.SelectedText = text
combo.Text = text
CURRENT_RECORD_ENABLED = True
Exit Sub
End If
End If
Next
Dim onRecordChangedHandler As EventHandler = CType(Me.Events(_onRecordChangedName), EventHandler)
If Not ControlsChanged.Contains(controlId) Then
ControlsChanged.Add(controlId)
End If
If (onRecordChangedHandler IsNot Nothing And WatchRecordChanges) Then
onRecordChangedHandler.Invoke(sender, e)
End If
'SQL für abhängige Auswahllisten
Dim SQL As String = String.Format("SELECT GUID, SQL_COMMAND_1, CONTROL_TYPE_ID,FORMAT_TYPE FROM TBPMO_CONTROL WHERE SQL_COMMAND_1 LIKE '%@{0}@%'", controlId)
Dim value
@@ -538,9 +616,11 @@ Public Class ClassControlBuilder
value = DirectCast(control, CustomComboBox).Text
If String.IsNullOrEmpty(value) Then
CURRENT_RECORD_ENABLED = True
Exit Sub
End If
If CURRENT_RECORD_ID = 0 And CtrlCommandUI.IsInsert = True Then
CURRENT_RECORD_ENABLED = True
Exit Sub
End If
@@ -549,7 +629,7 @@ Public Class ClassControlBuilder
Depending_Controls(control, datatable, value)
Enable_Controls(control, datatable1, value)
Console.WriteLine("value changed")
CURRENT_RECORD_ENABLED = True
Catch ex As Exception
If ex.Message.Contains("Objektverweis") Or ex.Message.Contains("reference not set") Then
@@ -588,6 +668,12 @@ Public Class ClassControlBuilder
If result = MsgBoxResult.No Then
RIGHT_CONTROL_CHANGED = False
CtrlBuilder.ControlsChanged.Remove(controlId)
Dim loadedValues As List(Of Object) = (From row In CURRENT_CONTROL_VALUES.AsEnumerable()
Where row.Item("CONTROL_ID") = controlId
Select row.Item("VALUE")).ToList()
ClassControlValues.LoadControlValue(CURRENT_RECORD_ID, CURRENT_PARENT_RECORD_ID, CONTROL_ID, control, loadedValues, CURRENT_FORM_ID)
RECORD_CHANGED = False
Exit Sub
End If
@@ -787,15 +873,15 @@ Public Class ClassControlBuilder
AddHandler textbox.TextChanged, AddressOf RecordChanged
AddHandler textbox.GotFocus, AddressOf OnTextBoxFocus
AddHandler textbox.LostFocus, AddressOf OnTextBoxLostFocus
AddHandler textbox.TextChanged, AddressOf OnTextBoxTextChanged
AddHandler textbox.ReadOnlyChanged, AddressOf OnReadOnlyChanged
Case "CustomComboBox"
Dim combo As CustomComboBox = CType(control, CustomComboBox)
AddHandler combo.GotFocus, AddressOf OnComboBoxFocused
AddHandler combo.SelectedValueChanged, AddressOf RecordChanged
'AddHandler combo.GotFocus, AddressOf OnComboBoxFocused
AddHandler combo.Enter, AddressOf OnComboBoxFocused
AddHandler combo.SelectedValueChanged, AddressOf OnComboBoxValueChanged
AddHandler combo.TextChanged, AddressOf RecordChanged
'AddHandler combo.TextChanged, AddressOf RecordChanged
'AddHandler combo.GotFocus, AddressOf OnComboBoxFocus
'AddHandler combo.LostFocus, AddressOf OnComboBoxLostFocus
AddHandler combo.EnabledChanged, AddressOf OnEnabledChanged
@@ -2275,7 +2361,9 @@ Public Class ClassControlBuilder
Next
End If
Me.SetEventHandlers(control)
If Not _designMode Then
Me.SetEventHandlers(control)
End If
Me.CurrentControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
If Not IsNothing(parent) Then
control.Parent = parent