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
| Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnNouvLigne.Click
Try
Dim resultat As String
con.Open()
cmd = New SqlCommand("insert into ligneRapport values('" & Me.TextBox10.Text & "','" & Me.TextBox1.Text & "','" & Me.TextBox7.Text & "','" & Me.DateTimePicker1.Value.Date.ToString & "','" & Me.DateTimePicker2.Value.Date.ToString & "')")
cmd.Connection = con
trans = cmd.Transaction
cmd.Transaction = con.BeginTransaction
cmd.ExecuteNonQuery()
cmd = New SqlCommand("insert into clients values('" & Me.TextBox4.Text & "' , '" & Me.TextBox5.Text & "' , '" & Me.TextBox10.Text & "')")
cmd.Connection = con
cmd.ExecuteNonQuery()
cmd = New SqlCommand("insert into fraisDeplacement values('" & Me.TextBox10.Text & "' , '" & Me.TextBox3.Text & "' , '" & Me.TextBox6.Text & "' , '" & Me.TextBox11.Text & "' , '" & Me.TextBox12.Text & "' , '" & Me.TextBox13.Text & "' , '" & Me.TextBox14.Text & "' , '" & Me.TextBox15.Text & "' , '" & Me.TextBox16.Text & "')")
cmd.Connection = con
cmd.ExecuteNonQuery()
''appel de la procédure qui control la saisie de la semaine
cmd = New SqlCommand("exec CtrlSemaine @id_pers,@sort output")
cmd.Parameters.Add("@id_pers", SqlDbType.VarChar, 50)
cmd.Parameters.Add("@sort", SqlDbType.VarChar, 50)
cmd.Connection = con
cmd.Parameters("@id_pers").Direction = ParameterDirection.Input
cmd.Parameters("@sort").Direction = ParameterDirection.Output
cmd.Parameters("@id_pers").Value = Me.TextBox2.Text
cmd.ExecuteNonQuery()
trans.Commit()
resultat = cmd.Parameters("@sort").Value
If Me.MaskedTextBox1.Text = resultat Or Me.MaskedTextBox1.Text < resultat Then
MsgBox("semaine incorrecte!!!!!", MsgBoxStyle.Exclamation)
Else
MsgBox("Ajout avec succès", MsgBoxStyle.Information)
End If
cmd.Parameters.Clear()
Catch ex As Exception
trans.Rollback()
End Try
con.Close()
End Sub |
Partager