This commit is contained in:
SchreiberM
2016-03-29 09:52:37 +02:00
parent 58788043c5
commit 49f2dc6f3f
18 changed files with 2619 additions and 815 deletions

View File

@@ -103,11 +103,13 @@ Public Class ClassControlBuilder
Dim combo As ComboBox = sender
combo.BackColor = Color.White
End Sub
Dim CONTROL_ID
Public Sub OnComboBoxValueChanged(sender As Object, ByVal e As EventArgs)
If CURRENT_RECORD_ENABLED = False Then Exit Sub
Try
Dim control As Control = DirectCast(sender, Control)
Dim controlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
CONTROL_ID = controlId
Dim SQL As String = String.Format("SELECT GUID, SQL_COMMAND_1 FROM TBPMO_CONTROL WHERE SQL_COMMAND_1 LIKE '%@{0}@%'", controlId)
Dim value
@@ -154,10 +156,38 @@ Public Class ClassControlBuilder
sqlcommand = sqlcommand.Replace(match.Groups(1).Value, value)
Console.WriteLine("Executing SQL_COMMAND: {0} for controlID {1}", sqlcommand, dependingControlId)
Dim dt As DataTable = ClassDatabase.Return_Datatable(sqlcommand)
Dim obj
obj = dependingControl.GetType.ToString
Select Case dependingControl.GetType.ToString
Select Case control.GetType()
Case GetType(ComboBox)
Case "System.Windows.Forms.ComboBox"
ControlLoader.Combobox.SetDataSource(DirectCast(dependingControl, ComboBox), dt)
Case "System.Windows.Forms.Label"
If dt.Rows.Count = 1 Then
Try
ControlLoader.Label.LoadValue(DirectCast(dependingControl, Label), 9999, 9999, dt.Rows(0).Item(0).ToString, True)
Catch ex As Exception
ClassLogger.Add(ex.Message)
End Try
End If
Case "System.Windows.Forms.TextBox"
If dt.Rows.Count = 1 Then
Try
ControlLoader.TextBox.LoadValue(DirectCast(dependingControl, TextBox), 9999, 9999, dt.Rows(0).Item(0).ToString, True)
Dim sql1 = String.Format("SELECT GUID FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", dependingControlId, CURRENT_RECORD_ID)
Dim id = ClassDatabase.Execute_Scalar(sql1)
If Not IsNothing(id) Then
Dim upd = String.Format("UPDATE TBPMO_CONTROL_VALUE SET VALUE = '{0}' WHERE GUID = {1}", dt.Rows(0).Item(0).ToString, id)
ClassDatabase.Execute_non_Query(sql1)
Else
Dim ins = String.Format("INSERT INTO TBPMO_CONTROL_VALUE (CONTROL_ID,RECORD_ID,VALUE,ADDED_WHO) VALUES ({0},{1},'{2}','{3}')", dependingControlId, CURRENT_RECORD_ID, dt.Rows(0).Item(0).ToString, Environment.UserName)
ClassDatabase.Execute_non_Query(ins)
End If
Catch ex As Exception
ClassLogger.Add(ex.Message)
End Try
End If
End Select
@@ -196,7 +226,11 @@ Public Class ClassControlBuilder
Console.WriteLine("value changed")
Catch ex As Exception
MsgBox("Error in OnComboBoxValueChanged: " & ex.Message)
If ex.Message.Contains("Objektverweis") Or ex.Message.Contains("reference not set") Then
Else
MsgBox("Error in OnComboBoxValueChanged - " & CONTROL_ID.ToString & ": " & ex.Message, MsgBoxStyle.Critical)
End If
End Try
End Sub