1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Public Class rhEmployes
Private _strConn As String
Private _strSql As String
Private _adapter As OleDbDataAdapter
Private _ObjDataSet As New Data.DataSet
Private _ObjetCommandBuilder As OleDbCommandBuilder
Public Sub New()
_strConn = My.Settings.dataConnectionString
_strSql = My.Settings.SQLEmployes
_adapter = New OleDbDataAdapter(_strSql, _strConn)
_ObjDataSet = New Data.DataSet
_adapter.Fill(_ObjDataSet)
End Sub
Public Function update_row(ByVal matricule As String, ByVal nom As String, ByVal prenom As String, ByVal service As String, ByVal equipe As String, ByVal particularite As String, ByVal embauche As Date, ByVal interim As Boolean, ByVal actif As Boolean, ByVal manager As Boolean, ByVal empLog As String) As Boolean
Dim expression As String = "empMatricule='" & matricule & "'" 'expression à rechercher
Dim foundRow() As DataRow
Dim ObjetDataTable As New DataTable
'résultat dans des DataRow
'ObjetCommandBuilder = New OleDbCommandBuilder(ObjetDataAdapter)
Try
ObjetDataTable = _ObjDataSet.Tables(0)
foundRow = ObjetDataTable.Select(expression)
foundRow(0).BeginEdit()
foundRow(0)("empNom") = nom
foundRow(0)("empPrenom") = prenom
foundRow(0)("empService") = service
foundRow(0)("empEquipe") = equipe
foundRow(0)("empParticularite") = particularite
foundRow(0)("empActif") = actif
foundRow(0)("empDateDebut") = embauche
foundRow(0)("empLogin") = empLog
foundRow(0)("empManager") = manager
foundRow(0)("empinterim") = interim
foundRow(0).EndEdit()
_ObjetCommandBuilder = New OleDbCommandBuilder(_adapter)
_adapter.Update(foundRow)
MessageBox.Show(foundRow(0).RowState)
Return True
Catch ex As Exception
MessageBox.Show(ex.Message)
Return False
End Try
End Function
Public ReadOnly Property datatable() As DataTable
Get
Return (_ObjDataSet.Tables(0))
End Get
End Property
End Class |
Partager