📄 employeeds.vb
字号:
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.employeeRowDeletedEvent) Is Nothing) Then
RaiseEvent employeeRowDeleted(Me, New employeeRowChangeEvent(CType(e.Row,employeeRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.employeeRowDeletingEvent) Is Nothing) Then
RaiseEvent employeeRowDeleting(Me, New employeeRowChangeEvent(CType(e.Row,employeeRow), e.Action))
End If
End Sub
Public Sub RemoveemployeeRow(ByVal row As employeeRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class employeeRow
Inherits DataRow
Private tableemployee As employeeDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tableemployee = CType(Me.Table,employeeDataTable)
End Sub
Public Property emp_id As String
Get
Return CType(Me(Me.tableemployee.emp_idColumn),String)
End Get
Set
Me(Me.tableemployee.emp_idColumn) = value
End Set
End Property
Public Property emp_name As String
Get
Try
Return CType(Me(Me.tableemployee.emp_nameColumn),String)
Catch e As InvalidCastException
Throw New StrongTypingException("Cannot get value because it is DBNull.", e)
End Try
End Get
Set
Me(Me.tableemployee.emp_nameColumn) = value
End Set
End Property
Public Property job_id As Short
Get
Return CType(Me(Me.tableemployee.job_idColumn),Short)
End Get
Set
Me(Me.tableemployee.job_idColumn) = value
End Set
End Property
Public Property hire_date As Date
Get
Return CType(Me(Me.tableemployee.hire_dateColumn),Date)
End Get
Set
Me(Me.tableemployee.hire_dateColumn) = value
End Set
End Property
Public Property jobsRow As jobsRow
Get
Return CType(Me.GetParentRow(Me.Table.ParentRelations("EmployeeJob")),jobsRow)
End Get
Set
Me.SetParentRow(value, Me.Table.ParentRelations("EmployeeJob"))
End Set
End Property
Public Function Isemp_nameNull() As Boolean
Return Me.IsNull(Me.tableemployee.emp_nameColumn)
End Function
Public Sub Setemp_nameNull()
Me(Me.tableemployee.emp_nameColumn) = System.Convert.DBNull
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class employeeRowChangeEvent
Inherits EventArgs
Private eventRow As employeeRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As employeeRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As employeeRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class jobsDataTable
Inherits DataTable
Implements System.Collections.IEnumerable
Private columnjob_id As DataColumn
Private columnjob_desc As DataColumn
Friend Sub New()
MyBase.New("jobs")
Me.InitClass
End Sub
Friend Sub New(ByVal table As DataTable)
MyBase.New(table.TableName)
If (table.CaseSensitive <> table.DataSet.CaseSensitive) Then
Me.CaseSensitive = table.CaseSensitive
End If
If (table.Locale.ToString <> table.DataSet.Locale.ToString) Then
Me.Locale = table.Locale
End If
If (table.Namespace <> table.DataSet.Namespace) Then
Me.Namespace = table.Namespace
End If
Me.Prefix = table.Prefix
Me.MinimumCapacity = table.MinimumCapacity
Me.DisplayExpression = table.DisplayExpression
End Sub
<System.ComponentModel.Browsable(false)> _
Public ReadOnly Property Count As Integer
Get
Return Me.Rows.Count
End Get
End Property
Friend ReadOnly Property job_idColumn As DataColumn
Get
Return Me.columnjob_id
End Get
End Property
Friend ReadOnly Property job_descColumn As DataColumn
Get
Return Me.columnjob_desc
End Get
End Property
Public Default ReadOnly Property Item(ByVal index As Integer) As jobsRow
Get
Return CType(Me.Rows(index),jobsRow)
End Get
End Property
Public Event jobsRowChanged As jobsRowChangeEventHandler
Public Event jobsRowChanging As jobsRowChangeEventHandler
Public Event jobsRowDeleted As jobsRowChangeEventHandler
Public Event jobsRowDeleting As jobsRowChangeEventHandler
Public Overloads Sub AddjobsRow(ByVal row As jobsRow)
Me.Rows.Add(row)
End Sub
Public Overloads Function AddjobsRow(ByVal job_desc As String) As jobsRow
Dim rowjobsRow As jobsRow = CType(Me.NewRow,jobsRow)
rowjobsRow.ItemArray = New Object() {Nothing, job_desc}
Me.Rows.Add(rowjobsRow)
Return rowjobsRow
End Function
Public Function FindByjob_id(ByVal job_id As Short) As jobsRow
Return CType(Me.Rows.Find(New Object() {job_id}),jobsRow)
End Function
Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
Return Me.Rows.GetEnumerator
End Function
Public Overrides Function Clone() As DataTable
Dim cln As jobsDataTable = CType(MyBase.Clone,jobsDataTable)
cln.InitVars
Return cln
End Function
Protected Overrides Function CreateInstance() As DataTable
Return New jobsDataTable
End Function
Friend Sub InitVars()
Me.columnjob_id = Me.Columns("job_id")
Me.columnjob_desc = Me.Columns("job_desc")
End Sub
Private Sub InitClass()
Me.columnjob_id = New DataColumn("job_id", GetType(System.Int16), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnjob_id)
Me.columnjob_desc = New DataColumn("job_desc", GetType(System.String), Nothing, System.Data.MappingType.Element)
Me.Columns.Add(Me.columnjob_desc)
Me.Constraints.Add(New UniqueConstraint("Constraint1", New DataColumn() {Me.columnjob_id}, true))
Me.columnjob_id.AutoIncrement = true
Me.columnjob_id.AllowDBNull = false
Me.columnjob_id.ReadOnly = true
Me.columnjob_id.Unique = true
Me.columnjob_desc.AllowDBNull = false
End Sub
Public Function NewjobsRow() As jobsRow
Return CType(Me.NewRow,jobsRow)
End Function
Protected Overrides Function NewRowFromBuilder(ByVal builder As DataRowBuilder) As DataRow
Return New jobsRow(builder)
End Function
Protected Overrides Function GetRowType() As System.Type
Return GetType(jobsRow)
End Function
Protected Overrides Sub OnRowChanged(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanged(e)
If (Not (Me.jobsRowChangedEvent) Is Nothing) Then
RaiseEvent jobsRowChanged(Me, New jobsRowChangeEvent(CType(e.Row,jobsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowChanging(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowChanging(e)
If (Not (Me.jobsRowChangingEvent) Is Nothing) Then
RaiseEvent jobsRowChanging(Me, New jobsRowChangeEvent(CType(e.Row,jobsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleted(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleted(e)
If (Not (Me.jobsRowDeletedEvent) Is Nothing) Then
RaiseEvent jobsRowDeleted(Me, New jobsRowChangeEvent(CType(e.Row,jobsRow), e.Action))
End If
End Sub
Protected Overrides Sub OnRowDeleting(ByVal e As DataRowChangeEventArgs)
MyBase.OnRowDeleting(e)
If (Not (Me.jobsRowDeletingEvent) Is Nothing) Then
RaiseEvent jobsRowDeleting(Me, New jobsRowChangeEvent(CType(e.Row,jobsRow), e.Action))
End If
End Sub
Public Sub RemovejobsRow(ByVal row As jobsRow)
Me.Rows.Remove(row)
End Sub
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class jobsRow
Inherits DataRow
Private tablejobs As jobsDataTable
Friend Sub New(ByVal rb As DataRowBuilder)
MyBase.New(rb)
Me.tablejobs = CType(Me.Table,jobsDataTable)
End Sub
Public Property job_id As Short
Get
Return CType(Me(Me.tablejobs.job_idColumn),Short)
End Get
Set
Me(Me.tablejobs.job_idColumn) = value
End Set
End Property
Public Property job_desc As String
Get
Return CType(Me(Me.tablejobs.job_descColumn),String)
End Get
Set
Me(Me.tablejobs.job_descColumn) = value
End Set
End Property
Public Function GetemployeeRows() As employeeRow()
Return CType(Me.GetChildRows(Me.Table.ChildRelations("EmployeeJob")),employeeRow())
End Function
End Class
<System.Diagnostics.DebuggerStepThrough()> _
Public Class jobsRowChangeEvent
Inherits EventArgs
Private eventRow As jobsRow
Private eventAction As DataRowAction
Public Sub New(ByVal row As jobsRow, ByVal action As DataRowAction)
MyBase.New
Me.eventRow = row
Me.eventAction = action
End Sub
Public ReadOnly Property Row As jobsRow
Get
Return Me.eventRow
End Get
End Property
Public ReadOnly Property Action As DataRowAction
Get
Return Me.eventAction
End Get
End Property
End Class
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -