jj 08.06 gridviewcheckable
This commit is contained in:
parent
9920ffe9e6
commit
6a13690465
@ -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
|
' 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 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
|
Else
|
||||||
ClassLogger.Add(" >> Attention: RowCount for enabling control was '" & dt.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & sqlcommand & "'")
|
ClassLogger.Add(" >> Attention: RowCount for enabling control was '" & dt.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & sqlcommand & "'")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
@ -290,6 +258,8 @@ Public Class ClassControlBuilder
|
|||||||
DirectCast(dependingControl, Label).Text = ""
|
DirectCast(dependingControl, Label).Text = ""
|
||||||
Case "TextBox"
|
Case "TextBox"
|
||||||
DirectCast(dependingControl, TextBox).Text = ""
|
DirectCast(dependingControl, TextBox).Text = ""
|
||||||
|
Case "GridControl"
|
||||||
|
DirectCast(dependingControl, DevExpress.XtraGrid.GridControl).DataSource = Nothing
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
Next
|
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)
|
ClassLogger.Add("Unexpected Error in converting Value '" & value & "' to date - Control-ID: " & dependingControlId.ToString & "- Error: " & ex.Message)
|
||||||
Continue For
|
Continue For
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
ControlLoader.DateTimePicker.LoadValue(dependingControl, dateValue)
|
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 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)
|
Dim id = ClassDatabase.Execute_Scalar(sql1)
|
||||||
@ -399,15 +369,18 @@ Public Class ClassControlBuilder
|
|||||||
Case "CustomComboBox"
|
Case "CustomComboBox"
|
||||||
ControlLoader.Combobox.SetDataSource(DirectCast(dependingControl, CustomComboBox), dt)
|
ControlLoader.Combobox.SetDataSource(DirectCast(dependingControl, CustomComboBox), dt)
|
||||||
Case "CheckedListBoxControl"
|
Case "CheckedListBoxControl"
|
||||||
ControlLoader.CheckedListBox.SetDataSource(DirectCast(dependingControl, DevExpress.XtraEditors.CheckedListBoxControl), dt)
|
Dim checkedlistbox = DirectCast(dependingControl, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||||
'Hier werden nun evtl schon gesetzte Werte für CheckedListBox angehakt
|
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
|
' 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()
|
Dim values As List(Of Object) = (From row1 In CURRENT_CONTROL_VALUES.AsEnumerable()
|
||||||
Where row1.Item("CONTROL_ID") = dependingControlId
|
Where row1.Item("CONTROL_ID") = dependingControlId
|
||||||
Select row1.Item("VALUE")).ToList()
|
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"
|
Case "Label"
|
||||||
If dt.Rows.Count = 1 Then
|
If dt.Rows.Count = 1 Then
|
||||||
@ -448,6 +421,15 @@ Public Class ClassControlBuilder
|
|||||||
Else
|
Else
|
||||||
ClassLogger.Add(" >> Attention: RowCount for depending control was '" & dt.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & sqlcommand & "'")
|
ClassLogger.Add(" >> Attention: RowCount for depending control was '" & dt.Rows.Count.ToString & "' and not 1 as expected - Check SQL: '" & sqlcommand & "'")
|
||||||
End If
|
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
|
End Select
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -110,20 +110,27 @@
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
Overloads Shared Sub SetDataSource(control As DevExpress.XtraGrid.GridControl, dt As DataTable)
|
Overloads Shared Sub SetDataSource(control As DevExpress.XtraGrid.GridControl, dt As DataTable)
|
||||||
Dim sw As Stopwatch = Stopwatch.StartNew()
|
Try
|
||||||
Dim columnCount As Integer = dt.Columns.Count
|
Dim columnCount As Integer = dt.Columns.Count
|
||||||
|
Dim rowCount As Integer = dt.Rows.Count
|
||||||
|
|
||||||
control.BeginUpdate()
|
' Zuerst die Datasource leeren und neu setzen
|
||||||
|
control.DataSource = Nothing
|
||||||
|
control.DataSource = dt
|
||||||
|
|
||||||
' Damit beim Setzen von DisplayMember und ValueMember kein Fehler auftritt,
|
' Wir müssen PopulateColumns und RefreshData nach dem Setzen der Datasource aufrufen
|
||||||
' muss die Datasource zunächst geleert werden und der selected index auf -1 gesetzt werden.
|
' ansonsten wird das Grid leer bleiben und die neuen Daten nicht anzeigen
|
||||||
control.DataSource = Nothing
|
control.MainView.PopulateColumns()
|
||||||
|
control.MainView.RefreshData()
|
||||||
|
|
||||||
' Als letztes setzen wir die DataSource
|
'Jetzt noch den Columnname ändern
|
||||||
control.DataSource = dt
|
Dim gridview = DirectCast(control.MainView, DevExpress.XtraGrid.Views.Grid.GridView)
|
||||||
control.EndUpdate()
|
|
||||||
sw.Stop()
|
Dim caption As String = ClassDatabase.Execute_Scalar(String.Format("SELECT COL_NAME FROM TBPMO_CONTROL WHERE GUID = {0}", DirectCast(control.Tag, ClassControlMetadata).Id))
|
||||||
' Console.WriteLine("SetDataSource for {0} took {1}ms", control.Name, sw.ElapsedMilliseconds)
|
gridview.Columns(0).Caption = caption
|
||||||
|
Catch ex As Exception
|
||||||
|
MsgBox("Error in SetDataSource - GridControl: " & ex.Message, MsgBoxStyle.Critical)
|
||||||
|
End Try
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Overloads Shared Sub SetDataSource(control As CustomComboBox, dt As DataTable)
|
Overloads Shared Sub SetDataSource(control As CustomComboBox, dt As DataTable)
|
||||||
|
|||||||
@ -444,6 +444,10 @@ Public Class ClassControlValues
|
|||||||
Dim chlistbox = DirectCast(Ctrl, DevExpress.XtraEditors.CheckedListBoxControl)
|
Dim chlistbox = DirectCast(Ctrl, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||||
ControlLoader.CheckedListBox.LoadList(chlistbox, FormId, connID, sqlcommand)
|
ControlLoader.CheckedListBox.LoadList(chlistbox, FormId, connID, sqlcommand)
|
||||||
|
|
||||||
|
Case GetType(DevExpress.XtraGrid.GridControl)
|
||||||
|
Dim gridControl = DirectCast(Ctrl, DevExpress.XtraGrid.GridControl)
|
||||||
|
ControlLoader.DataGridViewCheckable.LoadList(gridControl, FormId, connID, sqlcommand)
|
||||||
|
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
PerfomanceHelper.ResumeDraw(Ctrl)
|
PerfomanceHelper.ResumeDraw(Ctrl)
|
||||||
@ -460,7 +464,8 @@ Public Class ClassControlValues
|
|||||||
|
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
''' Sucht alle Controls in der aktuellen Entität, die eine Abhängigkeit besitzen
|
''' Sucht alle Controls in der aktuellen Entität, die eine Abhängigkeit besitzen,
|
||||||
|
''' und (de)aktiviert sie basierend auf dem Wert er Abhängigkeit
|
||||||
''' </summary>
|
''' </summary>
|
||||||
''' <remarks></remarks>
|
''' <remarks></remarks>
|
||||||
Public Shared Sub Enable_Depending_Controls(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection, entity_ID As Integer)
|
Public Shared Sub Enable_Depending_Controls(FormId As Integer, RecordId As Integer, ParentRecordId As Integer, controls As Control.ControlCollection, entity_ID As Integer)
|
||||||
@ -523,42 +528,13 @@ Public Class ClassControlValues
|
|||||||
DependingControlSQL = regex.Replace(DependingControlSQL, value)
|
DependingControlSQL = regex.Replace(DependingControlSQL, value)
|
||||||
|
|
||||||
Dim enableDT As DataTable = ClassDatabase.Return_Datatable(DependingControlSQL)
|
Dim enableDT As DataTable = ClassDatabase.Return_Datatable(DependingControlSQL)
|
||||||
Dim type = DependingControl.GetType().Name
|
|
||||||
|
|
||||||
' Jetzt wird basierend auf dem Ergebnis das DependingControl aktiviert/deaktiviert
|
|
||||||
Select Case type
|
|
||||||
Case "DateEdit"
|
|
||||||
Try
|
|
||||||
Dim enabled As Boolean = CBool(enableDT.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(enableDT.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(enableDT.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(enableDT.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: '" & DependingControlSQL & "'")
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user