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
|
'on peut lancer le rapport
Dim requete As String = ""
If CheckBox1.Checked = True Then
'On récupère les personnes ayant ce référentiel
Dim requete2 As String = "SELECT `evalution_complete`.`Matricule`, `evalution_complete`.`ENTREPRISE` FROM `userdb41`.`evalution_complete` where " & SELECT_ENT & " and year(`evalution_complete`.`DATE`) = '" & cmb_annee.Text & "' and `evalution_complete`.`COMP_PURE` IN (SELECT `comp`.`NOM` FROM userdb41.association_vue, `userdb41`.`comp`, `userdb41`.`view` where `view`.`idVIEW` = `association_vue`.`id_view` and `comp`.`ID` = `association_vue`.`id_comp` and `view`.`idVIEW` = '" & Me.LV_1.Items(LV_1.SelectedIndices(0)).Text & "') group by `evalution_complete`.`Matricule` having count(`evalution_complete`.`COMP_PURE`) >= (SELECT count(*) FROM userdb41.association_vue where id_view='" & Me.LV_1.Items(LV_1.SelectedIndices(0)).Text & "') "
'Dim requete3 As String = "SELECT `evalution_complete`.`Matricule`, `evalution_complete`.`SECTEUR`, `evalution_complete`.`DATE`, `evalution_complete`.`COMP_PURE`, `evalution_complete`.`DOM_COMP_PURE`, `evalution_complete`.`EVALUTION`, `evalution_complete`.`ENTREPRISE` FROM `userdb41`.`evalution_complete` where " & SELECT_ENT & " and year(`evalution_complete`.`DATE`)='" & cmb_annee.Text & "' and `evalution_complete`.`COMP_PURE` IN (SELECT `comp`.`NOM` FROM userdb41.association_vue, `userdb41`.`comp`, `userdb41`.`view` where `view`.`idVIEW` = `association_vue`.`id_view` and `comp`.`ID` = `association_vue`.`id_comp` and `view`.`idVIEW` = '" & Me.LV_1.Items(LV_1.SelectedIndices(0)).Text & "') "
Dim file_destination = Form1.chemin_travail & "\Rapport Personnalisé.xlsx"
get_model("liste_des_competences_de_l_entreprise.xlsx", "\Rapport Personnalisé.xlsx")
'on ouvre le fichier excel
Lbl_Progression.Text = "Ouverture d'Excel"
Lbl_Progression.Refresh()
Dim AppExcel As New Microsoft.Office.Interop.Excel.Application
Dim wbExcel As Microsoft.Office.Interop.Excel.Workbook
Dim wsExcel As Microsoft.Office.Interop.Excel.Worksheet
wbExcel = AppExcel.Workbooks.Open(file_destination)
wsExcel = wbExcel.Worksheets("Source")
Me.Cursor = Cursors.WaitCursor
'Try
Dim connection_entreprise2 As MySqlConnection = GetConnect()
connection_entreprise2.Open()
'On execute la requete
Dim CmdSql_entreprise2 As New MySqlCommand(requete2, connection_entreprise2)
Dim DrSql_entreprise2 = CmdSql_entreprise2.ExecuteReader()
While (DrSql_entreprise2.Read())
'maintenant on lance le rapport pour chaque personne ayant ce référentiel
requete = "SELECT `evalution_complete`.`Matricule`, `evalution_complete`.`SECTEUR`, `evalution_complete`.`DATE`, `evalution_complete`.`COMP_PURE`, `evalution_complete`.`DOM_COMP_PURE`, `evalution_complete`.`EVALUTION`, `evalution_complete`.`ENTREPRISE` FROM `userdb41`.`evalution_complete` where `evalution_complete`.`Matricule`='" & DrSql_entreprise2.GetString(0).Replace("'", "\'") & "' and `evalution_complete`.`ENTREPRISE`='" & DrSql_entreprise2.GetString(1).Replace("'", "\'") & "' and year(`evalution_complete`.`DATE`)='" & cmb_annee.Text & "' and `evalution_complete`.`COMP_PURE` IN (SELECT `comp`.`NOM` FROM userdb41.association_vue, `userdb41`.`comp`, `userdb41`.`view` where `view`.`idVIEW` = `association_vue`.`id_view` and `comp`.`ID` = `association_vue`.`id_comp` and `view`.`idVIEW` = '" & Me.LV_1.Items(LV_1.SelectedIndices(0)).Text & "') "
Try
'Ouverture de la connexion
Dim connection_entreprise As MySqlConnection = GetConnect()
connection_entreprise.Open()
'On execute la requete
Dim CmdSql_entreprise As New MySqlCommand(requete, connection_entreprise)
Dim DrSql_entreprise = CmdSql_entreprise.ExecuteReader()
Dim ligne_courante = 2
Lbl_Progression.Text = "Mise en place des informations, cette opération peut prendre plusieurs minutes.."
Lbl_Progression.Refresh()
'On le remplit avec la requete
While (DrSql_entreprise.Read())
Lbl_Progression.Text = DrSql_entreprise.GetString(0) & ":" & DrSql_entreprise.GetString(3)
Lbl_Progression.Refresh()
wsExcel.Cells(ligne_courante, 1).value = DrSql_entreprise.GetString(0)
wsExcel.Cells(ligne_courante, 2).value = DrSql_entreprise.GetString(1)
wsExcel.Cells(ligne_courante, 3).value = DrSql_entreprise.GetString(2)
wsExcel.Cells(ligne_courante, 4).value = DrSql_entreprise.GetString(3)
wsExcel.Cells(ligne_courante, 5).value = DrSql_entreprise.GetString(4)
wsExcel.Cells(ligne_courante, 6).value = DrSql_entreprise.GetString(5)
Select Case DrSql_entreprise.GetString(5)
Case "0"
wsExcel.Cells(ligne_courante, 7).value = "0- Non Concerné"
Case "1"
wsExcel.Cells(ligne_courante, 7).value = "1- Ne maitrise pas"
Case "2"
wsExcel.Cells(ligne_courante, 7).value = "2- A perfectionner"
Case "3"
wsExcel.Cells(ligne_courante, 7).value = "3- Maitrise"
Case "4"
wsExcel.Cells(ligne_courante, 7).value = "4- Expert"
End Select
ligne_courante += 1
wbExcel.RefreshAll()
End While
connection_entreprise.Close()
connection_entreprise.Dispose()
connection_entreprise = Nothing
Lbl_Progression.Text = "Enregistrement du fichier Excel"
wbExcel.RefreshAll()
wbExcel.Save()
AppExcel.Quit()
AppExcel = Nothing
clearExcel()
Catch ex As Exception
MsgBox(ex.Message)
Clipboard.Clear()
clearExcel()
wbExcel = Nothing
Me.Cursor = Cursors.Default
End Try
End While
Try
Catch ex As Exception
Lbl_Progression.Text = "Enregistrement du fichier Excel"
Me.Cursor = Cursors.Default
Lbl_Progression.Text = "Traitement terminé"
End Try |
Partager