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
| Imports System.Data.OleDb
Imports System.Data
Imports Microsoft.VisualBasic
Imports System
Public Class entretien
Private Action As String
Private km As Long
Private date_ent As Date
Private heuredebut As Integer
Private heurefin As Integer
Private tarif As Integer
Private mtent As Double
Public Sub recuperertarif(ByVal action As String)
Dim cnx As New OleDbConnection
Dim commande As OleDbCommand
Dim dr As OleDbDataReader
cnx = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source = c:\minoja\Documents\entretienvoiture.mdb ")
cnx.Open()
If cnx.State <> ConnectionState.Open Then
MsgBox("impossible d'etablir une connexion")
Else
commande = cnx.CreateCommand()
Dim req As String
req = "SELECT Prix FROM Tintervention WHERE Action = '" + action + "' "
commande.CommandText = req
dr = commande.ExecuteReader()
dr.Read()
tarif = dr.GetInt32(0)
dr.Close()
cnx.Close()
End If
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
End Sub
Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim req As String
Dim cmd1 As New OleDbCommand()
Dim cnx As New OleDbConnection
Try
{
cnx = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source = c:\minoja\Documents\entretienvoiture.mdb ")
cnx.Open()
cmd1 = cnx.CreateCommand()
req = " INSERT INTO Tintervention(Action,Km,Prix) VALUES (' + TextBox1.Text + ',' + TextBox2.Text + ','+ TextBox3.Text + ');"
cmd1.CommandText = req
cmd1.ExecuteNonQuery()
Catch e As OleDbException
MsgBox(e.Message, MsgBoxStyle.Critical, "Oledb Error")
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical, "General Error")
End Try
End Sub
End Class |
Partager