jj 08.06 gridviewcheckable

This commit is contained in:
JenneJ
2016-06-08 15:09:58 +02:00
parent 9920ffe9e6
commit 6a13690465
3 changed files with 51 additions and 86 deletions

View File

@@ -218,46 +218,14 @@ Public Class ClassControlBuilder
' Jetzt wird das SQL Command ausgeführt, es MUSS einen Boolschen Wert zurückgeben, True, False, 0, 1
Dim dt As DataTable = ClassDatabase.Return_Datatable(sqlcommand)
Dim type = dependingControl.GetType().Name
If dt.Rows.Count = 1 Then
' Jetzt können wir das dependingControl enablen/disablen
Select Case type
Case "DateEdit"
Try
Dim enabled As Boolean = CBool(dt.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(dt.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(dt.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(dt.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
If dt.Rows.Count = 1 Then
Dim enabled As Boolean = CBool(dt.Rows(0).Item(0))
dependingControl.Enabled = enabled
Else
ClassLogger.Add(" >> Attention: RowCount for enabling control was '" & dt.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & sqlcommand & "'")
End If
End If
Next
Catch ex As Exception
@@ -290,6 +258,8 @@ Public Class ClassControlBuilder
DirectCast(dependingControl, Label).Text = ""
Case "TextBox"
DirectCast(dependingControl, TextBox).Text = ""
Case "GridControl"
DirectCast(dependingControl, DevExpress.XtraGrid.GridControl).DataSource = Nothing
End Select
Next
@@ -368,7 +338,7 @@ Public Class ClassControlBuilder
ClassLogger.Add("Unexpected Error in converting Value '" & value & "' to date - Control-ID: " & dependingControlId.ToString & "- Error: " & ex.Message)
Continue For
End Try
ControlLoader.DateTimePicker.LoadValue(dependingControl, dateValue)
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)
@@ -399,15 +369,18 @@ Public Class ClassControlBuilder
Case "CustomComboBox"
ControlLoader.Combobox.SetDataSource(DirectCast(dependingControl, CustomComboBox), dt)
Case "CheckedListBoxControl"
ControlLoader.CheckedListBox.SetDataSource(DirectCast(dependingControl, DevExpress.XtraEditors.CheckedListBoxControl), dt)
'Hier werden nun evtl schon gesetzte Werte für CheckedListBox angehakt
Dim checkedlistbox = DirectCast(dependingControl, DevExpress.XtraEditors.CheckedListBoxControl)
ControlLoader.CheckedListBox.SetDataSource(checkedlistbox, dt)
' Hier werden nun evtl schon gesetzte Werte für CheckedListBox angehakt
' Wert per LINQ aus DT_ControlValues suchen der zur aktuellen controlId passt
Dim values As List(Of Object) = (From row1 In CURRENT_CONTROL_VALUES.AsEnumerable()
Where row1.Item("CONTROL_ID") = dependingControlId
Select row1.Item("VALUE")).ToList()
ClassControlValues.LoadControlValue(CURRENT_RECORD_ID, CURRENT_PARENT_RECORD_ID, dependingControlId, dependingControl, values, CURRENT_FORM_ID)
'ClassControlValues.LoadControlValue(CURRENT_RECORD_ID, CURRENT_PARENT_RECORD_ID, dependingControlId, dependingControl, values, CURRENT_FORM_ID)
ControlLoader.CheckedListBox.LoadValue(checkedlistbox, values)
Case "Label"
If dt.Rows.Count = 1 Then
@@ -448,6 +421,15 @@ Public Class ClassControlBuilder
Else
ClassLogger.Add(" >> Attention: RowCount for depending control was '" & dt.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & sqlcommand & "'")
End If
Case "GridControl"
Dim gridControl = DirectCast(dependingControl, DevExpress.XtraGrid.GridControl)
ControlLoader.DataGridViewCheckable.SetDataSource(gridControl, dt)
Dim values As List(Of Object) = (From row1 In CURRENT_CONTROL_VALUES.AsEnumerable()
Where row1.Item("CONTROL_ID") = dependingControlId
Select row1.Item("VALUE")).ToList()
ControlLoader.DataGridViewCheckable.LoadValue(gridControl, values)
End Select