HandleControlValueChange for all controls, Validate Grid values on a per-cell basis, add clipboard functions to validator grids, add GUIs.Common reference
This commit is contained in:
@@ -11,6 +11,7 @@ Imports DevExpress.XtraGrid.Columns
|
||||
Imports DevExpress.XtraGrid.Views.Base
|
||||
Imports DevExpress.XtraGrid.Views.Grid
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.GUIs.Common
|
||||
|
||||
Public Class ClassControlCreator
|
||||
|
||||
@@ -422,6 +423,9 @@ Public Class ClassControlCreator
|
||||
oView.OptionsView.ShowGroupPanel = False
|
||||
oControl.ContextMenu = Nothing
|
||||
|
||||
Dim oGridBuilder As New GridBuilder(oView)
|
||||
oGridBuilder.WithClipboardHandler()
|
||||
|
||||
If Not designMode Then
|
||||
oView.OptionsBehavior.Editable = Not row.Item("READ_ONLY")
|
||||
oView.OptionsBehavior.ReadOnly = row.Item("READ_ONLY")
|
||||
@@ -537,68 +541,27 @@ Public Class ClassControlCreator
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
AddHandler oView.ValidateRow, Sub(sender As Object, e As ValidateRowEventArgs)
|
||||
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
|
||||
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
|
||||
Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle)
|
||||
Dim oColumnName = oView.FocusedColumn.FieldName
|
||||
|
||||
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()
|
||||
|
||||
Dim oGridColumn As GridColumn = (From c As GridColumn In oView.Columns
|
||||
Where c.FieldName = oCol.ColumnName
|
||||
Select c).FirstOrDefault()
|
||||
|
||||
Dim oIsRequired = oColumn.Item("VALIDATION")
|
||||
Dim oValue = NotNull(oView.GetRowCellValue(e.RowHandle, oCol.ColumnName), "")
|
||||
|
||||
Try
|
||||
Dim oRegex = NotNull(oColumn.Item("REGEX_MATCH"), String.Empty)
|
||||
Dim oRegexMessage = NotNull(oColumn.Item("REGEX_MESSAGE_DE"), String.Empty)
|
||||
If oRegex <> String.Empty Then
|
||||
Dim oMatch = New Regex(oRegex).IsMatch(oValue)
|
||||
Dim oDefaultMessage = "Wert entspricht nicht dem gefordertem Format!"
|
||||
Dim oMessage = IIf(oRegexMessage <> String.Empty, oRegexMessage, oDefaultMessage)
|
||||
|
||||
If oMatch = False Then
|
||||
oView.SetColumnError(oGridColumn, oMessage)
|
||||
e.Valid = False
|
||||
Exit For
|
||||
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
|
||||
If oIsRequired And oValue = "" Then
|
||||
oView.SetColumnError(oGridColumn, "Spalte muss ausgefüllt werden!")
|
||||
e.Valid = False
|
||||
Exit For
|
||||
|
||||
End If
|
||||
Next
|
||||
End Sub
|
||||
GridTables_ValidateColumn(oView, DT_MY_COLUMNS, oColumnName, e.Value, e.Valid, e.ErrorText)
|
||||
End Sub
|
||||
|
||||
AddHandler oView.InvalidRowException, Sub(sender As Object, e As InvalidRowExceptionEventArgs)
|
||||
e.ExceptionMode = ExceptionMode.NoAction
|
||||
End Sub
|
||||
|
||||
|
||||
AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs)
|
||||
Dim oValue As String = NotNull(e.Value, "")
|
||||
|
||||
'MsgBox(oValue)
|
||||
|
||||
If oValue.Contains(" | ") Then
|
||||
oValue = oValue.Split(" | ").ToList().First()
|
||||
e.Value = oValue
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
'oView.FocusInvalidRow()
|
||||
|
||||
|
||||
Return oControl
|
||||
End Function
|
||||
|
||||
@@ -798,6 +761,46 @@ Public Class ClassControlCreator
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Shared Sub GridTables_HandleControlValueChange(pControlPanel As Panel, pColumnsWithSqlAndControlPlaceholders As DataTable)
|
||||
If Not IsNothing(pColumnsWithSqlAndControlPlaceholders) AndAlso pColumnsWithSqlAndControlPlaceholders.Rows.Count > 0 Then
|
||||
For Each oRow As DataRow In pColumnsWithSqlAndControlPlaceholders.Rows
|
||||
Try
|
||||
Dim oControlId = oRow.Item("CONTROL_ID")
|
||||
Dim oSqlStatement = oRow.Item("SQL_COMMAND")
|
||||
Dim oConnectionId = oRow.Item("CONNECTION_ID")
|
||||
Dim oColumnName = oRow.Item("SPALTENNAME")
|
||||
Dim oAdvancedLookup = oRow.Item("ADVANCED_LOOKUP")
|
||||
|
||||
If Not IsDBNull(oSqlStatement) And Not IsDBNull(oSqlStatement) Then
|
||||
oSqlStatement = clsPatterns.ReplaceAllValues(oSqlStatement, pControlPanel, True)
|
||||
|
||||
ClassControlCreator.GridTables_CacheDatatableForColumn(oControlId, oColumnName, oSqlStatement, oConnectionId, oAdvancedLookup)
|
||||
|
||||
|
||||
' === Block to force setting the editor for GridColumns
|
||||
For Each oControl As Control In pControlPanel.Controls
|
||||
Try
|
||||
Dim oMeta = DirectCast(oControl.Tag, ClassControlCreator.ControlMetadata)
|
||||
If oMeta.Guid = oControlId AndAlso TypeOf oControl Is GridControl Then
|
||||
Dim oGrid As GridControl = DirectCast(oControl, GridControl)
|
||||
DirectCast(oGrid.FocusedView, GridView).FocusInvalidRow()
|
||||
Exit For
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
Next
|
||||
' === End
|
||||
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
LOGGER.Info("Unexpected Error in Display SQL result for grid column: " & oRow.Item("CONTROL_ID") & " - ERROR: " & ex.Message)
|
||||
End Try
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Shared Function GridTables_TestEditorExistsByControlAndColumn(oControlId As Integer, pColumn As String) As Boolean
|
||||
If GridTables.ContainsKey(oControlId) Then
|
||||
Dim oContainsKey = GridTables.Item(oControlId).ContainsKey(pColumn)
|
||||
@@ -811,4 +814,43 @@ Public Class ClassControlCreator
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Shared Function GridTables_ValidateColumn(pView As GridView, pColumnDefinition As DataTable, ColumnName As String, pValue As Object, ByRef pIsValid As Boolean, ByRef pErrorText As String) As Boolean
|
||||
Dim oColumn As DataRow = (From r As DataRow In pColumnDefinition.Rows
|
||||
Where r.Item("SPALTENNAME") = ColumnName
|
||||
Select r).FirstOrDefault()
|
||||
|
||||
Dim oGridColumn As GridColumn = (From c As GridColumn In pView.Columns
|
||||
Where c.FieldName = ColumnName
|
||||
Select c).FirstOrDefault()
|
||||
|
||||
Dim oIsRequired = oColumn.Item("VALIDATION")
|
||||
|
||||
Try
|
||||
Dim oRegex = NotNull(oColumn.Item("REGEX_MATCH"), String.Empty)
|
||||
Dim oRegexMessage = NotNull(oColumn.Item("REGEX_MESSAGE_DE"), String.Empty)
|
||||
If oRegex <> String.Empty Then
|
||||
Dim oMatch = New Regex(oRegex).IsMatch(pValue.ToString)
|
||||
Dim oDefaultMessage = "Wert entspricht nicht dem gefordertem Format!"
|
||||
Dim oMessage = IIf(oRegexMessage <> String.Empty, oRegexMessage, oDefaultMessage)
|
||||
|
||||
If oMatch = False Then
|
||||
pErrorText = oMessage
|
||||
pIsValid = False
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LOGGER.Error(ex)
|
||||
End Try
|
||||
|
||||
If oIsRequired And pValue.ToString = "" Then
|
||||
pErrorText = "Spalte muss ausgefüllt werden!"
|
||||
pIsValid = False
|
||||
Return False
|
||||
|
||||
End If
|
||||
|
||||
Return True
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user