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

<Serializable()> Public Class BaseTblUserRoleRecord
	Inherits PrimaryKeyRecord
	Implements IUserRoleRecord


	Public Shared Shadows ReadOnly TableUtils As TblUserRoleTable = TblUserRoleTable.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 TblUserRoleRecord_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 TblUserRoleRec As TblUserRoleRecord = CType(sender,TblUserRoleRecord)
        Validate_Inserting()
        If Not TblUserRoleRec Is Nothing AndAlso Not TblUserRoleRec.IsReadOnly Then
                End If
    End Sub

	'Evaluates Initialize when->Updating record formulas specified at the data access layer
    Public Overridable Sub TblUserRoleRecord_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 TblUserRoleRec As TblUserRoleRecord = CType(sender,TblUserRoleRecord)
        Validate_Updating()
        If Not TblUserRoleRec Is Nothing AndAlso Not TblUserRoleRec.IsReadOnly Then
                End If
    End Sub
    
    'Evaluates Initialize when->Reading record formulas specified at the data access layer
    Public Overridable Sub TblUserRoleRecord_ReadRecord(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ReadRecord
        'Apply Initialize->Reading record formula only if validation is successful.
        	        Dim TblUserRoleRec As TblUserRoleRecord = CType(sender,TblUserRoleRecord)
        If Not TblUserRoleRec Is Nothing AndAlso Not TblUserRoleRec.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 "IUserRecord Members"

	' Get the user's unique identifier
	Public Function GetUserId() As String Implements IUserRecord.GetUserId
		Return CType(Me, IRecord).GetString(CType(Me.TableAccess, IUserTable).UserIdColumn)
	End Function

#End Region




#Region "IUserRoleRecord Members"

	' Get the role to which this user belongs
	Public Function GetUserRole() As String Implements IUserRoleRecord.GetUserRole
		Return CType(Me, IRecord).GetString(CType(Me.TableAccess, IUserRoleTable).UserRoleColumn)
	End Function

#End Region


#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 TblUserRole_.UserRoleId field.
	''' </summary>
	Public Function GetUserRoleIdValue() As ColumnValue
		Return Me.GetValue(TableUtils.UserRoleIdColumn)
	End Function

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

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

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

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

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

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

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

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

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

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

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

	''' <summary>
	''' This is a convenience method that allows direct modification of the value of the record's TblUserRole_.RoleId field.
	''' </summary>
	Public Sub SetRoleIdFieldValue(ByVal val As Int64)
		Dim colValue As ColumnValue = New ColumnValue(val)
		Me.SetValue(colValue, TableUtils.RoleIdColumn)
	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 TblUserRole_.UserRoleId field.
	''' </summary>
	Public Property UserRoleId() As Int32
		Get 
			Return CType(Me.GetValue(TableUtils.UserRoleIdColumn).ToInt32(), Int32)
		End Get
		Set (ByVal val As Int32) 
			Dim colValue As ColumnValue = New ColumnValue(val)
			Me.SetValue(colValue, TableUtils.UserRoleIdColumn)
		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 UserRoleIdSpecified() As Boolean
        Get
            Dim val As ColumnValue = Me.GetValue(TableUtils.UserRoleIdColumn)
            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 UserRoleIdDefault() As String
        Get
            Return TableUtils.UserRoleIdColumn.DefaultValue
        End Get
    End Property

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

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



#End Region

End Class
End Namespace
