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
| Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TrViContact.Nodes.Clear()
conn = New MySqlConnection
conn.ConnectionString = hote
req = "select nom_util ,groupe.nom from personnel,groupe where personnel.id_p = groupe.id_p"
pfl = New MySqlCommand(req, conn)
Try
conn.Open()
lire = pfl.ExecuteReader
Do While lire.Read()
LstNomgroup.Items.Add(lire.GetValue(1).ToString())
LstResp.Items.Add(lire.GetValue(0).ToString())
Loop
lire.Close()
cpt = LstNomgroup.Items.Count
TrViContact.ShowPlusMinus = False
TrViContact.ShowRootLines = False
req = "select id_g from groupe,personnel where groupe.id_p = personnel.id_p "
pfl = New MySqlCommand(req, conn)
lire = pfl.ExecuteReader
While lire.Read
LstIdgroup.Items.Add(lire.GetValue(0).ToString())
End While
lire.Close()
Dim group As New TreeNode
For Me.i = 0 To cpt - 1
Resp = TrViContact.Nodes.Add("", LstNomgroup.Items(i).ToString(), 1)
Resp.ForeColor = Color.DarkOrchid
req = "select nom_util from personnel,appartenir,groupe where personnel.id_p=appartenir.id_p and groupe.id_g=appartenir.id_g and appartenir.id_g =' " & LstIdgroup.Items(i) & "'"
pfl = New MySqlCommand(req, conn)
lire = pfl.ExecuteReader
group = Resp.Nodes.Add("", LstResp.Items(i), 0)
While lire.Read()
group.Nodes.Add("", lire.GetValue(0), 0)
End While
lire.Close()
Next i
TrViContact.ExpandAll()
'If p = 1 Then
'FrmContactenLigne.Show()
'Me.Dispose()
'Me.Hide()
'End If
Catch ex As Exception
MessageBox.Show("Connexion non établit", "Erreur connexion", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Timer1.Enabled = False
End Sub |