jj 14.03 add props for dgv, new value structure for clb

This commit is contained in:
JenneJ
2016-03-14 15:16:04 +01:00
parent 65ff842c1e
commit 0f271342b6
4 changed files with 105 additions and 13 deletions

View File

@@ -495,6 +495,12 @@ Public Class ClassControlCommandsUI
Continue For
End If
If TypeOf ctrl Is DevExpress.XtraEditors.CheckedListBoxControl Then
Dim id As Integer = DirectCast(ctrl.Tag, ClassControlMetadata).Id
UpdateMultipleValues(id, RecordID, CONTROL_VALUE)
Continue For
End If
Dim ValueExists = ClassDatabase.Execute_Scalar(String.Format("SELECT RECORD_ID FROM VWPMO_VALUES WHERE RECORD_ID = {0} AND CONTROL_ID = {1}", RecordID, CONTROL_ID))
If ValueExists Then ' Control Updaten
@@ -510,6 +516,31 @@ Public Class ClassControlCommandsUI
End Sub
Public Sub UpdateMultipleValues(ControlId As Integer, RecordId As Integer, value As String)
Try
Dim values As New List(Of String)(value.Split(";"))
Dim dt As DataTable = ClassDatabase.Return_Datatable(String.Format("SELECT VALUE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1}", ControlId, RecordId))
' Konvertiere datatable zu liste
Dim oldValues = dt.AsEnumerable().Select(Of String)(Function(r)
Return r.Item("VALUE")
End Function).ToList()
Dim AddValues = values.Except(oldValues)
Dim RemoveValues = oldValues.Except(values)
For Each v As String In AddValues
ClassDatabase.Execute_non_Query(String.Format("INSERT INTO TBPMO_CONTROL_VALUE (CONTROL_ID, RECORD_ID, VALUE) VALUES({0}, {1}, '{2}')", ControlId, RecordId, v))
Next
For Each v As String In RemoveValues
ClassDatabase.Execute_non_Query(String.Format("DELETE FROM TBPMO_CONTROL_VALUE WHERE CONTROL_ID = {0} AND RECORD_ID = {1} AND VALUE = '{2}'", ControlId, RecordId, v))
Next
Catch ex As Exception
MsgBox("Error in UpdateMultipleValues:" & vbNewLine & ex.Message)
End Try
End Sub
Function GetControlValue(ctrl As Control) As String
Dim type = ctrl.GetType().Name
@@ -547,7 +578,7 @@ Public Class ClassControlCommandsUI
Dim result_string As String
For Each item As DevExpress.XtraEditors.Controls.CheckedListBoxItem In chklbx.CheckedItems
result.Add(item.Value)
result.Add(item.Value.ToString.Trim)
Next
result_string = String.Join(";", result)
@@ -598,7 +629,7 @@ Public Class ClassControlCommandsUI
If LogErrorsOnly = False Then ClassLogger.Add(">> Checked ListBox record '" & rid.ToString & "' was linked successfully.", False)
End If
End If
End If
End If
Catch ex As Exception