Adding Format Custom Checks

<< Click to Display Table of Contents >>

EQuIS 7  >>  EDP > EDP Format Files, Open, Data Review, Tools, EDP Professional and EDP Enterprise > EDP Format Files >

Adding Format Custom Checks

1.Add a column changed event (if missing) in AddDataHandlers method.

 

Public OverridesSub *AddDataHandlers(**ByRefEfd* As *EarthSoft.EDP.**EddFormatDefinition)*

                 AddHandler Efd.Tables.Item(**"Subfacility_v1").ColumnChanged,AddressOf Me. CheckSubfacility*

End Sub

 

Private SubCheckSubfacility(*ByVal **sender As Object*,* ByVal e As{*}System.Data.**DataColumnChangeEventArgs)*

 

End Sub

 

2.Create a custom check that will add or remove the error/warning.

 

''' <summary> if accessyn = y then ReasonforNonAccess must be empty.  If accessYN ='N' then ReasonForNonAcess must be populated.

 ''' Applies to:

 ''' <list type="bullet">

 '''  <item>Subfacility_v1.ReasonForNonAccess</item>

 ''' <item>Subfacility_v1.Accessyn</item>

 ''' </list>

 ''' </summary>

Private Sub ERR06(ByVal e As System.Data.DataColumnChangeEventArgs)

   With e.Row

     If .Item("accessyn").ToString.ToUpper = "Y" AndAlsoNot .IsNull("ReasonForNonAccess")Then

       Me.AddError(e.Row, e.Row.Table.Columns.Item("ReasonForNonAccess"),EddErrors.CustomError16)

     ElseIf.Item("accessyn").ToString.ToUpper = "N" AndAlso.IsNull("ReasonForNonAccess") Then

       Me.AddError(e.Row, e.Row.Table.Columns.Item("ReasonForNonAccess"),EddErrors.CustomError16)

     Else

       Me.RemoveError(e.Row, e.Row.Table.Columns.Item("ReasonForNonAccess"),EddErrors.CustomError16)

     End If

   End With

 End Sub

 

3.Add a custom error message (max number of custom messages allowed is 63).

 

Public Overloads Overrides FunctionErrorMessage(ByVal err AsEddErrors) AsString

           Select Case err

          Case EddErrors.CustomError16

                    Return"If accessYN = y then ReasonforNonAccess must be empty.  If accessYN ='N' then ReasonForNonAcess must be populated."

  Case Else

                    ReturnMyBase.ErrorMessage(err)

        End Select
    End Function

 

4.Call the check from the column changed event.

 

Private SubCheckSubfacility(ByVal sender As Object, ByVal e AsSystem.Data.DataColumnChangeEventArgs)

        Select Casee.Column.ColumnName.ToLower

   Case "accessyn", "reasonfornonaccess"

ERR06(e)   'If accessyn = y then ReasonforNonAccess must be empty.  If accessYN ='N' then ReasonForNonAcess must be populated.

 

End Sub

 

5.If the error is dependent on more than one column, update the cell to create cell coloring when the error is added or removed in the user interface.

 

Public OverridesSub Grid_AfterCellUpdate(ByVal sender As Object, ByVal e As Object, ByVal edp As Object)

 Select CaseCType(e.cell.row.listObject, System.Data.DataRowView).DataView.Table.TableName

   Case "Subfacility_v1"

            Subfacility_Refresh(sender, e, edp)

 End Select

End Sub

 

Private Sub Subfacility_Refresh(ByValsender As Object,ByVal e As Object, ByVal edp As Object)

   Select Case e.Cell.Column.Key.ToLower

     Case "accessyn"

      edp.AfterCellUpdate(sender, e.Cell.Row.Cells.Item("reasonfornonaccess")) 'ERR06

   End Select

End Sub

 

 

6.To create a warning instead of an error, add the error to the Err property.

 

Public OverridesProperty Err() AsEddError

   Get

     Return MyBase.Err

   End Get

   Set(ByVal Value As EddError)

     Me._Err = Value

     Me._Err.SetStatus(EddErrors.CustomError16, EddError.ErrorStatus.Warning)

   End Set

End Property