Add LookupGrid3 to Validator, Improve frmControl_Detail, Add Sequence, Validation

This commit is contained in:
Jonathan Jenne
2021-02-25 16:06:51 +01:00
parent 78fcfdb8f1
commit 4df3916c12
13 changed files with 1817 additions and 1594 deletions

View File

@@ -6,6 +6,7 @@ Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraEditors.NavigatorButtons
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.Grid
Imports DigitalData.Controls.LookupGrid
@@ -418,7 +419,7 @@ Public Class ClassControlCreator
If Not designMode Then
oView.OptionsBehavior.Editable = Not row.Item("READ_ONLY")
oView.OptionsBehavior.ReadOnly = row.Item("READ_ONLY")
ocontrol.UseEmbeddedNavigator = Not row.Item("READ_ONLY")
oControl.UseEmbeddedNavigator = Not row.Item("READ_ONLY")
If row.Item("VKT_ADD_ITEM") = True Then
oView.OptionsBehavior.AllowAddRows = DefaultBoolean.True
@@ -486,75 +487,70 @@ Public Class ClassControlCreator
oControl.DataSource = oDatatable
oControl.RefreshDataSource()
oControl.ForceInitialize()
'Try
' For Each oRow As DataRow In DT_MY_COLUMNS.Rows
' Dim o = oRow.Item("SPALTENNAME")
' Dim p = oRow.Item("SPALTENBREITE")
' Dim ocount = oView.Columns.Count
' If oRow.Item("FORMATSTRING") <> String.Empty Then
' Select Case oRow.Item("FORMATSTRING")
' Case "c2"
' Dim colModelPrice As Columns.GridColumn = oView.Columns(oRow.Item("SPALTENNAME"))
' colModelPrice.DisplayFormat.FormatType = FormatType.Numeric
' colModelPrice.DisplayFormat.FormatString = "c2"
' End Select
' End If
' ' oGridView.Columns(oRow.Item("SPALTENNAME")).Width = oRow.Item("SPALTENBREITE")
' Next
'Catch ex As Exception
'End Try
AddHandler oView.CellValueChanged, AddressOf HandleCellValueChanged
AddHandler oView.CustomRowCellEdit, Sub(sender As Object, e As CustomRowCellEditEventArgs)
For Each oRow As DataRow In DT_MY_COLUMNS.Rows
If oRow.Item("SPALTENNAME") = e.Column.FieldName Then
If GridTables.ContainsKey(e.Column.FieldName) Then
Dim oComboboxDataTable As DataTable = GridTables.Item(e.Column.FieldName)
Dim oEditor As New RepositoryItemComboBox()
Dim oItems As New List(Of String)
AddHandler oEditor.Validating, Sub(_sender As ComboBoxEdit, _e As CancelEventArgs)
If oItems.Contains(_sender.EditValue) Then
_e.Cancel = False
Else
_e.Cancel = True
End If
If oRow.Item("ADVANCED_LOOKUP") Then
Dim oEditor = New RepositoryItemLookupControl3()
End Sub
For Each oRow2 As DataRow In oComboboxDataTable.Rows
Dim oValue = oRow2.Item(0)
oEditor.DataSource = oComboboxDataTable
oEditor.DisplayMember = oComboboxDataTable.Columns.Item(0).ColumnName
oEditor.ValueMember = oComboboxDataTable.Columns.Item(0).ColumnName
Try
oValue &= $" | {oRow2.Item(1)}"
Catch ex As Exception
End Try
e.RepositoryItem = oEditor
Else
Dim oEditor = New RepositoryItemComboBox()
Dim oItems As New List(Of String)
oEditor.Items.Add(oValue)
oItems.Add(oValue)
Next
AddHandler oEditor.Validating, Sub(_sender As ComboBoxEdit, _e As CancelEventArgs)
If oItems.Contains(_sender.EditValue) Then
_e.Cancel = False
Else
_e.Cancel = True
End If
e.RepositoryItem = oEditor
End Sub
For Each oRow2 As DataRow In oComboboxDataTable.Rows
Dim oValue = oRow2.Item(0)
Try
oValue &= $" | {oRow2.Item(1)}"
Catch ex As Exception
End Try
oEditor.Items.Add(oValue)
oItems.Add(oValue)
Next
e.RepositoryItem = oEditor
End If
End If
End If
Next
End Sub
AddHandler oView.ValidateRow, Sub(sender As Object, e As ValidateRowEventArgs)
Dim oRow As DataRowView = DirectCast(e.Row, DataRowView)
For Each oCol As DataColumn In oRow.DataView.Table.Columns
Dim oColumn As DataRow = (From r As DataRow In DT_MY_COLUMNS.Rows
Where r.Item("SPALTENNAME") = oCol.ColumnName
Select r).FirstOrDefault()
AddHandler oView.CellValueChanged, Sub(sender As Object, e As CellValueChangedEventArgs)
Dim oValue = e.Value.ToString()
Dim oView2 As GridView = TryCast(sender, GridView)
Dim oIsRequired = oColumn.Item("VALIDATION")
Dim oValue = oRow.Item(oCol.ColumnName)
If oValue.Contains(" | ") Then
oValue = oValue.Split(" | ").ToList().Item(0)
oView2.SetRowCellValue(e.RowHandle, e.Column, oValue)
End If
End Sub
If oIsRequired And (oValue Is Nothing OrElse oValue.ToString = "") Then
e.Valid = False
e.ErrorText = $"Spalte {oColumn.Item("SPALTEN_HEADER")} muss ausgefüllt werden!"
Exit For
End If
Next
End Sub
Return oControl
End Function
@@ -566,11 +562,15 @@ Public Class ClassControlCreator
Dim oCurrentDatasource As DataTable = oCurrentControl.DataSource
Dim oColumn = oCurrentDatasource.Columns.Item(e.Column.FieldName)
Dim foo = 1
Dim oValue = e.Value.ToString()
Dim oView2 As GridView = TryCast(sender, GridView)
If oValue.Contains(" | ") Then
oValue = oValue.Split(" | ").ToList().Item(0)
oView2.SetRowCellValue(e.RowHandle, e.Column, oValue)
End If
End Function
Public Shared Function CreateExistingLine(row As DataRow, designMode As Boolean) As LineLabel
Dim control As LineLabel = CreateBaseControl(New LineLabel(), row, designMode)
control.Text = "------------------------------"