EDMIService: WIP
This commit is contained in:
137
GUIs.ZooFlow/Globix/ClassValidator.vb
Normal file
137
GUIs.ZooFlow/Globix/ClassValidator.vb
Normal file
@@ -0,0 +1,137 @@
|
||||
Imports DigitalData.Controls.LookupGrid
|
||||
Imports DigitalData.GUIs.ZooFlow.Base
|
||||
Imports DigitalData.GUIs.ZooFlow.frmGlobix_Index
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ClassValidator
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly Client As Client
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pClient As Client)
|
||||
MyBase.New(pLogConfig)
|
||||
Client = pClient
|
||||
End Sub
|
||||
|
||||
Private Function TestIsIndexOptional(pDocType As DocType, pIndexName As String) As Boolean
|
||||
Dim oIsOptional As Boolean = My.Helpers.GetValueFromDatatable(
|
||||
My.Application.Globix.CURR_DT_MAN_INDEXE,
|
||||
$"DOK_ID = {pDocType.Guid} AND INDEXNAME = '{pIndexName}'", "OPTIONAL", "")
|
||||
|
||||
Return oIsOptional
|
||||
End Function
|
||||
|
||||
Private Sub ShowValidationMessage()
|
||||
MsgBox(ClassStrings.TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, ClassStrings.TITLE_MISSING_INPUT)
|
||||
End Sub
|
||||
|
||||
Function ValidateControls(pControls As ControlCollection, pDocType As DocType) As Boolean
|
||||
Try
|
||||
Logger.Debug("Starting [ValidateControls]")
|
||||
Dim result As Boolean = True
|
||||
|
||||
For Each oControl As Control In pControls
|
||||
|
||||
' ========================= TEXT BOX =========================
|
||||
If oControl.Name.StartsWith("txt") Then
|
||||
Dim oTextBox As DevExpress.XtraEditors.TextEdit = oControl
|
||||
If oTextBox.Text = "" Then
|
||||
Dim oIndexName = Replace(oTextBox.Name, "txt", "")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
ShowValidationMessage()
|
||||
oTextBox.Focus()
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
' ========================= LOOKUP =========================
|
||||
If oControl.Name.StartsWith("cmbMulti") Then
|
||||
Dim oLookup = DirectCast(oControl, LookupControl3)
|
||||
Dim oValues As List(Of String) = oLookup.Properties.SelectedValues
|
||||
|
||||
If oValues.Count = 0 Then
|
||||
Dim oIndexName = Replace(oLookup.Name, "cmbMulti", "")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
ShowValidationMessage()
|
||||
oLookup.Focus()
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
' ========================= COMBO BOX =========================
|
||||
If oControl.Name.StartsWith("cmbSingle") Then
|
||||
Dim cmbSingle As TextBox = oControl
|
||||
|
||||
If cmbSingle.Text = "" Then
|
||||
Dim oIndexName = Replace(cmbSingle.Name, "cmbSingle", "")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
ShowValidationMessage()
|
||||
cmbSingle.Focus()
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
If oControl.Name.StartsWith("cmb") Then
|
||||
Dim cmb As ComboBox = oControl
|
||||
If cmb.Text = "" Then
|
||||
Dim oIndexName = Replace(cmb.Name, "cmb", "")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
ShowValidationMessage()
|
||||
cmb.Focus()
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
' ========================= DATE PICKER =========================
|
||||
If oControl.Name.StartsWith("dtp") Then
|
||||
Dim dtp As DevExpress.XtraEditors.DateEdit = oControl
|
||||
Dim oIndexName As String = Replace(dtp.Name, "dtp", "")
|
||||
|
||||
If dtp.Text = String.Empty Then
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
ShowValidationMessage()
|
||||
dtp.Focus()
|
||||
Return False
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
|
||||
' ========================= CHECK BOX =========================
|
||||
If oControl.Name.StartsWith("chk") Then
|
||||
Dim chk As CheckBox = oControl
|
||||
'result = True
|
||||
End If
|
||||
|
||||
'If TypeOf (oControl) Is Button Then
|
||||
' Continue For
|
||||
'End If
|
||||
|
||||
'If oControl.Name.StartsWith("lbl") = False And result = False Then
|
||||
' Logger.Info("Die Überprüfung der manuellen Indices ist fehlerhaft. Bitte informieren Sie den Systembetreuer")
|
||||
' Return False
|
||||
'End If
|
||||
Next
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Unvorhergesehener Fehler in ValidateControls")
|
||||
Logger.Error(ex.Message)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
Reference in New Issue
Block a user