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 57 58 59 60 61 62 63 64 65
|
Private oAdo As ClAdoNet
Private Delegate Sub transfertDonnees()
Private Th As Thread
'Cette sub, s'occupe d'effectuer des transferts de données entre bases de données.
Private Sub Traitement()
Dim i, j As Integer
Dim oDataSetBaseApi As DataSet
Dim oDataRow As DataRow
Dim strRef As String
Dim strLib As String
Dim dblTTC As Double
Dim blnVis As Boolean
Dim strCodBar As String
Dim intConstructeur As String
Dim intType As String
oAdo = New ClAdoNet
oDataSetBaseApi = oAdo.ChargerDonnees("Select * from article", "article", True)
For i = 1 To ModPanelConsommable.lvListeAttente.Items.Count
j = 0
'On parcours la table article
For Each oDataRow In oDataSetBaseApi.Tables("article").Rows
'On compare les codes barre
If oDataSetBaseApi.Tables("article").Rows(j).Item("codebarre") = ModPanelConsommable.lvListeAttente.Items(i - 1).SubItems(1).Text Then
'Si on trouve le code barre
Dim oProduit As ClProduit
Try
strCodBar = ModPanelConsommable.lvListeAttente.Items(i - 1).SubItems(1).Text
strRef = oDataSetBaseApi.Tables("article").Rows(j).Item("code")
strLib = oDataSetBaseApi.Tables("article").Rows(j).Item("nom")
dblTTC = oDataSetBaseApi.Tables("article").Rows(j).Item("prixbasettc")
blnVis = CBool(oDataSetBaseApi.Tables("article").Rows(j).Item("sommeil"))
intConstructeur = ModPanelConsommable.lvListeAttente.Items(i - 1).SubItems(2).Tag
intType = ModPanelConsommable.lvListeAttente.Items(i - 1).SubItems(3).Tag
oProduit = New ClProduit(strRef, strCodBar, strLib, dblTTC, "", blnVis, intConstructeur, intType)
oProduit.Ajouter()
oProduit = Nothing
Catch ex As Exception
MsgBox(ex.Message)
End Try
'On recharge les differents elements.
Exit For
End If
j += 1
Next oDataRow
pgb1.PerformStep()
Next i
End Sub
'Bouton qui lance l'opération.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Création du thread
If IsNothing(Th) Then
Th = New Thread(AddressOf Traitement)
Th.Start()
Invoke(New transfertDonnees(AddressOf Traitement))
Th = Nothing
End If
MsgBox("Transfert(s) éffectué(s) correctement...", MsgBoxStyle.Information, "Transfert(s) OK.")
End Sub |
Partager