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
| Protected Sub enregistrer_Click(ByVal sender As Object, ByVal e As EventArgs) Handles enregistrer.Click
'-------------------------------------
' Variables declaration
'-------------------------------------
Dim objCommand As SqlCommand
Dim objParam As SqlParameter
Dim dt_KeywordsID As DataTable = New DataTable("piece")
Dim dtc_KeywordsID As DataColumn
Dim myConnection As SqlConnection = New SqlConnection("data source=UC033\DEV;integrated security=SSPI;initial catalog=BUDGET2")
'-------------------------------------
' Create a connection to SQL Server
'-------------------------------------
objCommand = New SqlCommand("dbo.spd_piece_insert", myConnection)
objCommand.CommandType = CommandType.StoredProcedure
objCommand.Connection.Open()
'-------------------------------------
' Create parameters for sp
'-------------------------------------
objParam = objCommand.Parameters.Add("@id_type_piece", SqlDbType.Int)
objParam.Value = lst_typePiece.SelectedValue
objParam = objCommand.Parameters.Add("@id_piece_anterieur ", SqlDbType.VarChar)
objParam.Value = lst_id_piece.SelectedValue
If (FileUpload.HasFile) Then
Dim blob As Byte() = FileUpload.FileBytes
objParam = objCommand.Parameters.Add("@piece_jointe", SqlDbType.VarBinary, blob.Length)
objParam.Value = blob
End If
objParam = objCommand.Parameters.Add("@commentaire ", SqlDbType.VarChar)
objParam.Value = commentaire.Text
objParam = objCommand.Parameters.Add("@date_creation", SqlDbType.DateTime)
objParam.Value = ConfirmationDate.Text
objParam = objCommand.Parameters.Add("@createur_piece ", SqlDbType.Char, 10)
objParam.Value = createur.Text
'-------------------------------------
' Prepare table as parameter
'-------------------------------------
dtc_KeywordsID = New DataColumn()
dtc_KeywordsID.ColumnName = "id_piece"
dt_KeywordsID.Columns.Add(dtc_KeywordsID)
'-------------------------------------
' Store procedure execution
'-------------------------------------
objCommand.ExecuteNonQuery()
'-------------------------------------
' Close the connexion object
'-------------------------------------
objCommand.Connection.Close()
'---------------------------------------------------------------
'direction vers le formulaire de saisie du detail de la piéce
'---------------------------------------------------------------
Response.Redirect("DetailPiece.aspx")
End Sub |
Partager