' This class is "generated" and will be overwritten.
' Your customizations should be made in DeptRecord.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="DeptRecord"></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="DeptTable"></see> class.
''' </remarks>
''' <seealso cref="DeptTable"></seealso>
''' <seealso cref="DeptRecord"></seealso>

<Serializable()> Public Class BaseDeptRecord
	Inherits PrimaryKeyRecord
	

	Public Shared Shadows ReadOnly TableUtils As DeptTable = DeptTable.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 DeptRecord_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 DeptRec As DeptRecord = CType(sender,DeptRecord)
        Validate_Inserting()
        If Not DeptRec Is Nothing AndAlso Not DeptRec.IsReadOnly Then
                End If
    End Sub

	'Evaluates Initialize when->Updating record formulas specified at the data access layer
    Public Overridable Sub DeptRecord_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 DeptRec As DeptRecord = CType(sender,DeptRecord)
        Validate_Updating()
        If Not DeptRec Is Nothing AndAlso Not DeptRec.IsReadOnly Then
                End If
    End Sub
    
    'Evaluates Initialize when->Reading record formulas specified at the data access layer
    Public Overridable Sub DeptRecord_ReadRecord(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ReadRecord
        'Apply Initialize->Reading record formula only if validation is successful.
        	        Dim DeptRec As DeptRecord = CType(sender,DeptRecord)
        If Not DeptRec Is Nothing AndAlso Not DeptRec.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 Dept_.DeptId field.
	''' </summary>
	Public Function GetDeptIdValue() As ColumnValue
		Return Me.GetValue(TableUtils.DeptIdColumn)
	End Function

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.DeptId field.
	''' </summary>
	Public Function GetDeptIdFieldValue() As Int16
		Return CType(Me.GetValue(TableUtils.DeptIdColumn).ToInt16(), Int16)
	End Function

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

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

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

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

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Dept_.DeptId field.
	''' </summary>
	Public Sub SetDeptIdFieldValue(ByVal val As Int64)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.DeptIdColumn)
	End Sub
	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.SectionId field.
	''' </summary>
	Public Function GetSectionIdValue() As ColumnValue
		Return Me.GetValue(TableUtils.SectionIdColumn)
	End Function

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.SectionId field.
	''' </summary>
	Public Function GetSectionIdFieldValue() As Int16
		Return CType(Me.GetValue(TableUtils.SectionIdColumn).ToInt16(), Int16)
	End Function

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

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

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

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

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Dept_.SectionId field.
	''' </summary>
	Public Sub SetSectionIdFieldValue(ByVal val As Int64)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.SectionIdColumn)
	End Sub
	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.Dept field.
	''' </summary>
	Public Function GetDeptValue() As ColumnValue
		Return Me.GetValue(TableUtils.DeptColumn)
	End Function

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

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

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

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

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

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

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

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

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.ChiefId field.
	''' </summary>
	Public Function GetChiefIdFieldValue() As Int32
		Return CType(Me.GetValue(TableUtils.ChiefIdColumn).ToInt32(), Int32)
	End Function

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

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

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

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

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Dept_.ChiefId field.
	''' </summary>
	Public Sub SetChiefIdFieldValue(ByVal val As Int64)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.ChiefIdColumn)
	End Sub
	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.Position field.
	''' </summary>
	Public Function GetPositionValue() As ColumnValue
		Return Me.GetValue(TableUtils.PositionColumn)
	End Function

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

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

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

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

	''' <summary>
	''' This is a convenience method that provides direct access to the value of the record's Dept_.Sign field.
	''' </summary>
	Public Function GetSignFieldValue() As Byte()
		Return CType(Me.GetValue(TableUtils.SignColumn).ToBinary(), Byte())
	End Function

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

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

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's Dept_.Sign field.
	''' </summary>
	Public Sub SetSignFieldValue(ByVal val As Byte ())
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.SignColumn)
	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 Dept_.DeptId field.
	''' </summary>
	Public Property DeptId() As Int16
		Get 
			Return CType(Me.GetValue(TableUtils.DeptIdColumn).ToInt16(), Int16)
		End Get
		Set (ByVal val As Int16) 
			Dim colValue As ColumnValue = New ColumnValue(val)
			Me.SetValue(colValue, TableUtils.DeptIdColumn)
		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 DeptIdSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.DeptIdColumn)
            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 DeptIdDefault() As String
        Get
            Return TableUtils.DeptIdColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Dept_.SectionId field.
	''' </summary>
	Public Property SectionId() As Int16
		Get 
			Return CType(Me.GetValue(TableUtils.SectionIdColumn).ToInt16(), Int16)
		End Get
		Set (ByVal val As Int16) 
			Dim colValue As ColumnValue = New ColumnValue(val)
			Me.SetValue(colValue, TableUtils.SectionIdColumn)
		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 SectionIdSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.SectionIdColumn)
            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 SectionIdDefault() As String
        Get
            Return TableUtils.SectionIdColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Dept_.Dept field.
	''' </summary>
	Public Property Dept() As String
		Get 
			Return CType(Me.GetValue(TableUtils.DeptColumn).ToString(), String)
		End Get
		Set (ByVal Value As String) 
			Me.SetString(value, TableUtils.DeptColumn)
		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 DeptSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.DeptColumn)
            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 DeptDefault() As String
        Get
            Return TableUtils.DeptColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Dept_.DeptAbbvr field.
	''' </summary>
	Public Property DeptAbbvr() As String
		Get 
			Return CType(Me.GetValue(TableUtils.DeptAbbvrColumn).ToString(), String)
		End Get
		Set (ByVal Value As String) 
			Me.SetString(value, TableUtils.DeptAbbvrColumn)
		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 DeptAbbvrSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.DeptAbbvrColumn)
            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 DeptAbbvrDefault() As String
        Get
            Return TableUtils.DeptAbbvrColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Dept_.ChiefId field.
	''' </summary>
	Public Property ChiefId() As Int32
		Get 
			Return CType(Me.GetValue(TableUtils.ChiefIdColumn).ToInt32(), Int32)
		End Get
		Set (ByVal val As Int32) 
			Dim colValue As ColumnValue = New ColumnValue(val)
			Me.SetValue(colValue, TableUtils.ChiefIdColumn)
		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 ChiefIdSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.ChiefIdColumn)
            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 ChiefIdDefault() As String
        Get
            Return TableUtils.ChiefIdColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Dept_.Position field.
	''' </summary>
	Public Property Position() As String
		Get 
			Return CType(Me.GetValue(TableUtils.PositionColumn).ToString(), String)
		End Get
		Set (ByVal Value As String) 
			Me.SetString(value, TableUtils.PositionColumn)
		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 PositionSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.PositionColumn)
            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 PositionDefault() As String
        Get
            Return TableUtils.PositionColumn.DefaultValue
        End Get
    End Property

	''' <summary>
	''' This is a convenience property that provides direct access to the value of the record's Dept_.Sign field.
	''' </summary>
	Public Property Sign() As Byte()
		Get 
			Return CType(Me.GetValue(TableUtils.SignColumn).ToBinary(), Byte())
		End Get
		Set (ByVal val As Byte ()) 
			Dim colValue As ColumnValue = New ColumnValue(val)
			Me.SetValue(colValue, TableUtils.SignColumn)
		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 SignSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.SignColumn)
            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 SignDefault() As String
        Get
            Return TableUtils.SignColumn.DefaultValue
        End Get
    End Property



#End Region

End Class
End Namespace
