jj 14.03 add props for dgv, new value structure for clb
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
If IsNothing(staticList) Or String.IsNullOrWhiteSpace(staticList) Then
|
||||
Return Nothing
|
||||
Else
|
||||
Return New List(Of String)(staticList.Split(";"))
|
||||
Return New List(Of String)(staticList.Split(";").ToArray())
|
||||
End If
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in CheckForStaticList: " & vbNewLine & ex.Message)
|
||||
@@ -74,7 +74,7 @@
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Shared Function GetSqlList(controlId As Integer, formId As Integer, connection_Id As Object, sqlCommand As String)
|
||||
Public Shared Function GetSqlList(controlId As Integer, formId As Integer, connection_Id As Object, sqlCommand As String) As DataTable
|
||||
Try
|
||||
If sqlCommand Is Nothing Or sqlCommand = String.Empty Then
|
||||
Return Nothing
|
||||
@@ -178,6 +178,10 @@
|
||||
control.DataSource = dt
|
||||
End Sub
|
||||
|
||||
Overloads Shared Sub SetDataSource(control As Windows.Forms.DataGridView, dt As DataTable)
|
||||
control.DataSource = dt
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Structure DynamicValue
|
||||
@@ -333,13 +337,11 @@
|
||||
|
||||
Public Class CheckedListBox : Inherits _ListControl
|
||||
|
||||
Public Shared Sub LoadValue(control As DevExpress.XtraEditors.CheckedListBoxControl, value As String)
|
||||
If IsNothing(value) Then
|
||||
Public Shared Sub LoadValue(control As DevExpress.XtraEditors.CheckedListBoxControl, values As List(Of Object))
|
||||
If IsNothing(values) Then
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim values() As String = value.Split(";")
|
||||
|
||||
For Each v As String In values
|
||||
Dim pos = control.FindStringExact(v)
|
||||
If pos >= 0 Then
|
||||
@@ -391,4 +393,26 @@
|
||||
|
||||
End Class
|
||||
|
||||
Public Class DataGridView : Inherits _ListControl
|
||||
|
||||
Public Shared Sub LoadList(control As Windows.Forms.DataGridView, formId As Integer, ConnId As Object, SQLCommand As String)
|
||||
Dim controlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
|
||||
Dim dynamic As DynamicValue = GetDynamicValue(DirectCast(control.Tag, ClassControlMetadata).Id, formId, ConnId, SQLCommand)
|
||||
|
||||
' SQLCommand ignorieren
|
||||
If dynamic.StaticList IsNot Nothing Then
|
||||
Dim bindingSource As New BindingSource()
|
||||
|
||||
For Each item As String In dynamic.StaticList
|
||||
bindingSource.Add(item)
|
||||
Next
|
||||
|
||||
'control.DataSource = dynamic.StaticList
|
||||
control.DataSource = bindingSource
|
||||
End If
|
||||
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
|
||||
@@ -399,6 +399,31 @@ Module ClassControlProperties
|
||||
|
||||
Public Class DataGridViewProperties
|
||||
Inherits CommonProperties
|
||||
|
||||
Private _show_column As Boolean
|
||||
Private _static_list As String
|
||||
|
||||
<LocalizedCategoryAttribute("category_view")>
|
||||
<LocalizedDescriptionAttribute("desc_showcolumn")>
|
||||
Public Property ShowColumn() As Boolean
|
||||
Get
|
||||
Return _show_column
|
||||
End Get
|
||||
Set(value As Boolean)
|
||||
_show_column = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
<LocalizedCategoryAttribute("category_data")>
|
||||
<LocalizedDescriptionAttribute("desc_staticlist")>
|
||||
Public Property StaticList() As String
|
||||
Get
|
||||
Return _static_list
|
||||
End Get
|
||||
Set(value As String)
|
||||
_static_list = value
|
||||
End Set
|
||||
End Property
|
||||
End Class
|
||||
Public Class PictureBoxProperties
|
||||
Inherits CommonProperties
|
||||
|
||||
@@ -159,15 +159,15 @@ Public Class ClassControlValues
|
||||
Dim ControlId As Integer = DirectCast(control.Tag, ClassControlMetadata).Id
|
||||
|
||||
' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt
|
||||
Dim value = (From row In DT_ControlValues.AsEnumerable()
|
||||
Dim values As List(Of Object) = (From row In DT_ControlValues.AsEnumerable()
|
||||
Where row.Item("CONTROL_ID") = ControlId
|
||||
Select row.Item("VALUE")).FirstOrDefault()
|
||||
Select row.Item("VALUE")).ToList()
|
||||
|
||||
If TypeOf control Is GroupBox Then
|
||||
Dim groupbox As GroupBox = DirectCast(control, GroupBox)
|
||||
LoadControlValues(RecordId, ParentRecordId, FormId, groupbox.Controls)
|
||||
Else
|
||||
LoadControlValue(RecordId, ParentRecordId, ControlId, control, value)
|
||||
LoadControlValue(RecordId, ParentRecordId, ControlId, control, values)
|
||||
End If
|
||||
|
||||
Next
|
||||
@@ -178,8 +178,15 @@ Public Class ClassControlValues
|
||||
|
||||
End Sub
|
||||
|
||||
Private Shared Sub LoadControlValue(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, value As Object)
|
||||
Private Shared Sub LoadControlValue(recordId As Integer, parentRecordId As Integer, controlId As Integer, control As Control, values As List(Of Object))
|
||||
Try
|
||||
' Für die meisten Controls wird nur das erste Element der Liste benötigt
|
||||
Dim value As String = Nothing
|
||||
|
||||
If values.Count > 0 Then
|
||||
value = values.Item(0)
|
||||
End If
|
||||
|
||||
Select Case control.GetType()
|
||||
Case GetType(TextBox)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValueNeu - GetType(TextBox) ", False)
|
||||
@@ -219,7 +226,7 @@ Public Class ClassControlValues
|
||||
Case GetType(DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValueNeu - GetType(CheckedListBoxControl) ", False)
|
||||
Dim checkedlistbox As DevExpress.XtraEditors.CheckedListBoxControl = DirectCast(control, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, value)
|
||||
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, values)
|
||||
|
||||
Case GetType(PictureBox)
|
||||
If LogErrorsOnly = False Then ClassLogger.Add(">> Sub LoadControlValueNeu - GetType(PictureBox) ", False)
|
||||
@@ -290,6 +297,11 @@ Public Class ClassControlValues
|
||||
Dim chlistbox = DirectCast(Ctrl, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
ControlLoader.CheckedListBox.LoadList(chlistbox, FormID, ConnID, sqlcommand)
|
||||
|
||||
Case GetType(DataGridView)
|
||||
Dim gridview = DirectCast(Ctrl, DataGridView)
|
||||
Dim noSQL As String = ""
|
||||
ControlLoader.DataGridView.LoadList(gridview, FormID, ConnID, noSQL)
|
||||
|
||||
End Select
|
||||
|
||||
swcontrol.Stop()
|
||||
|
||||
Reference in New Issue
Block a user