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
| Dim X1, X2, B20 As String
Dim Mavariable As String=""
'Connexion à la base de données
Dim Mochamp As XPathNavigator = Me.MainDataSource.CreateNavigator()
Dim Pem24 As XPathNavigator = Mochamp.SelectSingleNode("/my:mesChamps/my:Zone", Me.NamespaceManager)
'Dim Pem25 As XPathNavigator = Mochamp.SelectSingleNode("/my:mesChamps/my:groupe1", Me.NamespaceManager)
'Dim pem26 As XPathNavigator = Mochamp.SelectSingleNode("/my:mesChamps/my:groupe1/my:groupe2", Me.NamespaceManager)
Dim pem27 As XPathNavigator = Mochamp.SelectSingleNode("/my:mesChamps/my:groupe1/my:groupe2/my:Unite", Me.NamespaceManager)
'Dim pem27 As XPathNavigator = Mochamp.SelectSingleNode("/my:mesChamps/my:groupe1", Me.NamespaceManager)
'Dim Pem102 As XPathNavigator = Mochamp.SetValue("/my:mesChamps/my:Num_demande")
B20 = Pem24.Value
Dim Tito As String
Dim TConnection As New SqlConnection
Dim TCommand As SqlCommand
Dim TReader As SqlDataReader
TConnection.ConnectionString = "Data Source=PEMCODEV\SQLEXPRESS;Initial Catalog=GESTETUDE;Integrated Security = true"
'Ouverture de la connexion à la base de données
Tito = "SELECT Code_compteur,Annee FROM COMPTEUR"
TConnection.Open()
TCommand = New SqlCommand(Tito, TConnection)
TReader = TCommand.ExecuteReader()
TReader.Read()
X1 = TReader.GetValue(0)
X2 = TReader.GetValue(1)
'traitement des resultats
TReader.Close()
If X2 < Date.Now.Year Then
X1 = 01
X2 = Date.Now.Year
Else
If X2 = Date.Now.Year Then
X1 = CDbl(X1) + 1
If Len(X1) = 1 Then X1 = "0" + X1
Else
'Affichage du message d'info à l'utilisateur
MessageBox.Show("Veuillez verifier la date?")
End If
End If
'Modifier les valeurs dans la table
Tito = " UPDATE COMPTEUR SET Code_compteur = '" & X1 & "',Annee='" & X2 & "'"
TCommand = New SqlCommand(Tito, TConnection)
TReader = TCommand.ExecuteReader()
If B20 = "LABORATOIRE" Then
'Affectation des données dans la variable
Mavariable = Right(X2, 2) & "-" & "LAB" & "-" & X1
Else
'recuperation des champs
Dim B25, B26, B27 As String
'B25 = Pem25.Value
'B26 = pem26.Value
B27 = pem27.Value
' Retrieve a reference to the Main DOM
Dim root As XPathNavigator = MainDataSource.CreateNavigator()
' Count the amount of group2 nodes
Dim iter As XPathNodeIterator = root.Select( _
"/my:mesChamps/my:groupe1/my:groupe2/my:Structure1", _
NamespaceManager)
Dim group2NodesCount As Integer = iter.Count
Dim X3 As Integer=0
X3 = iter.Count
' Retrieve the first group2 node
Dim firstGroup2NodeNav As XPathNavigator = _
root.SelectSingleNode("/my:mesChamps/my:groupe1/my:groupe2[1]", _
NamespaceManager)
' Retrieve the last group2 node
Dim lastGroup2NodeNav As XPathNavigator = _
root.SelectSingleNode("/my:mesChamps/my:groupe1/my:groupe2[" & _
group2NodesCount.ToString() & "]", _
NamespaceManager)
If X3 = 2 Then
Mavariable = Right(X2, 2) & "-" & "RAF" & "-" & X1
Else
Mavariable = Right(X2, 2) & "-" & Right(B27, 2) & "-" & X1
End If
End If
MonNumero = Mavariable
C7 = MonNumero
Dim myNav As XPathNavigator = Me.MainDataSource.CreateNavigator()
'affectation des champs du Numero de la demande....
myNav.SelectSingleNode("/my:mesChamps/my:Num_demande", Me.NamespaceManager). _
SetValue(Mavariable)
'Fermeture de la connection
TConnection.Close()
End Sub |
Partager