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
| Imports System
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Inherits System.Windows.Forms.Form
Public conn As SqlConnection
Public CmdS As SqlCommand
Public da As SqlDataAdapter
Public ds As New DataSet()
Public strSql As String
Public strConn As String = "Initial Catalog=FAVRE;Data Source=Serveur-corc;User ID=sa;Password=;"
Public Poids As Integer
Public DateForm As String
Public JJ As String
Public MM As String
Public AA As String
Public NomCol(6) As String
Public i As Short
Public Dossier As String
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
Dim Annee As String
NomCol(0) = "Dossier"
NomCol(1) = "N° client"
NomCol(2) = "Séquence"
NomCol(3) = "N° liste ingénieur"
NomCol(4) = "Date"
NomCol(5) = "Poids (kg)"
Annee = DateTimePicker1.Value
JJ = Annee.Substring(0, 2)
MM = Annee.Substring(3, 2)
AA = Annee.Substring(6, 4)
Annee = AA & MM & JJ
strSql = "SELECT ESRC_FILE, RC_NUM, PS_CODE, PS_TITLE, DELIVASKED, INVWEIGHT FROM REF_PS WHERE DELIVASKED = " & Annee
Connexion(strConn, strSql)
MiseForme()
End Sub
Private Sub Connexion(ByVal strConn As String, ByVal strSql As String)
conn = New SqlConnection(strConn)
conn.Open()
CmdS = New SqlCommand(strSql)
da = New SqlDataAdapter(CmdS)
CmdS.Connection() = conn
da.Fill(ds, "REF_PS")
End Sub
Private Sub MiseForme()
Poids = 0
With ds.Tables("REF_PS")
For i = 0 To .Rows.Count - 1
DateForm = .Rows(i).Item("DELIVASKED")
JJ = DateForm.Substring(6, 2)
MM = DateForm.Substring(4, 2)
AA = DateForm.Substring(0, 4)
DateForm = JJ & "/" & MM & "/" & AA
.Rows(i).Item("DELIVASKED") = DateForm
Poids = Poids + .Rows(i).Item("INVWEIGHT")
Next
End With
With ds.Tables("REF_PS")
For i = 0 To .Columns.Count - 1
.Columns(i).ColumnName = NomCol(i)
Next
End With
Dim Vue As New DataView(ds.Tables("REF_PS"))
DataGridView1.DataSource = Vue
Poids = Poids / 1000
TextBox4.Text = Poids
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dossier = "CHT" & TextBox1.Text
strSql = "SELECT ESRC_FILE, RC_NUM, PS_CODE, PS_TITLE, DELIVASKED, INVWEIGHT FROM REF_PS WHERE ESRC_FILE = " & Dossier & " AND PS_TITLE LIKE " & TextBox2.Text
Connexion(strConn, strSql)
MiseForme()
End Sub
End Class |
Partager