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 Sub loadGamme()
Dim masterBindingSource As New BindingSource()
Dim detailsBindingSource As New BindingSource()
gamme.DataSource = masterBindingSource
fournitures.DataSource = detailsBindingSource
Dim Sql As String
Dim Rs As ADODB.Recordset
Dim aid As Integer
Dim data As DataSet
aid = article.SelectedValue
ConnectBD(Conn)
GammeDT.Rows.Clear()
Rs = New ADODB.Recordset()
Sql = "SELECT * FROM gam WHERE gam_article = " & aid & " ORDER BY gam_op;"
Rs.Open(Sql, Conn)
If Not Rs.EOF Then
Do While Not Rs.EOF
GammeDT.Rows.Add(Rs("gam_article"), Rs("gam_op").Value, Rs("gam_op_designation").Value, Rs("gam_op_detail").Value, Rs("gam_cout_piece").Value, Rs("gam_op_mere").Value)
Rs.MoveNext()
Loop
End If
Rs.Close()
FournituresDT.Rows.Clear()
Sql = "SELECT * FROM nmcl, art WHERE nmcl_fourniture = art_id AND nmcl_article = " & aid & " ORDER BY nmcl_fourniture;"
Rs.Open(Sql, Conn)
If Not Rs.EOF Then
Do While Not Rs.EOF
FournituresDT.Rows.Add(Rs("nmcl_article"), Rs("nmcl_op").Value, Rs("nmcl_fourniture").Value, Rs("nmcl_qte_lien").Value)
Rs.MoveNext()
Loop
End If
Rs.Close()
DeconnectBD(Conn)
data = New DataSet()
data.Tables.Add(GammeDT)
data.Tables.Add(FournituresDT)
Dim GammeColumns() As DataColumn
Dim FournituresColumns() As DataColumn
GammeColumns = New DataColumn() {GammeDT.Columns("ARTICLEID"), GammeDT.Columns("OP")}
FournituresColumns = New DataColumn() {FournituresDT.Columns("ARTICLEID"), FournituresDT.Columns("OP")}
Dim relation As New DataRelation("FournituresOperation", GammeColumns, FournituresColumns)
data.Relations.Add(relation)
masterBindingSource.DataSource = data
masterBindingSource.DataMember = GammeDT.TableName
detailsBindingSource.DataSource = masterBindingSource
detailsBindingSource.DataMember = "FournituresOperation"
End Sub |