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
|
||||
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
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
@ -110,20 +110,27 @@
|
||||
End Function
|
||||
|
||||
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 rowCount As Integer = dt.Rows.Count
|
||||
|
||||
control.BeginUpdate()
|
||||
|
||||
' Damit beim Setzen von DisplayMember und ValueMember kein Fehler auftritt,
|
||||
' muss die Datasource zunächst geleert werden und der selected index auf -1 gesetzt werden.
|
||||
' Zuerst die Datasource leeren und neu setzen
|
||||
control.DataSource = Nothing
|
||||
|
||||
' Als letztes setzen wir die DataSource
|
||||
control.DataSource = dt
|
||||
control.EndUpdate()
|
||||
sw.Stop()
|
||||
' Console.WriteLine("SetDataSource for {0} took {1}ms", control.Name, sw.ElapsedMilliseconds)
|
||||
|
||||
' Wir müssen PopulateColumns und RefreshData nach dem Setzen der Datasource aufrufen
|
||||
' ansonsten wird das Grid leer bleiben und die neuen Daten nicht anzeigen
|
||||
control.MainView.PopulateColumns()
|
||||
control.MainView.RefreshData()
|
||||
|
||||
'Jetzt noch den Columnname ändern
|
||||
Dim gridview = DirectCast(control.MainView, DevExpress.XtraGrid.Views.Grid.GridView)
|
||||
|
||||
Dim caption As String = ClassDatabase.Execute_Scalar(String.Format("SELECT COL_NAME FROM TBPMO_CONTROL WHERE GUID = {0}", DirectCast(control.Tag, ClassControlMetadata).Id))
|
||||
gridview.Columns(0).Caption = caption
|
||||
Catch ex As Exception
|
||||
MsgBox("Error in SetDataSource - GridControl: " & ex.Message, MsgBoxStyle.Critical)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Overloads Shared Sub SetDataSource(control As CustomComboBox, dt As DataTable)
|
||||
|
||||
@ -444,6 +444,10 @@ Public Class ClassControlValues
|
||||
Dim chlistbox = DirectCast(Ctrl, DevExpress.XtraEditors.CheckedListBoxControl)
|
||||
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
|
||||
|
||||
PerfomanceHelper.ResumeDraw(Ctrl)
|
||||
@ -460,7 +464,8 @@ Public Class ClassControlValues
|
||||
|
||||
|
||||
''' <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>
|
||||
''' <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)
|
||||
@ -523,42 +528,13 @@ Public Class ClassControlValues
|
||||
DependingControlSQL = regex.Replace(DependingControlSQL, value)
|
||||
|
||||
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))
|
||||
If dt.Rows.Count = 1 Then
|
||||
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(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
|
||||
|
||||
|
||||
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
|
||||
Next
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user