Hello,
Ce matin, je code une modif qui devrait être sans problème et pourtant lors des tests, le dgv n'affiche pas l'info...
Ce qui doit être affiché :
Il s'agit en fait de détails de fichier coda (fichier d'opérations bancaires en Belgique). J'ai donc une liste de mouvements bancaires dont voici la définition
La liste des mouvements s'affiche sans problème dans un premier dgv. Mais lors de la sélection d'une ligne de mouvement, je veux bien sûr afficher les communications dans deux autres dgv (un pour chaque communication).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 Public Class Movement Public Property Id As Integer Public Property Amount As Decimal Public Property OperationDate As Date Public Property ComptabilisationDate As Date Public Property CommunicationMovement As CommunicationMovement Public Property CommunicationInformation As CommunicationInformation Public Property CounterPartName As String Public Property CounterPartAccount As String Public Sub New(id As Integer, amount As Decimal, operationdate As Date, comptabilisationdate As Date, counterpartname As String, counterpartaccount As String, commMovement As RawCommunication, commInformation As RawCommunication) Me.Id = id Me.Amount = amount Me.OperationDate = operationdate Me.ComptabilisationDate = comptabilisationdate Me.CounterPartName = counterpartname Me.CounterPartAccount = counterpartaccount Me.CommunicationMovement = CODA_VISUALIZER.CommunicationMovement.ParseCommunication(commMovement) Me.CommunicationInformation = CODA_VISUALIZER.CommunicationInformation.ParseCommunication(commInformation) End Sub End Class
Voici les communications (on va se contenter de celle de mouvement, c'est quasi pareil pour les autres) :
Et voici comment je procède pour l'affichage histoire que les choses soient bien présentées :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Public Class CommunicationMovement101 Inherits CommunicationMovement Public Property StructuredCode As String Public Property XActCode As String Public Sub New(comm As String) Me.StructuredCode = comm.Substring(0).Trim End Sub End Class Public Class CommunicationMovement102 Inherits CommunicationMovement Public Property StructuredCode As String Public Property XActCode As String Public Sub New(comm As String) Me.StructuredCode = comm.Substring(0).Trim End Sub End Class Public Class CommunicationMovement114 Inherits CommunicationMovement Public Property CardSchema As ECardSchema Public Property Pos As String Public Property PeriodNumber As Integer Public Property OperationSequenceNumber As Integer Public Property OperationDate As Date Public Property OperationTime As TimeSpan Public Property TerminalName As String Public Property TerminalZipCode As String Public Property OperationRef As String Public Enum ECardSchema As Integer Aucun = 0 BancontactMisterCash = 1 Maestro = 2 Privé = 3 TINA = 5 Autres = 9 End Enum Public Sub New(comm As String) CardSchema = CInt(comm.Substring(0, 1)) Pos = comm.Substring(1, 6).Trim PeriodNumber = CInt(comm.Substring(7, 3)) OperationSequenceNumber = CInt(comm.Substring(10, 6)) Dim day, month, year As String day = comm.Substring(16, 2) month = comm.Substring(18, 2) year = comm.Substring(20, 2) OperationDate = New Date(CInt(year) + 2000, CInt(month), CInt(day)) OperationTime = New TimeSpan(CInt(comm.Substring(22, 2)), CInt(comm.Substring(24, 2)), 0) TerminalName = comm.Substring(27, 16).Trim TerminalZipCode = comm.Substring(43, 10).Trim OperationRef = comm.Substring(53, 16) End Sub End Class
Ce qu'il se passe (ce qui est observable) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Private Sub dgvFile_RowEnter(sender As Object, e As DataGridViewCellEventArgs) Handles dgvFile.RowEnter If e.RowIndex > -1 Then movement = coda.GetMovementById(CInt(dgvFile.Rows(e.RowIndex).Cells("dgvcId").Value)) ShowComm(movement) End If End Sub Public Sub ShowComm(movement As Movement) If movement.CommunicationMovement IsNot Nothing Then dgvCommMovement.DataSource = Nothing Select Case movement.CommunicationMovement.GetType Case GetType(CommunicationMovement101) InitDgvCommMovement(102) dgvCommMovement.DataSource = CType(movement.CommunicationMovement, CommunicationMovement101) Case GetType(CommunicationMovement102) InitDgvCommMovement(102) dgvCommMovement.DataSource = CType(movement.CommunicationMovement, CommunicationMovement102) Case GetType(CommunicationMovement114) InitDgvCommMovement(114) dgvCommMovement.DataSource = CType(movement.CommunicationMovement, CommunicationMovement114) End Select End If End Sub Private Sub InitDgvCommMovement(type As Integer) With dgvCommMovement .AutoGenerateColumns = False .AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill With .Columns Dim index As Integer .Clear() Select Case type Case 101, 102 index = .Add("dgvcStructuredCode", "Code Structuré") .Item(index).DataPropertyName = "StructuredCode" index = .Add("dgvcXActCode", "Code transaction") .Item(index).DataPropertyName = "XActCode" Case 114 index = .Add("dgvcCardSchema", "Schéma de carte") .Item(index).DataPropertyName = "CardSchema" index = .Add("dgvcPos", "Pos") .Item(index).DataPropertyName = "Pos" index = .Add("dgvcPeriodNumber", "Numéro de période") .Item(index).DataPropertyName = "PeriodNumber" index = .Add("dgvcOperationDate", "Date de l'opération") .Item(index).DataPropertyName = "OperationDate" index = .Add("dgvcOperationTime", "Heure de l'opération") .Item(index).DataPropertyName = "OperationTime" index = .Add("dgvcTerminalName", "Nom du terminal") .Item(index).DataPropertyName = "TerminalName" index = .Add("dgvcTerminalZipCode", "Code postal du terminal") .Item(index).DataPropertyName = "TerminalZipCode" index = .Add("dgvcOperationRef", "Référence de l'opération") .Item(index).DataPropertyName = "OperationRef" End Select End With End With End Sub
Le dgv de la communication est correctement initialisé avec les bonnes colonnes. Malheureusement, aucune donnée n'est affichée. Je mets pourtant bien quelque chose dans la propriété DataSource.
J'ai déjà essayé plusieurs manières. Avec cast, sans cast, en déclarant une nouvelle variable du "bon" type et en mettant la communication dedans (en la castant ou non). Le résultat est toujours le même.
Quelque chose m'échappe forcément.
Merci de me remettre dans le droit chemin ^^.
Partager