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
| Sub Charger()
Dim Obj_Etor_Bloc As New Etor_Bloc
Dim Obj_Etor As New Etor
Dim idx_row As Integer
Dim total_ligne = My_Frm_confAPI.DGV_Rgt_Etor.Rows.Count - 1
ReDim resultat(1, total_ligne)
Try
For Each dtgr As DataGridViewRow In MonDGV.Rows
'Sort du traitement si c'est la dernière ligne, car elle ne doit pas être traitée.
If dtgr.Index = MonDGV.Rows.Count - 1 Then
Return
End If
'Calcul pour chaque ligne en fonction des BR ou des BL
' on stocke les valeurs dans un tableau bidimensionnel, si la valeur existe déjà, retourne un message d'erreur
If dtgr.Cells("T_BR").Value = True Then
idx_row = dtgr.Index
resultat(0, idx_row) = MonCalcul
'On test si la valeur calculée n'est pas déjà contenue dans le tableau.
For i As Integer = 0 To resultat.GetUpperBound(0)
If Not (i = idx_row) Then
If resultat(0, i) = resultat(0, idx_row) Then
MessageBox.Show("[ERREUR] : le calcul obtient un doublon au rang : " & Obj_Etor.Rang)
ElseIf resultat(1, i) = resultat(0, idx_row) Then
MessageBox.Show("[ERREUR] : le calcul obtient un doublon au rang : " & Obj_Etor.Rang)
End If
End If
Next i
ElseIf dtgr.Cells("T_BR").Value = False Then
idx_row = dtgr.Index
resultat(1, idx_row) = MonCalcul2
For i As Integer = 0 To resultat.GetUpperBound(0)
If Not (i = idx_row) Then
If resultat(0, i) = resultat(0, idx_row) Then
MessageBox.Show("[ERREUR] : le calcul obtient un doublon au rang : " & Obj_Etor.Rang)
ElseIf resultat(1, i) = resultat(0, idx_row) Then
MessageBox.Show("[ERREUR] : le calcul obtient un doublon au rang : " & Obj_Etor.Rang)
End If
End If
Next i
End If
Next dtgr
Catch ex As Exception
MessageBox.Show(ex.Message, ex.Source)
End Try
End Sub |
Partager