' This class is "generated" and will be overwritten.
' Your customizations should be made in StatusRecord.vb

Imports System.Data.SqlTypes
Imports BaseClasses
Imports BaseClasses.Data
Imports BaseClasses.Data.SqlProvider

Namespace Persons.Business

''' <summary>
''' The generated superclass for the <see cref="StatusRecord"></see> class.
''' </summary>
''' <remarks>
''' This class is not intended to be instantiated directly.  To obtain an instance of this class, 
''' use the methods of the <see cref="StatusTable"></see> class.
''' </remarks>
''' <seealso cref="StatusTable"></seealso>
''' <seealso cref="StatusRecord"></seealso>

<Serializable()> Public Class BaseStatusRecord
	Inherits PrimaryKeyRecord
	

	Public Shared Shadows ReadOnly TableUtils As StatusTable = StatusTable.Instance

	' Constructors
 
	Protected Sub New()
		MyBase.New(TableUtils)
	End Sub

	Protected Sub New(ByVal record As PrimaryKeyRecord)
		MyBase.New(record, TableUtils)
	End Sub
	
	'Evaluates Initialize when->Inserting record formulas specified at the data access layer
    Public Overridable Sub StatusRecord_InsertingRecord(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.InsertingRecord
        'Apply Initialize->Inserting record formula only if validation is successful.
        	        Dim StatusRec As StatusRecord = CType(sender,StatusRecord)
        Validate_Inserting()
        If Not StatusRec Is Nothing AndAlso Not StatusRec.IsReadOnly Then
                End If
    End Sub

	'Evaluates Initialize when->Updating record formulas specified at the data access layer
    Public Overridable Sub StatusRecord_UpdatingRecord(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.UpdatingRecord
        'Apply Initialize->Updating record formula only if validation is successful.
        	        Dim StatusRec As StatusRecord = CType(sender,StatusRecord)
        Validate_Updating()
        If Not StatusRec Is Nothing AndAlso Not StatusRec.IsReadOnly Then
                End If
    End Sub
    
    'Evaluates Initialize when->Reading record formulas specified at the data access layer
    Public Overridable Sub StatusRecord_ReadRecord(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ReadRecord
        'Apply Initialize->Reading record formula only if validation is successful.
        	        Dim StatusRec As StatusRecord = CType(sender,StatusRecord)
        If Not StatusRec Is Nothing AndAlso Not StatusRec.IsReadOnly Then
                End If
    End Sub
    
   'Evaluates Validate when->Inserting formulas specified at the data access layer
   Public Overridable Sub Validate_Inserting ()
		Dim fullValidationMessage As String = ""
		Dim validationMessage As String = ""

		dim formula as String = ""


		If validationMessage <> "" AndAlso validationMessage.ToLower() <> "true" Then
			fullValidationMessage &= validationMessage & vbCrLf
		End If

		If fullValidationMessage <> "" Then
			Throw New Exception(fullValidationMessage)
		End If 
	End Sub
	
	'Evaluates Validate when->Updating formulas specified at the data access layer
   Public Overridable Sub Validate_Updating ()
		Dim fullValidationMessage As String = ""
		Dim validationMessage As String = ""

		dim formula as String = ""


		If validationMessage <> "" AndAlso validationMessage.ToLower() <> "true" Then
			fullValidationMessage &= validationMessage & vbCrLf
		End If

		If fullValidationMessage <> "" Then
			Throw New Exception(fullValidationMessage)
		End If 
	End Sub
 
	Public Overridable Function EvaluateFormula(ByVal formula As String, Optional ByVal dataSourceForEvaluate As BaseClasses.Data.BaseRecord = Nothing, Optional ByVal format As String = Nothing) As String

		Dim e As Data.BaseFormulaEvaluator = New Data.BaseFormulaEvaluator()

            ' All variables referred to in the formula are expected to be
            ' properties of the DataSource.  For example, referring to
            ' UnitPrice as a variable will refer to DataSource.UnitPrice
            e.DataSource = dataSourceForEvaluate

            Dim resultObj As Object = e.Evaluate(formula)
            If resultObj Is Nothing Then
                Return ""
            End If
        	Return resultObj.ToString()
	End Function







#Region "Convenience methods to get/set values of fields"

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Status_.StatusId field.
	''' </summary>
	Public Function GetStatusIdValue() As ColumnValue
		Return Me.GetValue(TableUtils.StatusIdColumn)
	End Function

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Status_.StatusId field.
	''' </summary>
	Public Function GetStatusIdFieldValue() As Byte
		Return CType(Me.GetValue(TableUtils.StatusIdColumn).ToByte(), Byte)
	End Function

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.StatusId field.
	''' </summary>
	Public Sub SetStatusIdFieldValue(ByVal val As ColumnValue)
		Me.SetValue(val, TableUtils.StatusIdColumn)
	End Sub

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.StatusId field.
	''' </summary>
	Public Sub SetStatusIdFieldValue(ByVal val As String)
		Me.SetString(val, TableUtils.StatusIdColumn)
	End Sub

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.StatusId field.
	''' </summary>
	Public Sub SetStatusIdFieldValue(ByVal val As Double)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.StatusIdColumn)
	End Sub

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.StatusId field.
	''' </summary>
	Public Sub SetStatusIdFieldValue(ByVal val As Decimal)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.StatusIdColumn)
	End Sub

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.StatusId field.
	''' </summary>
	Public Sub SetStatusIdFieldValue(ByVal val As Int64)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.StatusIdColumn)
	End Sub
	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Status_.Status field.
	''' </summary>
	Public Function GetStatusValue() As ColumnValue
		Return Me.GetValue(TableUtils.StatusColumn)
	End Function

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Status_.Status field.
	''' </summary>
	Public Function GetStatusFieldValue() As String
		Return CType(Me.GetValue(TableUtils.StatusColumn).ToString(), String)
	End Function

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.Status field.
	''' </summary>
	Public Sub SetStatusFieldValue(ByVal val As ColumnValue)
		Me.SetValue(val, TableUtils.StatusColumn)
	End Sub

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Status_.Status field.
	''' </summary>
	Public Sub SetStatusFieldValue(ByVal val As String)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.StatusColumn)
	End Sub



#End Region

#Region "Convenience methods to get field names"

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Status_.StatusId field.
	''' </summary>
	Public Property StatusId() As Byte
		Get 
			Return CType(Me.GetValue(TableUtils.StatusIdColumn).ToByte(), Byte)
		End Get
		Set (ByVal val As Byte) 
			Dim colValue As ColumnValue = New ColumnValue(val)
			Me.SetValue(colValue, TableUtils.StatusIdColumn)
		End Set
	End Property


	''' <summary>
	''' This is a convenience method that can be used to determine that the column is set.
	''' </summary>
	Public ReadOnly Property StatusIdSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.StatusIdColumn)
            If val Is Nothing OrElse val.IsNull Then
                Return False
            End If
            Return True
        End Get
    End Property

	''' <summary>
	''' This is a convenience method that can be used to get the default value of a column.
	''' </summary>
    Public ReadOnly Property StatusIdDefault() As String
        Get
            Return TableUtils.StatusIdColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Status_.Status field.
	''' </summary>
	Public Property Status() As String
		Get 
			Return CType(Me.GetValue(TableUtils.StatusColumn).ToString(), String)
		End Get
		Set (ByVal Value As String) 
			Me.SetString(value, TableUtils.StatusColumn)
		End Set
	End Property


	''' <summary>
	''' This is a convenience method that can be used to determine that the column is set.
	''' </summary>
	Public ReadOnly Property StatusSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.StatusColumn)
            If val Is Nothing OrElse val.IsNull Then
                Return False
            End If
            Return True
        End Get
    End Property

	''' <summary>
	''' This is a convenience method that can be used to get the default value of a column.
	''' </summary>
    Public ReadOnly Property StatusDefault() As String
        Get
            Return TableUtils.StatusColumn.DefaultValue
        End Get
    End Property



#End Region

End Class
End Namespace
