Professional Documents
Culture Documents
Data Supplier
Data Supplier
DATA SUPPLIER
Keterangan
Nama Komponen Properties
TextBox1 Name : TxtID
TextBox2 Name :
txtNamaSupplier
TextBox3 Name : txtAlamat
TextBox4 Name : txtTelp
ComboBox1 Name : CmbProduk
Items : MAKANAN
MINUMAN
ACCESSORIES
FASHION
Button1 Text : Simpan
Name : BtnSimpan
Button2 Text : Simpan
Name : BtnSimpan
Button3 Text : Simpan
Name : BtnSimpan
Button4 Text : Simpan
Name : BtnSimpan
8. Code Program;
a. Klik Project ->Add Module : Name : Module1 Klik Tombol Add dan ketik baris code berikut;
Imports System.Data.OleDb
Module Module1
Public cn As OleDbConnection
Public cmd As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Public tb As DataTable
b. Kemudian ketika baris code pada form load (Double click pada area form kosong), sebagai berikut;
Imports System.Data.OleDb
Public Class Form4
Sub lihat_supplier()
cmd = New OleDbCommand("SELECT * FROM supplier", cn)
cmd.ExecuteNonQuery()
da = New OleDbDataAdapter(cmd)
tb = New DataTable
da.Fill(tb)
DataGridView1.DataSource = tb
End Sub
Sub bersih()
txtID.Clear()
TxtNamaSupplier.Clear()
TxtAlamat.Clear()
TxtTelp.Clear()
CmbProduk.Text = ""
End Sub
cmd.ExecuteNonQuery()
lihat_supplier()
bersih()
d. Baris code pada DataGridview1 untuk memilih data (Double click pada DatagGridview1);
txtID.Text = DataGridView1.CurrentRow.Cells(0).Value
TxtNamaSupplier.Text = DataGridView1.CurrentRow.Cells(1).Value
TxtAlamat.Text = DataGridView1.CurrentRow.Cells(2).Value
TxtTelp.Text = DataGridView1.CurrentRow.Cells(3).Value
CmbProduk.Text = DataGridView1.CurrentRow.Cells(4).Value
txtID.Enabled = False
BtnSimpan.Enabled = False
TxtNamaSupplier.Focus()
e. Baris code pada tombol Ubah;
cmd = New OleDbCommand("update supplier set
nama_supplier=@nama_supplier,alamat=@alamat,no_telp=@no_telp,supplier_produk=@supplier_pro
duk where id_supplier=@id_supplier", cn)
cmd.Parameters.AddWithValue("@nama_supplier", TxtNamaSupplier.Text)
cmd.Parameters.AddWithValue("@alamat", TxtAlamat.Text)
cmd.Parameters.AddWithValue("@no_telp", TxtTelp.Text)
cmd.Parameters.AddWithValue("@supplier_produk", CmbProduk.Text)
cmd.Parameters.AddWithValue("@id_supplier", txtID.Text)
cmd.ExecuteNonQuery()
lihat_supplier()
txtID.Enabled = True
BtnSimpan.Enabled = True
bersih()
MsgBox("data Supplier berhasil diubah..!", vbOKOnly + vbInformation, "Ubah")
--Selamat mengerjakan--