Advertisement
Guest User

valpacino

a guest
May 27th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. Private Sub insert_Click()
  2.  
  3. Dim cnx As ADODB.Connection
  4. Dim rst As ADODB.Recordset
  5. Set cnx = New ADODB.Connection
  6. Set rst = New ADODB.Recordset
  7. Dim NomUtilisateur As String, MotDePasse As String, NomServeur As String, NomBaseDeDonnées As String
  8. NomUtilisateur = "intranet"
  9. MotDePasse = "intranet"
  10. NomServeur = "x71vyscsa0b"
  11. NomBaseDeDonnées = "INTRANET_ASSURANCE_RECETTE"
  12.  
  13.  
  14. cnx.ConnectionString = "UID=" & NomUtilisateur & ";PWD=" & MotDePasse & ";" & "DRIVER={SQL Server};Server=" & NomServeur & ";Database=" & NomBaseDeDonnées & ";"
  15. cnx.Open
  16.  
  17. admin = False
  18. rst.Open "SELECT cp FROM admin", cnx
  19. While Not (rst.EOF Or admin = True)
  20. If (rst(0) = Environ$("UserName")) Then
  21. admin = True
  22. Else
  23. rst.MoveNext
  24. End If
  25. Wend
  26. rst.Close
  27.  
  28. If (admin = False) Then
  29. MsgBox "Vous n'avez pas les droits d'insertion !"
  30. Exit Sub
  31. End If
  32.  
  33.  
  34. Range("C3").Select
  35. nomDemandeur = ActiveCell.Offset(0, 0).Value
  36. prenomDemandeur = ActiveCell.Offset(1, 0).Value
  37. cpDemandeur = ActiveCell.Offset(2, 0).Value
  38. telephoneDemandeur = ActiveCell.Offset(3, 0).Value
  39.  
  40. Range("D3").Select
  41. nomChefEssai = ActiveCell.Offset(0, 0).Value
  42. prenomChefEssai = ActiveCell.Offset(1, 0).Value
  43. cpChefEssai = ActiveCell.Offset(2, 0).Value
  44.  
  45. Range("E7").Select
  46. nomEssai = ActiveCell.Offset(0, 0).Value
  47. numeroRame = ActiveCell.Offset(1, 0).Value
  48.  
  49. Range("F9").Select
  50. dateDebut = ActiveCell.Offset(0, 0).Value
  51. dateFin = ActiveCell.Offset(1, 0).Value
  52.  
  53. Range("G11").Select
  54. numPrestation = ActiveCell.Offset(0, 0).Value
  55. motif = ActiveCell.Offset(1, 0).Value
  56. obs = ActiveCell.Offset(2, 0).Value
  57.  
  58. Dim nomArray() As String
  59. Dim prenomArray() As String
  60. Dim entrepriseArray() As String
  61. Dim roleObsArray() As String
  62.  
  63. Range("C17").Select
  64. Dim i As Integer
  65. i = 0
  66.  
  67. While (ActiveCell.Offset(i, 0) <> "")
  68. i = i + 1
  69. Wend
  70.  
  71. ReDim nomArray(i)
  72. ReDim prenomArray(i)
  73. ReDim entrepriseArray(i)
  74. ReDim roleObsArray(i)
  75.  
  76. i = 0
  77. While (ActiveCell.Offset(i, 0) <> "")
  78. nomArray(i) = ActiveCell.Offset(i, 0)
  79. i = i + 1
  80. Wend
  81.  
  82. i = 0
  83. Range("D17").Select
  84. While (ActiveCell.Offset(i, 0) <> "")
  85. prenomArray(i) = ActiveCell.Offset(i, 0)
  86. i = i + 1
  87. Wend
  88.  
  89. i = 0
  90. Range("E17").Select
  91. While (ActiveCell.Offset(i, 0) <> "")
  92. entrepriseArray(i) = ActiveCell.Offset(i, 0)
  93. roleObsArray(i) = ActiveCell.Offset(i, 1)
  94. MsgBox roleObsArray(i)
  95. i = i + 1
  96. Wend
  97.  
  98. Dim values As New Dictionary
  99. values("Demandeur") = nomDemandeur & "," & prenomDemandeur & "," & cpDemandeur & "," & telephoneDemandeur & ","
  100. values("ChefEssai") = nomChefEssai & "," & prenomChefEssai & "," & cpChefEssai & ","
  101. values("Infos") = nomEssai & "," & numeroRame & ","
  102. values("DatesDebutFin") = dateDebut & "," & dateFin & ","
  103. values("Presta") = numPrestation & "," & motif & "," & obs & ","
  104. values("Noms") = Join(nomArray, ",")
  105. values("Prenoms") = Join(prenomArray, ",")
  106. values("Entreprises") = Join(entrepriseArray, ",")
  107. values("RoleObs") = Join(roleObsArray, ",")
  108.  
  109. Dim hReq As Object
  110.  
  111. Dim strUrl As String
  112. strUrl = "http://x71vyscsa0b:8080/autorisation_1231/Modele/giveMeData.php?demandeur=" & values("Demandeur") & "&chefessai=" & values("ChefEssai") & "&infos=" & values("Infos") & "&datesDebutFin=" & values("DatesDebutFin") & "&presta=" & values("Presta") & "&noms=" & values("Noms") & "&prenoms=" & values("Prenoms") & "&entreprises=" & values("Entreprises") & "&roleObs=" & values("RoleObs")
  113.  
  114. Set hReq = CreateObject("Microsoft.XMLHTTP")
  115. With hReq
  116. .Open "POST", strUrl, False
  117. .SetRequestHeader "Content-Type", "text/xml; charset=utf-8"
  118. .Send
  119. End With
  120.  
  121. MsgBox "Données transmises avec succès !"
  122. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement