| Imports System.Data |
| |
| Class Window1 |
| |
| Public Sub New() |
| InitializeComponent() |
| Dim ds As New DataSet |
| Dim dt As New DataTable("Labour.Employee") |
| Me.BuildEmployeesTable(dt) |
| ds.Tables.Add(dt) |
| dt = New DataTable("Labour.EmployeeLeave") |
| Me.BuildEmployeeLeaveTable(dt) |
| ds.Tables.Add(dt) |
| Me.DataContext = ds |
| End Sub |
| |
| Private Sub BuildEmployeesTable(ByVal dt As DataTable) |
| dt.Columns.Add("EmpNum", GetType(System.Int32)) |
| dt.Columns.Add("Firstname", GetType(System.String)) |
| dt.Columns.Add("Surname", GetType(System.String)) |
| dt.Columns.Add("Fullname", GetType(System.String), "Firstname+' '+Surname") |
| Me.AdddEmployeesRow(dt, 1, "Joe", "Blogs") |
| Me.AdddEmployeesRow(dt, 2, "John", "Doe") |
| Me.AdddEmployeesRow(dt, 3, "Mary", "May") |
| End Sub |
| |
| Private Sub BuildEmployeeLeaveTable(ByVal dt As DataTable) |
| dt.Columns.Add("EmpNum", GetType(System.Int32)) |
| dt.Columns.Add("LeaveCode", GetType(System.String)) |
| dt.Columns.Add("DateFrom", GetType(System.DateTime)) |
| dt.Columns.Add("DateTo", GetType(System.DateTime)) |
| dt.Columns.Add("Hours", GetType(System.Int32)) |
| dt.Columns.Add("PayInAdvance", GetType(System.Boolean)) |
| dt.Columns.Add("Comments", GetType(System.String)) |
| dt.Columns.Add("TotalMade", GetType(String), "Comments+Hours") |
| Me.AdddEmployeeLeaveRow(dt, 1, "sss", Now, Now, 55, True, "comment") |
| Me.AdddEmployeeLeaveRow(dt, 2, "sss", Now, Now, 22, True, "comment") |
| Me.AdddEmployeeLeaveRow(dt, 3, "sss", Now, Now, 33, True, "comment") |
| End Sub |
| |
| Private Sub AdddEmployeesRow(ByVal dt As DataTable, ByVal id As Integer, ByVal fname As String, ByVal lname As String) |
| Dim dr As DataRow = dt.NewRow() |
| dr("EmpNum") = id |
| dr("Firstname") = fname |
| dr("Surname") = lname |
| dt.Rows.Add(dr) |
| End Sub |
| |
| Private Sub AdddEmployeeLeaveRow(ByVal dt As DataTable, ByVal id As Integer, ByVal LeaveCode As String, ByVal DateFrom As DateTime, ByVal DateTo As DateTime, ByVal Hours As Integer, ByVal PayInAdvance As Boolean, ByVal Comments As String) |
| Dim dr As DataRow = dt.NewRow() |
| dr("EmpNum") = id |
| dr("LeaveCode") = LeaveCode |
| dr("DateFrom") = DateFrom |
| dr("DateTo") = DateTo |
| dr("Hours") = Hours |
| dr("PayInAdvance") = PayInAdvance |
| dr("Comments") = Comments |
| dt.Rows.Add(dr) |
| End Sub |
| |
| End Class |
| |