Professional Documents
Culture Documents
NET
MenuUtama.vb
Imports System.Data.OleDb
Imports System.Data
FormBarang.vb
Public Class FormBarang
Dim A As New ClassBarang
Private Sub FormBarang_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
BukaKONEKSI()
End Sub
Sub KOSONG()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button1.Click
A.Kd = TextBox1.Text
A.Tgl = TextBox2.Text
A.Jml = TextBox3.Text
A.simpan()
KOSONG()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button2.Click
A.Kd = TextBox1.Text
A.Tgl = TextBox2.Text
A.Jml = TextBox3.Text
A.ubah()
KOSONG()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button3.Click
A.Kd = TextBox1.Text
A.Tgl = TextBox2.Text
A.Jml = TextBox3.Text
A.hapus()
KOSONG()
End Sub
ClassBarang.vb
Imports System.Data.OleDb
Imports System.Data
#Region "Property"
Public Property Kd() As String
Get
Return _Kd
End Get
Set(ByVal value As String)
_Kd = value
End Set
End Property
Public Property Tgl() As String
Get
Return _Tgl
End Get
Set(ByVal value As String)
_Tgl = value
End Set
End Property
Public Property Jml() As String
Get
Return _Jml
End Get
Set(ByVal value As String)
_Jml = value
End Set
End Property
#End Region
#Region "Method"
Public Function simpan() As Integer '-----LISTING UNTUK SIMPAN
Q = "INSERT INTO BARANG VALUES('" & _Kd & "','" & _Tgl & "','" & _Jml & "')"
Command = New OleDbCommand(Q, conn)
Return Command.ExecuteNonQuery
End Function
Module KONEKSI
Public strconn As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &
Application.StartupPath & "\Penjualan.accdb;"
Public conn As OleDbConnection
Sub BukaKONEKSI()
conn = New OleDbConnection(strconn)
If conn.State <> ConnectionState.Closed Then conn.Close()
conn.Open()
End Sub
End Module