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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
| Option Strict On
Option Explicit On
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Public Class FrmROUGRAPH
Private pathbase As String = Application.StartupPath & "\V_Techno_DB_be.mdb"
Private connStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & pathbase
Private dts As New DataSet
Private dtt As DataTable
Private ListePersonnel As List(Of Personnel)
Private Sub FrmROUGRAPH_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub FrmProjets_Load(sender As Object, e As EventArgs) Handles MyBase.Load
ComboPrenom.Items.Clear()
ComboNom.Items.Clear()
remplirComboNom()
remplirComboNomProjet()
remplirComboPrenom()
End Sub
'---Remplissage comboBoxCode avec les codes
Sub remplirComboNom()
Try
Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\V_Techno_DB_be.mdb")
Dim cmd As New OleDbCommand("select DISTINCT Nom from Requête_SommeTotal_Jours ", cn)
cn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Do While dr.Read
ComboNom.Items.Add(dr.GetValue(0))
Loop
dr.Close()
cn.Close()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
Sub remplirComboPrenom()
Try
Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\V_Techno_DB_be.mdb")
Dim cmd As New OleDbCommand("select DISTINCT Prenom from Requête_SommeTotal_Jours ", cn)
cn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Do While dr.Read
ComboPrenom.Items.Add(dr.GetValue(0))
Loop
dr.Close()
cn.Close()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
'Traitement en fonction de la colonne où se situe la cellule en cours d'édition
Sub remplirComboNomProjet()
Try
Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\V_Techno_DB_be.mdb")
Dim cmd As New OleDbCommand("select DISTINCT Nom_Projet from Requête_SommeTotal_Jours ", cn)
cn.Open()
Dim dr As OleDbDataReader = cmd.ExecuteReader
Do While dr.Read
ComboNomProjet.Items.Add(dr.GetValue(0))
Loop
dr.Close()
cn.Close()
Catch ex As Exception
'MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
'Try
Dim cn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\wayne\Documents\Visual Studio 2012\Projects\VERSCHUERE\VESCHUERE_TECHNO_Apps\VESCHUERE_TECHNO_Apps\bin\Debug\V_Techno_DB_be.mdb")
Dim cmd As New OleDbCommand("select * from Requête_SommeTotal_Jours where Nom ='" & ComboNom.Text & "'and Nom_Projet ='" & ComboNomProjet.Text & "'and Prenom ='" & ComboPrenom.Text & "'", cn)
cn.Open()
Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds, "Requête_SommeTotal_Jours")
da.Update(ds, "Requête_SommeTotal_Jours")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "Requête_SommeTotal_Jours"
cn.Close()
'Catch ex As Exception
'End Try
End Sub
Sub blabla()
Using conn As New OleDbConnection(connStr)
Dim query As String = "Select * From [Requête_SommeTotal_Jours] Where [Date_de_demarrage_Projet] Is Not Null"
Dim cmd As OleDbCommand = New OleDbCommand(query)
Dim dta As OleDbDataAdapter = New OleDbDataAdapter(cmd)
conn.Open()
cmd.Connection() = conn
dta.Fill(dts, "Requête_SommeTotal_Jours")
dtt = dts.Tables("Requête_SommeTotal_Jours")
conn.Close()
End Using
ListePersonnel = (
From row In dtt.AsEnumerable()
Order By row.Field(Of String)("Nom"), row.Field(Of String)("Prenom"), row.Field(Of String)("Code") Ascending
Select New Personnel With {
.Employers = row.Field(Of String)("Nom") & New String(" "c, 1) & row.Field(Of String)("Prenom"),
.Code = row.Field(Of String)("Code"),
.Ref_Projet = row.Field(Of String)("Ref_Projet"),
.Heures_Depart = row.Field(Of String)("Heures_Depart"),
.Heures_FIN = row.Field(Of String)("Heures_FIN"),
.Designation_Tache = row.Field(Of String)("Designation_Tache"),
.Date_de_demarrage_Projet = row.Field(Of Date)("Date_de_demarrage_Projet"),
.Date_de_Fin_Projet = row.Field(Of Date)("Date_de_Fin_Projet"),
.Total_jours = row.Field(Of Integer)("Total_jours")
}).ToList
'
Dim NameEmploye = (From y In ListePersonnel.GroupBy(Function(x) x.Employers)).ToList
For Each value In NameEmploye.Where(Function(x) x.Key <> Nothing)
MessageBox.Show(value.Key.ToString, "Nom-Prénom du Personnel")
Next
' Initialisation DataGridView1
With Me.DataGridView1
.ColumnCount = 9
.Columns(0).Name = "Personnel"
.Columns(1).Name = "Code"
.Columns(2).Name = "Ref_Projet"
.Columns(3).Name = "Heures_Depart"
.Columns(4).Name = "Heures_FIN"
.Columns(5).Name = "Date_de_demarrage_Projet"
.Columns(6).Name = "Date_de_Fin_Projet"
.Columns(7).Name = "Total_jours"
.Columns(8).Name = "Designation_Tache"
.Columns(4).Width = 140
.Columns(4).Width = 140
End With
' Exemple : sélection d'une personne
Dim exempleEmploye As String = NameEmploye.Item(0).Key
' For Each item In ListePersonnel.Where(Function(x) x.Employers = exempleEmploye)
'With Me.DataGridView1.Rows
'.Add(item.Employers, item.Code, item.Ref_Projet, item.Heures_Depart, item.Heures_FIN, item.Date_de_Fin_Projet.ToString("dd/MM/yyyy"), _
' item.Date_de_demarrage_Projet.ToString("dd/MM/yyyy"), item.Total_jours, item.Designation_Tache)
' End With
' Next
For Each item In ListePersonnel
With Me.DataGridView1.Rows
.Add(item.Employers, item.Code, item.Ref_Projet, item.Heures_Depart, item.Heures_FIN, item.Date_de_Fin_Projet.ToString("dd/MM/yyyy"), _
item.Date_de_demarrage_Projet.ToString("dd/MM/yyyy"), item.Total_jours, item.Designation_Tache)
End With
Next
End Sub
Private Sub BtnSupprimer_Click(sender As Object, e As EventArgs) Handles BtnSupprimer.Click
Me.Hide()
End Sub
Private Sub BtnActualisation_Click(sender As Object, e As EventArgs) Handles BtnActualisation.Click
ComboPrenom.Items.Clear()
ComboNom.Items.Clear()
remplirComboNom()
remplirComboNomProjet()
remplirComboPrenom()
End Sub
End Class
'Code pour la 1ere Grid
Public Class Personnel
Public Property Employers As String
Public Property Code As String
Public Property Ref_Projet As String
Public Property Heures_Depart As String
Public Property Heures_FIN As String
Public Property Date_de_demarrage_Projet As Date
Public Property Date_de_Fin_Projet As Date
Public Property Total_jours As Integer
Public Property Designation_Tache As String
End Class |
Partager