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
| Private Sub Buttonload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Buttonload.Click
Initialisernouveaupatient()
' Fichier Excel
Dim CheminFicher As String
Dim BoiteDialogue As New OpenFileDialog
txtDocteur2.Text = txtDocteur.Text
If AppExcel IsNot Nothing Then
MessageBox.Show("Excel Worksheet is closing please wait")
If xlWorkSheetOne IsNot Nothing Then
xlWorkSheetOne = Nothing
End If
If xlWorkbook IsNot Nothing Then
xlWorkbook.Close()
xlWorkbook = Nothing
End If
AppExcel.Quit()
AppExcel = Nothing
End If
With BoiteDialogue
' Initialisation de la boite de dialogue
.Title = "Load Data"
.InitialDirectory = "\D:\encours\"
.Filter = "Fichiers Excel |*.xls; *.xlsx"
' vérification de la séléction
If .ShowDialog() = System.Windows.Forms.DialogResult.OK Then
CheminFicher = .FileName
Else
MessageBox.Show("Aucun fichier Excel séléctionné")
Exit Sub ' Abandon de la routine
End If
'ouvre l'onglet 1 de l'application
AppExcel = New OXL.Application
xlWorkbook = AppExcel.Workbooks.Open(CheminFicher)
xlWorkSheetOne = CType(xlWorkbook.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
AppExcel.Visible = False
'chargement des data en Textbox
Dim rng As OXL.Range = Nothing
rng = CType(Me.xlWorkSheetOne.Cells(10, 4), Microsoft.Office.Interop.Excel.Range)
Me.tbDestinaraire.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(10, 6), Microsoft.Office.Interop.Excel.Range)
Me.txtPRENOM.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(10, 7), Microsoft.Office.Interop.Excel.Range)
Me.txtNOM.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(10, 8), Microsoft.Office.Interop.Excel.Range)
Me.TxtNAISSANCE.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(10, 10), Microsoft.Office.Interop.Excel.Range)
Me.Txtpseudo.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(10, 14), Microsoft.Office.Interop.Excel.Range)
Me.Txtrelift.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 16), Microsoft.Office.Interop.Excel.Range)
Me.TextBoxosod.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 2), Microsoft.Office.Interop.Excel.Range)
Me.S.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 3), Microsoft.Office.Interop.Excel.Range)
Me.C.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 4), Microsoft.Office.Interop.Excel.Range)
Me.AXE.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 8), Microsoft.Office.Interop.Excel.Range)
Me.SC.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 9), Microsoft.Office.Interop.Excel.Range)
Me.CC.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 10), Microsoft.Office.Interop.Excel.Range)
Me.AC.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 5), Microsoft.Office.Interop.Excel.Range)
Me.DVA.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 6), Microsoft.Office.Interop.Excel.Range)
Me.ADD.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 7), Microsoft.Office.Interop.Excel.Range)
Me.NVA.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 14), Microsoft.Office.Interop.Excel.Range)
Me.K1.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(16, 15), Microsoft.Office.Interop.Excel.Range)
Me.K2.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 2), Microsoft.Office.Interop.Excel.Range)
Me.QIRIGHT.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 10), Microsoft.Office.Interop.Excel.Range)
Me.QILEFT.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 9), Microsoft.Office.Interop.Excel.Range)
Me.PACHY.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 8), Microsoft.Office.Interop.Excel.Range)
Me.ACD.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 7), Microsoft.Office.Interop.Excel.Range)
Me.AL.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 4), Microsoft.Office.Interop.Excel.Range)
Me.Pupilphoto.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 5), Microsoft.Office.Interop.Excel.Range)
Me.Pupilmeso.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(22, 6), Microsoft.Office.Interop.Excel.Range)
Me.Pupilmax.Text = CType(rng.Value, String)
rng = CType(Me.xlWorkSheetOne.Cells(10, 3), Microsoft.Office.Interop.Excel.Range)
If Not txtDocteur.Items.Contains(rng.Value) Then
txtDocteur.Items.Add(rng.Value)
txtDocteur2.Text = txtDocteur.Text
End If
txtDocteur.SelectedItem = (rng.Value)
txtDocteur2.Text = txtDocteur.Text
'Affichage de Etiqoeiltraite
If TextBoxosod.Text = "OS" Then
indiceoeil = 0
Etiqoeiltraite.Text = "OS"
Etiqoeiltraite.ForeColor = Color.Lime
PictureBoxleft.Visible = True
PictureBoxleft2.Visible = False
PictureBoxright.Visible = False
PictureBoxright2.Visible = True
End If
If TextBoxosod.Text = "OD" Then
indiceoeil = 1
Etiqoeiltraite.Text = "OD"
Etiqoeiltraite.ForeColor = Color.Lime
PictureBoxleft2.Visible = True
PictureBoxleft.Visible = False
PictureBoxright2.Visible = False
PictureBoxright.Visible = True
End If
'calcul de deltaqi
If Txtrelift.Text = "N" Then
deltaqi.Text = (Math.Abs(CDbl(QILEFT.Text)) - Math.Abs(CDbl(QIRIGHT.Text))).ToString("0.00")
End If
If Txtrelift.Text = "Y" Then
deltaqi.Text = "0.00"
End If
'cas de traitement pseudophake
If Txtpseudo.Text = "Y" Then
Pseudo.Checked = True
Pseudo.ForeColor = Color.Lime
Else
Pseudo.Checked = False
Pseudo.ForeColor = Color.White
End If
'cas de relift
If Txtrelift.Text = "N" Then
relift.Checked = False
relift.ForeColor = Color.White
Else
relift.Checked = True
relift.ForeColor = Color.LimeGreen
End If
CloseAppExcel()
System.Threading.Thread.Sleep(2000)
Dim dossierDest As String = "\D:\traites"
Dim nomFichierCourt As String = System.IO.Path.GetFileName(CheminFicher)
Dim cheminCompletFichierDest = System.IO.Path.Combine(dossierDest, nomFichierCourt)
If System.IO.Directory.Exists(dossierDest) Then
If System.IO.File.Exists(cheminCompletFichierDest) Then
System.IO.File.Delete(cheminCompletFichierDest)
End If
System.IO.File.Move(CheminFicher, cheminCompletFichierDest)
End If
Calcul.Focus()
End With
UOZMAX.Text = ""
UOZMIN.Text = ""
UOZMEAN.Text = ""
End Sub |
Partager