EDMIService: sEcond working version
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
Imports DigitalData.GUIs.ZooFlow.Base
|
||||
Imports DigitalData.GUIs.ZooFlow.frmGlobix_Index
|
||||
Imports DigitalData.Modules.EDMI.API
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class ClassValidator
|
||||
@@ -14,30 +15,18 @@ Public Class ClassValidator
|
||||
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
|
||||
Function ValidateControls(pPanel As Panel, pDocType As DocType) As Boolean
|
||||
Try
|
||||
Logger.Debug("Starting [ValidateControls]")
|
||||
Dim result As Boolean = True
|
||||
|
||||
For Each oControl As Control In pControls
|
||||
For Each oControl As Control In pPanel.Controls
|
||||
|
||||
' ========================= 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 oIndexName = GetIndexName(oTextBox, "txt")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
@@ -54,7 +43,7 @@ Public Class ClassValidator
|
||||
Dim oValues As List(Of String) = oLookup.Properties.SelectedValues
|
||||
|
||||
If oValues.Count = 0 Then
|
||||
Dim oIndexName = Replace(oLookup.Name, "cmbMulti", "")
|
||||
Dim oIndexName = GetIndexName(oLookup, "cmbMulti")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
@@ -70,7 +59,7 @@ Public Class ClassValidator
|
||||
Dim cmbSingle As TextBox = oControl
|
||||
|
||||
If cmbSingle.Text = "" Then
|
||||
Dim oIndexName = Replace(cmbSingle.Name, "cmbSingle", "")
|
||||
Dim oIndexName = GetIndexName(cmbSingle, "cmbSingle")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
@@ -84,7 +73,7 @@ Public Class ClassValidator
|
||||
If oControl.Name.StartsWith("cmb") Then
|
||||
Dim cmb As ComboBox = oControl
|
||||
If cmb.Text = "" Then
|
||||
Dim oIndexName = Replace(cmb.Name, "cmb", "")
|
||||
Dim oIndexName = GetIndexName(cmb, "cmb")
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
|
||||
If oOptional = False Then
|
||||
@@ -98,7 +87,7 @@ Public Class ClassValidator
|
||||
' ========================= DATE PICKER =========================
|
||||
If oControl.Name.StartsWith("dtp") Then
|
||||
Dim dtp As DevExpress.XtraEditors.DateEdit = oControl
|
||||
Dim oIndexName As String = Replace(dtp.Name, "dtp", "")
|
||||
Dim oIndexName As String = GetIndexName(dtp, "dtp")
|
||||
|
||||
If dtp.Text = String.Empty Then
|
||||
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
|
||||
@@ -134,4 +123,124 @@ Public Class ClassValidator
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Function GetControlValues(pPanel As Panel)
|
||||
Dim oAttributeValues As New List(Of UserAttributeValue)
|
||||
|
||||
For Each oControl As Control In pPanel.Controls
|
||||
|
||||
' ========================= TEXTBOX =========================
|
||||
If oControl.Name.StartsWith("txt") Then
|
||||
Dim oTextBox As DevExpress.XtraEditors.TextEdit = oControl
|
||||
Dim oIndexName = GetIndexName(oTextBox, "txt")
|
||||
|
||||
' TODO: What to do when value is emmpty? send an empty value or skip the control?
|
||||
'If oTextBox.Text = "" Then
|
||||
'End If
|
||||
|
||||
oAttributeValues.Add(New UserAttributeValue With {
|
||||
.AttributeName = oIndexName,
|
||||
.AttributeValues = WrapIndexValue(oTextBox.Text),
|
||||
.ControlName = oTextBox.Name
|
||||
})
|
||||
End If
|
||||
|
||||
' ========================= LOOKUP =========================
|
||||
If oControl.Name.StartsWith("cmbMulti") Then
|
||||
Dim oLookup = DirectCast(oControl, LookupControl3)
|
||||
Dim oValues As List(Of String) = oLookup.Properties.SelectedValues
|
||||
Dim oIndexName = GetIndexName(oLookup, "cmbMulti")
|
||||
|
||||
If oValues.Count = 0 Then
|
||||
End If
|
||||
|
||||
oAttributeValues.Add(New UserAttributeValue With {
|
||||
.AttributeName = oIndexName,
|
||||
.AttributeValues = WrapIndexValue(oValues),
|
||||
.ControlName = oLookup.Name
|
||||
})
|
||||
End If
|
||||
|
||||
' ========================= COMBO BOX =========================
|
||||
If oControl.Name.StartsWith("cmbSingle") Then
|
||||
Dim cmbSingle As TextBox = oControl
|
||||
Dim oIndexName = GetIndexName(cmbSingle, "cmbSingle")
|
||||
|
||||
If cmbSingle.Text = "" Then
|
||||
End If
|
||||
|
||||
oAttributeValues.Add(New UserAttributeValue With {
|
||||
.AttributeName = oIndexName,
|
||||
.AttributeValues = WrapIndexValue(cmbSingle.Text),
|
||||
.ControlName = cmbSingle.Name
|
||||
})
|
||||
End If
|
||||
|
||||
If oControl.Name.StartsWith("cmb") Then
|
||||
Dim cmb As ComboBox = oControl
|
||||
Dim oIndexName = GetIndexName(cmb, "cmb")
|
||||
|
||||
If cmb.Text = "" Then
|
||||
End If
|
||||
|
||||
oAttributeValues.Add(New UserAttributeValue With {
|
||||
.AttributeName = oIndexName,
|
||||
.AttributeValues = WrapIndexValue(cmb.Text),
|
||||
.ControlName = cmb.Name
|
||||
})
|
||||
End If
|
||||
|
||||
' ========================= DATE PICKER =========================
|
||||
If oControl.Name.StartsWith("dtp") Then
|
||||
Dim dtp As DevExpress.XtraEditors.DateEdit = oControl
|
||||
Dim oIndexName As String = GetIndexName(dtp, "dtp")
|
||||
|
||||
oAttributeValues.Add(New UserAttributeValue With {
|
||||
.AttributeName = oIndexName,
|
||||
.AttributeValues = WrapIndexValue(dtp.EditValue.ToString),
|
||||
.ControlName = dtp.Name
|
||||
})
|
||||
End If
|
||||
|
||||
' ========================= CHECK BOX =========================
|
||||
If oControl.Name.StartsWith("chk") Then
|
||||
Dim chk As CheckBox = oControl
|
||||
Dim oIndexName As String = GetIndexName(chk, "chk")
|
||||
|
||||
|
||||
oAttributeValues.Add(New UserAttributeValue With {
|
||||
.AttributeName = oIndexName,
|
||||
.AttributeValues = WrapIndexValue(chk.Checked.ToString),
|
||||
.ControlName = chk.Name
|
||||
})
|
||||
End If
|
||||
Next
|
||||
|
||||
Return oAttributeValues
|
||||
End Function
|
||||
|
||||
Private Function GetIndexName(pControl As Control, pPrefix As String) As String
|
||||
Dim oIndexName = Replace(pControl.Name, pPrefix, "")
|
||||
Return oIndexName
|
||||
End Function
|
||||
|
||||
Private Function WrapIndexValue(pValue As String) As String()
|
||||
Return New List(Of String) From {pValue}.ToArray
|
||||
End Function
|
||||
|
||||
Private Function WrapIndexValue(pValues As List(Of String)) As String()
|
||||
Return pValues.ToArray
|
||||
End Function
|
||||
|
||||
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
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user