From ab382c7fd0a1f24063d8ae106ad189eff6c9cf48 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Mon, 15 Mar 2021 13:36:07 +0100 Subject: [PATCH] Validation, More Lookup Grid Control Tweaks --- app/DD_PM_WINDREAM/ClassControlCreator.vb | 62 +++++++++++------------ app/DD_PM_WINDREAM/frmControl_Detail.resx | 3 -- app/DD_PM_WINDREAM/frmValidator.vb | 37 +++++++++----- 3 files changed, 56 insertions(+), 46 deletions(-) diff --git a/app/DD_PM_WINDREAM/ClassControlCreator.vb b/app/DD_PM_WINDREAM/ClassControlCreator.vb index 784bf8e..bf55378 100644 --- a/app/DD_PM_WINDREAM/ClassControlCreator.vb +++ b/app/DD_PM_WINDREAM/ClassControlCreator.vb @@ -547,37 +547,37 @@ Public Class ClassControlCreator Next End Sub - 'AddHandler oView.CellValueChanged, Sub(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs) - ' Console.WriteLine("") - ' End Sub - - 'AddHandler oView.ValidateRow, Sub(sender As Object, e As ValidateRowEventArgs) - ' Console.WriteLine("") - ' End Sub - - 'AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs) - ' Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle) - - ' 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 oIsRequired = oColumn.Item("VALIDATION") - ' Dim oValue As String = NotNull(e.Value, "") - - ' If oValue.contains(" | ") Then - ' oValue = oValue.Split(" | ").ToList().First() - ' e.Value = oValue - ' End If - - ' If oIsRequired And oValue = "" Then - ' e.Valid = False - ' e.ErrorText = $"Spalte {oColumn.Item("SPALTEN_HEADER")} muss ausgefüllt werden!" - ' Exit For - ' End If - ' Next - ' End Sub + AddHandler oView.ValidateRow, Sub(sender As Object, e As ValidateRowEventArgs) + Dim oRow As DataRowView = oView.GetRow(oView.FocusedRowHandle) + + 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 oIsRequired = oColumn.Item("VALIDATION") + Dim oValue = NotNull(oView.GetRowCellValue(e.RowHandle, oCol.ColumnName), "") + + If oIsRequired And oValue = "" Then + e.Valid = False + e.ErrorText = $"Spalte {oColumn.Item("SPALTEN_HEADER")} muss ausgefüllt werden!" + Exit For + End If + Next + End Sub + + AddHandler oView.InvalidRowException, Sub(sender As Object, e As InvalidRowExceptionEventArgs) + e.ExceptionMode = ExceptionMode.DisplayError + End Sub + + AddHandler oView.ValidatingEditor, Sub(sender As Object, e As BaseContainerValidateEditorEventArgs) + Dim oValue As String = NotNull(e.Value, "") + + If oValue.Contains(" | ") Then + oValue = oValue.Split(" | ").ToList().First() + e.Value = oValue + End If + End Sub Return oControl End Function diff --git a/app/DD_PM_WINDREAM/frmControl_Detail.resx b/app/DD_PM_WINDREAM/frmControl_Detail.resx index 3a387de..00fd422 100644 --- a/app/DD_PM_WINDREAM/frmControl_Detail.resx +++ b/app/DD_PM_WINDREAM/frmControl_Detail.resx @@ -529,9 +529,6 @@ 18 - - False - 24, 455 diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index 0e663bd..e34fbbb 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -3665,23 +3665,36 @@ Public Class frmValidator btnSave.Enabled = False ' TODO: Use when working on Validation - 'Dim oGrids = (From oControl In pnldesigner.Controls - ' Where TypeOf oControl Is GridControl - ' Select oControl).ToList() + Dim oValidation As Boolean = True + Dim oGrids = (From oControl In pnldesigner.Controls + Where TypeOf oControl Is GridControl + Select oControl).ToList() - 'For Each oGrid As GridControl In oGrids - ' Dim oView As GridView = oGrid.MainView + For Each oGrid As GridControl In oGrids + Dim oView As GridView = oGrid.MainView - ' For index = 0 To oView.RowCount - 1 - ' oView.FocusedRowHandle = index - ' oView.UpdateCurrentRow() - ' Next + If oView.RowCount = 0 Then + Continue For + End If - 'Next + For index = 0 To oView.RowCount - 1 + oView.FocusedRowHandle = index - 'Return + If oView.UpdateCurrentRow() = False Then + oValidation = False + Exit For + End If + Next + + If oValidation = False Then + Exit For + End If + Next + + If oValidation = True Then + Finish_WFStep() + End If - Finish_WFStep() btnSave.Enabled = True End Sub Private Function btnFinish_continue()