Sistem Informasi Inventori Pada Toko Panglong 4 Dara Menggunakan Microsoft Visual Basic 2010

L
A
M
P
I
R
A
N

Universitas Sumatera Utara

1

Listing Program

1. Form Menu
Public Class frm_menu
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
frm_login.Show()
Me.Hide()

End Sub
End Class

2. Form Login
Imports System.Data.OleDb
Public Class frm_login
Dim exp As OleDbCommand
Dim dr As OleDbDataReader
Private Sub frm_login_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cekKoneksi()
End Sub
Private Sub btn_login_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_login.Click
Try
exp = New OleDbCommand("SELECT * FROM tbl_user
WHERE [username]='" & TextBox1.Text & "'
AND [password]='" & TextBox2.Text & "'",

koneksi)
dr = exp.ExecuteReader
If dr.HasRows Then
'jika data yang diinput benar,
maka proses dibawah dikerjakan,utk memanggil
dr.Read()
Me.Hide()
Dim F_Utama As New MDIParent1
F_Utama.Show()
Else
MsgBox("Pastikan data anda benar",
MsgBoxStyle.Information, "Pesan")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Select()
End If
dr.Close()
Catch ex As Exception
'memunculkan pesan kesalahan
jika step 1 ada kesalahan tetapi program tetap berjalan

MsgBox(ex.Message)

Universitas Sumatera Utara

2

End Try
End Sub
End Class

3. Form MDI Parent
Imports System.Windows.Forms
Public Class MDIParent1
Private Sub ShowNewForm(ByVal sender As Object, ByVal e
As EventArgs)
' Create a new instance of the child form.
Dim ChildForm As New System.Windows.Forms.Form
' Make it a child of this MDI form before showing
it.
ChildForm.MdiParent = Me

m_ChildFormNumber += 1
ChildForm.Text = "Window " & m_ChildFormNumber
ChildForm.Show()
End Sub
Private Sub OpenFile(ByVal sender As Object, ByVal e As
EventArgs)
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "Text Files
(*.txt)|*.txt|All Files (*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = OpenFileDialog.FileName
' TODO: Add code here to open the file.
End If
End Sub
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender
As Object, ByVal e As EventArgs)
Dim SaveFileDialog As New SaveFileDialog

SaveFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files
(*.txt)|*.txt|All Files (*.*)|*.*"
If (SaveFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = SaveFileDialog.FileName
' TODO: Add code here to save the current
contents of the form to a file.
End If
End Sub
Private Sub ExitToolsStripMenuItem_Click(ByVal sender As
Object, ByVal e As EventArgs)
End

Universitas Sumatera Utara

3

End Sub

Private Sub CutToolStripMenuItem_Click(ByVal sender As
Object, ByVal e As EventArgs)
' Use My.Computer.Clipboard to insert the selected
text or images into the clipboard
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As
Object, ByVal e As EventArgs)
' Use My.Computer.Clipboard to insert the selected
text or images into the clipboard
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As
Object, ByVal e As EventArgs)
'Use My.Computer.Clipboard.GetText() or
My.Computer.Clipboard.GetData to retrieve
information from the clipboard.
End Sub
Private Sub ToolBarToolStripMenuItem_Click(ByVal sender
As Object, ByVal e As EventArgs)
'Me.ToolStrip.Visible =
Me.ToolBarToolStripMenuItem.Checked

End Sub
Private Sub StatusBarToolStripMenuItem_Click(ByVal
sender As Object, ByVal e As EventArgs)
'Me.StatusStrip.Visible =
Me.StatusBarToolStripMenuItem.Checked
End Sub
Private Sub CascadeToolStripMenuItem_Click(ByVal sender
As Object, ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub TileVerticalToolStripMenuItem_Click(ByVal
sender As Object, ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub TileHorizontalToolStripMenuItem_Click(ByVal
sender As Object, ByVal e As EventArgs)
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal
sender As Object, ByVal e As EventArgs)

Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub
Private Sub CloseAllToolStripMenuItem_Click(ByVal sender
As Object, ByVal e As EventArgs)
' Close all child forms of the parent.
For Each ChildForm As Form In Me.MdiChildren
ChildForm.Close()
Next

Universitas Sumatera Utara

4

End Sub
Private m_ChildFormNumber As Integer
Private Sub UserToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
UserToolStripMenuItem.Click
Dim F_User As New frm_user
F_User.MdiParent = Me

F_User.Show()
End Sub
Private Sub DataBarangToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles DataBarangToolStripMenuItem.Click
Dim F_Barang As New frm_barang
F_Barang.MdiParent = Me
F_Barang.Show()
End Sub
Private Sub DataSupplierToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles DataSupplierToolStripMenuItem.Click
Dim F_Supplier As New frm_supplier
F_Supplier.MdiParent = Me
F_Supplier.Show()
End Sub
Private Sub DataCustomerToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles DataCustomerToolStripMenuItem.Click
Dim F_Customer As New frm_customer

F_Customer.MdiParent = Me
F_Customer.Show()
End Sub
Private Sub FakturPembelianToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles FakturPembelianToolStripMenuItem.Click
Dim F_Pembelian As New frm_pembelian
F_Pembelian.MdiParent = Me
F_Pembelian.Show()
End Sub
Private Sub
DetailHutangPiutangPembelianToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles DetailHutangPiutangPembelianToolStripMenuItem.Click
Dim F_Detail_Credit As New frm_detail_credit
F_Detail_Credit.MdiParent = Me
F_Detail_Credit.Show()
End Sub
Private Sub FakturPenjualanToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)

Handles FakturPenjualanToolStripMenuItem.Click
Dim F_Penjualan As New frm_penjualan
F_Penjualan.MdiParent = Me
F_Penjualan.Show()

Universitas Sumatera Utara

5

End Sub
Private Sub
DetailHutangPiutangPenjualanToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles
DetailHutangPiutangPenjualanToolStripMenuItem.Click
Dim F_Detail_Hutang As New frm_detail_hutang
F_Detail_Hutang.MdiParent = Me
F_Detail_Hutang.Show()
End Sub
Private Sub MDIParent1_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Dim F_Cek_Gudang As New frm_cek_gudang
F_Cek_Gudang.MdiParent = Me
F_Cek_Gudang.Show()
Timer1.Enabled = True
'LaporanToolStripMenuItem.Enabled = False
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Timer1.Tick
ToolTime.Text = Format(Now, "HH:mm:ss")
ToolDate.Text = Format(Now, "ddd dd-MMM-yyyy")
End Sub
Private Sub LaporanPembelianToolStripMenuItem_Click(ByVal
sender As
System.Object, ByVal e As System.EventArgs) Handles
LaporanPembelianToolStripMenuItem.Click
Dim F_Laporan_Pembelian As New Laporan
F_Laporan_Pembelian.MdiParent = Me
F_Laporan_Pembelian.Show()
End Sub
Private Sub LaporanPenjualanToolStripMenuItem_Click(ByVal
sender As
System.Object, ByVal e As System.EventArgs) Handles
LaporanPenjualanToolStripMenuItem.Click
Dim F_Laporan_Penjualan As New Laporan1
F_Laporan_Penjualan.MdiParent = Me
F_Laporan_Penjualan.Show()
End Sub
Private Sub BantuanToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles BantuanToolStripMenuItem.Click
Dim F_help As New frm_help
F_help.MdiParent = Me
F_help.Show()
End Sub
Private Sub TentangToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles TentangToolStripMenuItem.Click
Dim F_about As New frm_about
F_about.MdiParent = Me

Universitas Sumatera Utara

6

F_about.Show()
End Sub
Private Sub LogoutToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles LogoutToolStripMenuItem.Click
End
End Sub
End Class

4. Form Cek_Gudang
Imports System.Data.OleDb
Public Class frm_cek_gudang
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub refresh_isi()
da = New OleDbDataAdapter("Select * from tbl_barang
WHERE jumlah < 5", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_barang")
DGV1.DataSource = (ds.Tables("tbl_barang"))
With DGV1
.Columns(0).Width = 200
.Columns(1).Width = 350
.Columns(2).Width = 100
.Columns(3).Width = 150
.Columns(4).Width = 150
.Columns(5).Width = 150
.Columns(0).HeaderText = "Kode Barang"
.Columns(1).HeaderText = "Nama Barang"
.Columns(2).HeaderText = "Satuan"
.Columns(3).HeaderText = "Harga Beli"
.Columns(4).HeaderText = "Harga Jual"
.Columns(5).HeaderText = "Stok"
.ForeColor = Color.Red
End With
End Sub
Private Sub frm_cek_gudang_Activated(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
Me.Activated
refresh_isi() 'gunanya pada saat dia aktip maka form akan
terus terrefresh
End Sub
Private Sub frm_cek_gudang_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cekKoneksi()
refresh_isi()
End Sub
End Class

Universitas Sumatera Utara

7

5. Form User
Imports System.Data.OleDb
Public Class frm_user
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub frm_user_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
refresh_isi()
End Sub
Private Sub refresh_isi()
bersih()
da = New OleDbDataAdapter("Select username,
password, kategori from tbl_user", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_user")
DGV1.DataSource = (ds.Tables("tbl_user"))
With DGV1
.Columns(0).Width = 250
.Columns(1).Width = 100
.Columns(2).Width = 120
.Columns(0).HeaderText = "Username"
.Columns(1).HeaderText = "Password"
.Columns(2).HeaderText = "Kategori"
End With
End Sub
Private Sub bersih()
txtuname.Text = ""
txtpass.Text = ""
cbokategori.Text = ""
txtuname.Select()
End Sub
Private Sub txtuname_LostFocus(ByVal sender As Object,
ByVal e As System.EventArgs) Handles
txtuname.LostFocus
If txtuname.Text = String.Empty Then
Exit Sub
End If
Dim perintah As String = "select * from tbl_user
where username = '" &
txtuname.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txtuname.Text = data(1)
txtpass.Text = data(2)
cbokategori.Text = data(3)
End If
data.Close()

Universitas Sumatera Utara

8

End Sub
Private Sub btn_simpan_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_simpan.Click
Dim perintah As String = "INSERT INTO” &_
tbl_user([username],
[password], kategori
VALUES ('" & txtuname.Text
& "','" & txtpass.Text &
"','" & cbokategori.Text &
"')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_hapus_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_hapus.Click
Dim perintah As String = "Delete from tbl_user where
username = '" &
txtuname.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Dihapus",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_batal_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_batal.Click
bersih()
End Sub
Private Sub btn_keluar_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_keluar.Click
Me.Close()
End Sub
End Class

6. Form Barang
Imports System.Data.OleDb
Public Class frm_barang

Universitas Sumatera Utara

9

Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub frm_barang_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
cekKoneksi()
refresh_isi()
tampil_satuan()
txtKode.Select()
End Sub
Private Sub refresh_isi()
bersih()
da = New OleDbDataAdapter("Select * from
tbl_barang", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_barang")
DGV1.DataSource = (ds.Tables("tbl_barang"))
With DGV1
.Columns(0).Width = 100
.Columns(1).Width = 250
.Columns(2).Width = 100
.Columns(3).Width = 120
.Columns(4).Width = 120
.Columns(5).Width = 100
.Columns(0).HeaderText = "Kode Barang"
.Columns(1).HeaderText = "Nama Barang"
.Columns(2).HeaderText = "Satuan"
.Columns(3).HeaderText = "Harga Beli"
.Columns(4).HeaderText = "Harga Jual"
.Columns(5).HeaderText = "Stok yang Tersedia"
End With
End Sub
Private Sub bersih()
txtKode.Text = ""
txtNama.Text = ""
cboSatuan.Text = ""
txtHargaBeli.Text = ""
txtHargaJual.Text = ""
txtJumlah.Text = ""
txtKode.Focus()
End Sub
Private Sub btn_satuan_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btn_satuan.Click
frm_satuan.Show()
End Sub
Private Sub txtKode_LostFocus(ByVal sender As Object,
ByVal e As System.EventArgs) Handles
txtKode.LostFocus
If txtKode.Text = String.Empty Then 'jika textkode kosong
maka tidak ada proses yang dijalankan.
Exit Sub
End If

Universitas Sumatera Utara

10

'jika txtkode ada isi dan isi tersebut tertera di tabel db maka
data yang ada di tabel db dimunculkan pada komponen dibwh ini
Dim perintah As String = "select * from tbl_barang where
kode = '" & txtKode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txtKode.Text = data(0)
txtNama.Text = data(1)
cboSatuan.Text = data(2)
txtHargaBeli.Text = data(3)
txtHargaJual.Text = data(4)
txtJumlah.Text = data(5)
End If
data.Close()
End Sub
Public Sub tampil_satuan()
cboSatuan.Items.Clear()
Try
Dim perintah As String = "Select satuan from satuan"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cboSatuan.Items.Add(data("satuan"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_hapus_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_hapus.Click
Dim perintah As String = "Delete from tbl_barang where
kode = '" & txtKode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Dihapus",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_simpan_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_simpan.Click
Dim perintah As String = "Insert into tbl_barang (kode,
nama, satuan, harga_beli,
harga_jual, jumlah) values ('" &
txtKode.Text & "','" & txtNama.Text
& "','" & cboSatuan.Text & "','" &
txtHargaBeli.Text & "','" &
txtHargaJual.Text & "','" &

Universitas Sumatera Utara

11

txtJumlah.Text & "')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_update_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_update.Click
Dim perintah As String = "update tbl_barang set nama='" &
txtNama.Text & "', satuan ='" &
cboSatuan.Text & "', harga_beli='"
& txtHargaBeli.Text & "',
harga_jual='" & txtHargaJual.Text &
"', jumlah='" & txtJumlah.Text & "'
WHERE kode='" & txtKode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Diupdate",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_batal_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click
bersih()
End Sub
Private Sub btn_keluar_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
Private Sub cboSatuan_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cboSatuan.Click
tampil_satuan()
End Sub
End Class

7. Form Satuan
Imports System.Data.OleDb
Public Class frm_satuan
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub bersih()
txtSatuan.Text = ""

Universitas Sumatera Utara

12

txtSatuan.Select()
End Sub
Private Sub frm_satuan_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
bersih()
End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_simpan.Click
Dim perintah As String = "insert into satuan (satuan)
values ('" & txtSatuan.Text & "')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data berhasil ditambah",
MsgBoxStyle.Information, "Pesan")
bersih()
Catch ex As Exception
MsgBox(ex.Message)
End Try
frm_barang.tampil_satuan()
Me.Close()
End Sub
Private Sub txtSatuan_LostFocus(ByVal sender As Object, ByVal
e As System.EventArgs) Handles txtSatuan.LostFocus
If txtSatuan.Text = String.Empty Then
Exit Sub
End If
Dim perintah As String = "select * from satuan where
satuan like '" & txtSatuan.Text &
"'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader
If data.HasRows Then
data.Read()
txtSatuan.Text = data(1)
End If
data.Close()
End Sub
Private Sub btn_hapus_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_hapus.Click
Dim perintah As String = "delete from satuan where
satuan='" & txtSatuan.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data berhasil dihapus",
MsgBoxStyle.Information, "Pesan")
bersih()
Catch ex As Exception
MsgBox(ex.Message)
End Try

Universitas Sumatera Utara

13

frm_barang.tampil_satuan()
Me.Close()
End Sub
End Class

8. Form Supplier
Imports System.Data.OleDb
Public Class frm_supplier
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub frm_supplier_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
refresh_isi()
End Sub
Private Sub refresh_isi()
bersih()
da = New OleDbDataAdapter("Select * from tbl_supplier",
conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_supplier")
DGV1.DataSource = (ds.Tables("tbl_supplier"))
With DGV1
.Columns(0).Width = 100
.Columns(1).Width = 250
.Columns(2).Width = 100
.Columns(3).Width = 120
.Columns(4).Width = 120
.Columns(5).Width = 100
.Columns(0).HeaderText = "Kode Supplier"
.Columns(1).HeaderText = "Nama Supplier"
.Columns(2).HeaderText = "Alamat"
.Columns(3).HeaderText = "Nomor Telp"
.Columns(4).HeaderText = "Nomor Hp"
.Columns(5).HeaderText = "Email"
End With
End Sub
Private Sub bersih()
txtkode.Text = ""
txtnama.Text = ""
txtalamat.Text = ""
txttelp.Text = ""
txthp.Text = ""
txtemail.Text = ""
txtkode.Select()
End Sub
Private Sub txtkode_LostFocus(ByVal sender As Object, ByVal e
As System.EventArgs) Handles txtkode.LostFocus
If txtkode.Text = String.Empty Then
Exit Sub
End If

Universitas Sumatera Utara

14

Dim perintah As String = "select * from tbl_supplier where
kode = '" & txtkode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txtkode.Text = data(0)
txtnama.Text = data(1)
txtalamat.Text = data(2)
txttelp.Text = data(3)
txthp.Text = data(4)
txtemail.Text = data(5)
End If
data.Close()
End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_simpan.Click
Dim perintah As String = "Insert into tbl_supplier values
('" & txtkode.Text & "','" &
txtnama.Text & "','" &
txtalamat.Text & "','" &
txttelp.Text & "','" & txthp.Text &
"','" & txtemail.Text & "')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_update_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_update.Click
Dim perintah As String = "update tbl_supplier set nama='"
& txtnama.Text & "', alamat ='" &
txtalamat.Text & "', telp='" &
txttelp.Text & "', hp='" &
txthp.Text & "', email='" &
txtemail.Text & "' WHERE kode='" &
txtkode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Diupdate",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_hapus_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_hapus.Click

Universitas Sumatera Utara

15

Dim perintah As String = "Delete from tbl_supplier where
kode = '" & txtkode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Dihapus",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_batal_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click
bersih()
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
End Class

9. Form Customer
Imports System.Data.OleDb
Public Class frm_customer
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub frm_customer_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.Load
cekKoneksi()
refresh_isi()
End Sub
Private Sub refresh_isi()
bersih()
da = New OleDbDataAdapter("Select * from tbl_customer",
conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_customer")
DGV1.DataSource = (ds.Tables("tbl_customer"))
With DGV1
.Columns(0).Width = 100
.Columns(1).Width = 250
.Columns(2).Width = 100
.Columns(3).Width = 120
.Columns(4).Width = 120
.Columns(5).Width = 100
.Columns(0).HeaderText = "Kode Customer"
.Columns(1).HeaderText = "Nama Customer"
.Columns(2).HeaderText = "Alamat"
.Columns(3).HeaderText = "Nomor Telp"
.Columns(4).HeaderText = "Nomor Hp"

Universitas Sumatera Utara

16

.Columns(5).HeaderText = "Email"
End With
End Sub
Private Sub bersih()
txtKode.Text = ""
txtNama.Text = ""
txtalamat.Text = ""
txttelp.Text = ""
txthp.Text = ""
txtemail.Text = ""
txtkode.Select()
End Sub
Private Sub txtkode_LostFocus(ByVal sender As Object, ByVal e
As System.EventArgs) Handles txtkode.LostFocus
If txtkode.Text = String.Empty Then
Exit Sub
End If
Dim perintah As String = "select * from tbl_customer where
kode = '" & txtkode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txtkode.Text = data(0)
txtnama.Text = data(1)
txtalamat.Text = data(2)
txttelp.Text = data(3)
txthp.Text = data(4)
txtemail.Text = data(5)
End If
data.Close()
End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_simpan.Click
Dim perintah As String = "Insert into tbl_customer values
('" & txtkode.Text & "','" &
txtnama.Text & "','" &
txtalamat.Text & "','" &
txttelp.Text & "','" & txthp.Text &
"','" & txtemail.Text & "')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Universitas Sumatera Utara

17

Private Sub btn_update_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_update.Click
Dim perintah As String = "update tbl_customer set nama='"
& txtnama.Text & "', alamat ='" &
txtalamat.Text & "', telp='" &
txttelp.Text & "', hp='" &
txthp.Text & "', email='" &
txtemail.Text & "' WHERE kode='" &
txtkode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Diupdate",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_hapus_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_hapus.Click
Dim perintah As String = "Delete from tbl_customer where
kode = '" & txtkode.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Dihapus",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_batal_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click
bersih()
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
End Class

10. Form Pembelian
Imports System.Data.OleDb
Public Class frm_pembelian
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub refresh_isi()
bersih1()
da = New OleDbDataAdapter("Select tgl_pembelian, kode_brg,
qty, satuan, harga_beli, jumlah_bayar from
tbl_pembelian WHERE no_faktur = '" & txtfaktur.Text &

Universitas Sumatera Utara

18

"'", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_pembelian")
DGV1.DataSource = (ds.Tables("tbl_pembelian"))
With DGV1
.Columns(0).Width = 100
.Columns(1).Width = 250
.Columns(2).Width = 100
.Columns(3).Width = 120
.Columns(4).Width = 120
.Columns(5).Width = 100
.Columns(0).HeaderText = "Tanggal Pembelian"
.Columns(1).HeaderText = "Kode Barang"
.Columns(2).HeaderText = "Banyaknya"
.Columns(3).HeaderText = "Satuan"
.Columns(4).HeaderText = "Harga Beli"
.Columns(5).HeaderText = "Jumlah Yang Dibayar"
End With
End Sub
Private Sub tampil_supplier()
Try
Dim perintah As String = "Select nama from
tbl_supplier"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cbosupplier.Items.Add(data("nama"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub tampil_kode_barang()
Try
Dim perintah As String = "Select kode from tbl_barang"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cbobarang.Items.Add(data("kode"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub bersih1()
cbobarang.Text = ""
txtbarang.Text = ""
txtsatuan.Text = ""
txtqty.Text = ""
txtharga.Text = ""
txtjum.Text = ""

Universitas Sumatera Utara

19

cbobarang.Select()
End Sub
Private Sub bersih2()
txtfaktur.Text = ""
cbosupplier.Text = ""
cbobarang.Text = ""
txtbarang.Text = ""
txtsatuan.Text = ""
txtqty.Text = ""
txtharga.Text = ""
txtjum.Text = ""
txttotbayar.Text = ""
cbojenisbayar.Text = ""
txtsudahbayar.Text = ""
txtsisabayar.Text = ""
cbostatus.Text = ""
'DGV1.Rows.Clear()
txtfaktur.Select()
End Sub
Private Sub frm_pembelian_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
refresh_isi()
tampil_supplier()
tampil_kode_barang()
txtfaktur.Select()
End Sub
Private Sub cbobarang_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cbobarang.SelectedIndexChanged
Dim perintah As String = "select nama, satuan from
tbl_barang where kode = '"
& cbobarang.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txtbarang.Text = data(0)
txtsatuan.Text = data(1)
End If
data.Close()
End Sub
Private Sub txtharga_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtharga.TextChanged
txtjum.Text = Val(txtqty.Text) * Val(txtharga.Text)
End Sub
Private Sub btn_tambah_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_tambah.Click
Dim perintah As String = "Insert into tbl_pembelian
(no_faktur, tgl_pembelian,
supplier, kode_brg, qty, satuan,
harga_beli, jumlah_bayar) values

Universitas Sumatera Utara

20

('" & txtfaktur.Text & "','" &
tgl_beli.Text & "','" &
cbosupplier.Text & "','" &
cbobarang.Text & "','" &
txtqty.Text & "','" &
txtsatuan.Text & "','" &
txtharga.Text & "','" & txtjum.Text
& "')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim perintah1 As String = "update tbl_barang set
harga_beli='" & txtharga.Text & "',
jumlah=jumlah + '" & txtqty.Text &
"' where kode='" & cbobarang.Text &
"'"
Dim eksekusi1 As New OleDbCommand(perintah1, koneksi)
Try
eksekusi.ExecuteNonQuery()
eksekusi1.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button2.Click
Dim perintah As String = "Select Sum(jumlah_bayar) as
total_bayar From tbl_pembelian
WHERE no_faktur = '" &
txtfaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txttotbayar.Text = data(0)
End If
data.Close()
End Sub
Private Sub txtsudahbayar_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtsudahbayar.TextChanged
txtsisabayar.Text = Val(txttotbayar.Text) –
Val(txtsudahbayar.Text)
End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_simpan.Click
Dim perintah As String = "Insert into tbl_detail_pembelian
values ('" & txtfaktur.Text & "','"
& tgl_beli.Text & "','" &
txttotbayar.Text & "','" &
cbojenisbayar.Text & "','" &
txtsudahbayar.Text & "','" &
txtsisabayar.Text & "','" &
cbostatus.Text & "')"

Universitas Sumatera Utara

21

Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
bersih2()
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub pilih_jenis_bayar()
If cbojenisbayar.Text = "Cash" Then
txtsudahbayar.Text = txttotbayar.Text
txtsisabayar.Enabled = False
cbostatus.Text = "Lunas"
ElseIf cbojenisbayar.Text = "Credit" Then
txtsudahbayar.Text = ""
cbostatus.Text = "Belum Lunas"
End If
End Sub
Private Sub cbojenisbayar_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cbojenisbayar.SelectedIndexChanged
pilih_jenis_bayar()
End Sub
Private Sub btn_batal_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click
bersih2()
refresh_isi()
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
Private Sub btn_hapus_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_hapus.Click
Dim perintah As String = "Delete from tbl_detail_pembelian
where no_faktur = '" &
txtfaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Dihapus",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class

Universitas Sumatera Utara

22

11. Form Penjualan
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class frm_penjualan
Dim da As OleDbDataAdapter
Dim ds As DataSet
Private Sub refresh_isi()
bersih1()
da = New OleDbDataAdapter("Select tgl_penjualan, kode_brg,
qty, satuan, harga_jual, jumlah_bayar from
tbl_penjualan WHERE no_faktur = '" & txtfaktur.Text &
"'", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "tbl_penjualan")
DGV1.DataSource = (ds.Tables("tbl_penjualan"))
With DGV1
.Columns(0).Width = 100
.Columns(1).Width = 250
.Columns(2).Width = 100
.Columns(3).Width = 120
.Columns(4).Width = 120
.Columns(5).Width = 100
.Columns(0).HeaderText = "Tanggal Penjualan"
.Columns(1).HeaderText = "Kode Barang"
.Columns(2).HeaderText = "Banyaknya"
.Columns(3).HeaderText = "Satuan"
.Columns(4).HeaderText = "Harga Jual"
.Columns(5).HeaderText = "Jumlah Yang Dibayar"
End With
End Sub
Private Sub tampil_customer()
cbocustomer.Items.Clear()
Try
Dim perintah As String = "Select nama from
tbl_customer"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cbocustomer.Items.Add(data("nama"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub tampil_kode_barang()
Try
Dim perintah As String = "Select kode from tbl_barang"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()

Universitas Sumatera Utara

23

While data.Read()
cbobarang.Items.Add(data("kode"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub bersih1()
cbobarang.Text = ""
txtbarang.Text = ""
txtsatuan.Text = ""
txtqty.Text = ""
txtharga.Text = ""
txtjum.Text = ""
cbostatusbeli.Select()
End Sub
Private Sub bersih2()
cbostatusbeli.Text = ""
txtfaktur.Text = ""
cbocustomer.Text = ""
cbobarang.Text = ""
txtbarang.Text = ""
txtsatuan.Text = ""
txtqty.Text = ""
txtharga.Text = ""
txtjum.Text = ""
txttotbayar.Text = ""
cbojenisbayar.Text = ""
txtsudahbayar.Text = ""
txtsisabayar.Text = ""
cbostatus.Text = ""
'DGV1.Rows.Clear()
cbostatusbeli.Select()
End Sub
Private Sub cbostatusbeli_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cbostatusbeli.SelectedIndexChanged
If cbostatusbeli.Text = "Non-Member" Then
cbocustomer.Enabled = False
Else
tampil_customer()
cbocustomer.Enabled = True
End If
End Sub
Private Sub frm_penjualan_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
refresh_isi()
tampil_kode_barang()
End Sub
Private Sub cbobarang_LostFocus(ByVal sender As Object, ByVal
e As System.EventArgs) Handles cbobarang.LostFocus
If txtfaktur.Text = String.Empty Then

Universitas Sumatera Utara

24

MsgBox("Nomor Faktur mohon Diisi",
MsgBoxStyle.Information, "Pesan")
Else
Exit Sub
End If
End Sub
Private Sub cbobarang_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cbobarang.SelectedIndexChanged
Dim perintah As String = "select nama, satuan, harga_jual
from tbl_barang where kode = '" &
cbobarang.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txtbarang.Text = data(0)
txtsatuan.Text = data(1)
txtharga.Text = data(2)
End If
data.Close()
End Sub
Private Sub txtqty_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtqty.TextChanged
txtjum.Text = Val(txtharga.Text) * Val(txtqty.Text)
End Sub
Private Sub btn_tambah_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_tambah.Click
Try
Dim temp As Integer
Dim perintah2 As String = "Select jumlah from
tbl_barang where kode = '" &
cbobarang.Text & "'"
Dim eksekusi2 As New OleDbCommand(perintah2, koneksi)
Dim data As OleDbDataReader
data = eksekusi2.ExecuteReader()
While data.Read()
temp = data("jumlah")
End While
If temp < txtqty.Text Then
MsgBox("Stok Tidak Mencukupi, Mohon Periksa
Kembali Data di Gudang",
MsgBoxStyle.Information, "Alert")
Exit Sub
Else
Dim perintah As String = "Insert into
tbl_penjualan (no_faktur,
tgl_penjualan,
status_pembeli, customer,
kode_brg, qty, satuan,
harga_jual, jumlah_bayar)
values ('" & txtfaktur.Text &
"','" & tgl_beli.Text & "','"
& cbojenisbayar.Text & "','"
& cbocustomer.Text & "','" &

Universitas Sumatera Utara

25

cbobarang.Text & "','" &
txtqty.Text & "','" &
txtsatuan.Text & "','" &
txtharga.Text & "','" &
txtjum.Text & "')"
Dim eksekusi As New OleDbCommand(perintah,koneksi)
Dim perintah1 As String = "update tbl_barang set
jumlah=jumlah - '" &
txtqty.Text & "' where
kode='" & cbobarang.Text &"'"
Dim eksekusi1 As New
OleDbCommand(perintah1,koneksi)
Try
eksekusi.ExecuteNonQuery()
eksekusi1.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button2.Click
Dim perintah As String = "Select Sum(jumlah_bayar) as
total_bayar From tbl_penjualan
WHERE no_faktur = '" &
txtfaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
txttotbayar.Text = data(0)
End If
data.Close()
End Sub
Private Sub txtsudahbayar_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtsudahbayar.TextChanged
txtsisabayar.Text = Val(txttotbayar.Text) –
Val(txtsudahbayar.Text)
End Sub
Private Sub btn_simpan_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_simpan.Click
Dim perintah As String = "Insert into tbl_detail_penjualan
values ('" & txtfaktur.Text & "','"
& tgl_beli.Text & "','" &
txttotbayar.Text & "','" &
cbojenisbayar.Text & "','" &
txtsudahbayar.Text & "','" &

Universitas Sumatera Utara

26

txtsisabayar.Text & "','" &
cbostatus.Text & "')"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan",
MsgBoxStyle.Information, "Message")
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim str1 As String = "Select * From view_cetak_penjualan
Where no_faktur='" & txtfaktur.Text & "'"
Dim CRP1 As New ReportDocument
Dim dSet1 As New DataSet
Dim DA1 As New OleDbDataAdapter(str1, koneksi)
DA1.Fill(dSet1)
CRP1.Load(Application.StartupPath & "\CetakPenjualan.rpt")
CRP1.SetDataSource(dSet1.Tables(0))
CRP1.Refresh()
Dim F_Cetak_Penjualan As New frm_cetak_penjualan
With F_Cetak_Penjualan
.CRV1.Refresh()
.CRV1.ReportSource = CRP1
.Show()
End With
bersih2()
refresh_isi()
End Sub
Private Sub pilih_jenis_bayar()
If cbojenisbayar.Text = "Cash" Then
txtsudahbayar.Text = txttotbayar.Text
txtsisabayar.Enabled = False
cbostatus.Text = "Lunas"
ElseIf cbojenisbayar.Text = "Credit" Then
txtsudahbayar.Text = ""
cbostatus.Text = "Belum Lunas"
txtsisabayar.Enabled = True
End If
End Sub

Private Sub btn_batal_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click
bersih2()
refresh_isi()
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub

Universitas Sumatera Utara

27

Private Sub btn_hapus_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_hapus.Click
Dim perintah As String = "Delete from tbl_detail_penjualan
where no_faktur = '" &
txtfaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Dihapus",
MsgBoxStyle.Information, "Message")
refresh_isi()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub cbojenisbayar_SelectedValueChanged(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
cbojenisbayar.SelectedValueChanged
pilih_jenis_bayar()
End Sub
End Class

12. Form Detail Hutang Pembelian
Imports System.Data.OleDb
Public Class frm_detail_credit
Private Sub bersih()
cbofaktur.Text = ""
tglpembelian.Text = ""
txtsupplier.Text = ""
txttotbayar.Text = ""
txtsudahbayar.Text = ""
txtsisabayar.Text = ""
cbostatus.Text = ""
tampil_credit()
End Sub
Private Sub tampil_credit()
cbofaktur.Items.Clear()
Try
Dim perintah As String = "Select no_faktur from
tbl_detail_pembelian where
status='Belum Lunas'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cbofaktur.Items.Add(data("no_faktur"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Universitas Sumatera Utara

28

Private Sub frm_detail_credit_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cekKoneksi()
bersih()
End Sub
Private Sub cbofaktur_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cbofaktur.SelectedIndexChanged
Dim perintah As String = "select
tbl_detail_pembelian.tgl_pembelian,
tbl_pembelian.supplier,
tbl_detail_pembelian.total_bayar,
tbl_detail_pembelian.sudah_bayar,
tbl_detail_pembelian.sisa_bayar,
tbl_detail_pembelian.status from
tbl_detail_pembelian, tbl_pembelian
where
tbl_detail_pembelian.no_faktur = '"
& cbofaktur.Text & "' and
tbl_pembelian.no_faktur = '" &
cbofaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
tglpembelian.Text = data(0)
txtsupplier.Text = data(1)
txttotbayar.Text = data(2)
txtsudahbayar.Text = data(3)
txtsisabayar.Text = data(4)
cbostatus.Text = data(5)
End If
data.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
txtsudahbayar.Text = Val(txttotbayar.Text)
txtsisabayar.Text = 0
cbostatus.Text = "Lunas"
End Sub
Private Sub btn_update_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_update.Click
Dim perintah As String = "update tbl_detail_pembelian set
sudah_bayar='" & txtsudahbayar.Text
& "', sisa_bayar ='" &
txtsisabayar.Text & "', status='" &
cbostatus.Text & "' WHERE
no_faktur='" & cbofaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Diupdate",
MsgBoxStyle.Information, "Message")
bersih()

Universitas Sumatera Utara

29

Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_batal_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click
bersih()
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
End Class

13. Form Detail Hutang Penjualan
Imports System.Data.OleDb
Public Class frm_detail_hutang
Private Sub bersih()
cbofaktur.Text = ""
tglpembelian.Text = ""
txtsupplier.Text = ""
txttotbayar.Text = ""
txtsudahbayar.Text = ""
txtsisabayar.Text = ""
cbostatus.Text = ""
tampil_credit()
End Sub
Private Sub tampil_credit()
cbofaktur.Items.Clear()
Try
Dim perintah As String = "Select no_faktur from
tbl_detail_penjualan where
status='Belum Lunas'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cbofaktur.Items.Add(data("no_faktur"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub frm_detail_hutang_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
cekKoneksi()
bersih()
End Sub

Universitas Sumatera Utara

30

Private Sub cbofaktur_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cbofaktur.SelectedIndexChanged
Dim perintah As String = "select
tbl_detail_penjualan.tgl_penjualan,
tbl_penjualan.customer,
tbl_detail_penjualan.total_bayar,
tbl_detail_penjualan.sudah_bayar,
tbl_detail_penjualan.sisa_bayar,
tbl_detail_penjualan.status from
tbl_detail_penjualan, tbl_penjualan
where
tbl_detail_penjualan.no_faktur = '"
& cbofaktur.Text & "' and
tbl_penjualan.no_faktur = '" &
cbofaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
If data.HasRows Then
data.Read()
tglpembelian.Text = data(0)
txtsupplier.Text = data(1)
txttotbayar.Text = data(2)
txtsudahbayar.Text = data(3)
txtsisabayar.Text = data(4)
cbostatus.Text = data(5)
End If
data.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
txtsudahbayar.Text = Val(txttotbayar.Text)
txtsisabayar.Text = 0
cbostatus.Text = "Lunas"
End Sub
Private Sub btn_update_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_update.Click
Dim perintah As String = "update tbl_detail_penjualan set
sudah_bayar='" & txtsudahbayar.Text
& "', sisa_bayar ='" &
txtsisabayar.Text & "', status='" &
cbostatus.Text & "' WHERE
no_faktur='" & cbofaktur.Text & "'"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Try
eksekusi.ExecuteNonQuery()
MsgBox("Data Berhasil Diupdate",
MsgBoxStyle.Information, "Message")
bersih()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btn_batal_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_batal.Click

Universitas Sumatera Utara

31

bersih()
End Sub
Private Sub btn_keluar_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btn_keluar.Click
Me.Close()
End Sub
End Class

14. Form Laporan Pembelian
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Laporan
Dim teks As String
Dim da As OleDbDataAdapter
Dim perintah As String
Dim perintah1 As String
Private Sub RadioButton2_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton2.CheckedChanged
DTtanggal.Enabled = False
cbohari.Enabled = True
cboItem.Enabled = False
cbohari.Items.Clear()
Dim i As Integer
For i = 1 To 12
cbohari.Items.Add(i)
Next
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton3.CheckedChanged
DTtanggal.Enabled = False
cbohari.Enabled = True
cboItem.Enabled = False
cbohari.Items.Clear()
Dim i As Integer
For i = 2009 To 2050
cbohari.Items.Add(i)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button2.Click
Try
If RadioButton1.Checked = True Then
teks = DTtanggal.Value.Date.ToString("MM/dd/yyyy")
perintah = "Select * From view_pembelian where
tgl_pembelian=CDate('" & teks & "')"

Universitas Sumatera Utara

32

ElseIf RadioButton2.Checked = True Then
teks = cbohari.Text
perintah = "Select * From view_pembelian where
MONTH(tgl_pembelian)='" & teks & "'"
ElseIf RadioButton3.Checked = True Then
teks = cbohari.Text
perintah = "Select * From view_pembelian where
YEAR(tgl_pembelian)='" & teks & "'"
ElseIf RadioButton4.Checked = True Then
teks = cboItem.Text
perintah1 = "Select * From tbl_pembelian where
kode_brg='" & teks & "'"
End If
'Dim CRP1 As New ReportDocument
'Dim dSet1 As New DataSet
'Dim DA1 As New OleDbDataAdapter(perintah, koneksi)
'DA1.Fill(dSet1)
'CRP1.Load(Application.StartupPath &
"\CRPembelian.rpt")
'CRP1.SetDataSource(dSet1.Tables(0))
'CRP1.Refresh()
'CrystalReportViewer1.ReportSource = CRP1
'CrystalReportViewer1.Refresh()
Dim
Dim
Dim
Dim
Dim
Dim

CRP1 As New ReportDocument
CRP2 As New ReportDocument
dSet1 As New DataSet
dSet2 As New DataSet
DA1 As New OleDbDataAdapter(perintah, koneksi)
DA2 As New OleDbDataAdapter(perintah1, koneksi)

If RadioButton4.Checked = True Then
DA2.Fill(dSet2)
CRP2.Load(Application.StartupPath &
"\CRPembelian1.rpt")
CRP2.SetDataSource(dSet2.Tables(0))
CRP2.Refresh()
Else
DA1.Fill(dSet1)
CRP1.Load(Application.StartupPath &
"\CRPembelian.rpt")
CRP1.SetDataSource(dSet1.Tables(0))
CRP1.Refresh()
End If
If RadioButton4.Checked = True Then
CrystalReportViewer1.ReportSource = CRP2
CrystalReportViewer1.Refresh()
Else
CrystalReportViewer1.ReportSource = CRP1
CrystalReportViewer1.Refresh()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Universitas Sumatera Utara

33

Private Sub RadioButton1_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton1.CheckedChanged
DTtanggal.Enabled = True
cbohari.Enabled = False
cboItem.Enabled = False
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton4.CheckedChanged
DTtanggal.Enabled = False
cbohari.Enabled = False
cboItem.Enabled = True
End Sub
Private Sub Laporan_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
tampil_kode_barang()
End Sub
Private Sub tampil_kode_barang()
Try
Dim perintah As String = "Select kode from tbl_barang"
Dim eksekusi As New OleDbCommand(perintah, koneksi)
Dim data As OleDbDataReader
data = eksekusi.ExecuteReader()
While data.Read()
cboItem.Items.Add(data("kode"))
End While
data.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class

15. Form Laporan Penjualan
Imports System.Data.OleDb
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class Laporan1
Dim teks As String
Dim da As OleDbDataAdapter
Dim perintah As String
Dim perintah1 As String
Private Sub Laporan1_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
cekKoneksi()
tampil_kode_barang()
End Sub

Universitas Sumatera Utara

34

Private Sub RadioButton2_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton2.CheckedChanged
DTtanggal.Enabled = False
cbohari.Enabled = True
cboItem.Enabled = False
cbohari.Items.Clear()
Dim i As Integer
For i = 1 To 12
cbohari.Items.Add(i)
Next
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RadioButton3.CheckedChanged
DTtanggal.Enabled = False
cbohari.Enabled = True
cboItem.Enabled = False
cbohari.Items.Clear()
Dim i As Integer
For i = 2009 To 2050
cbohari.Items.Add(i)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button2.Click
Try
If RadioButton1.Checked = True Then
teks = DTtanggal.Value.Date.ToString("MM/dd/yyyy")
perintah = "Select * From view_penjualan where
tgl_penjualan=CDate('" & teks & "')"
ElseIf RadioButton2.Checked = True Then
teks = cbohari.Text
perintah = "Select * From view_penjualan where
MONTH(tgl_penjualan)='" & teks & "'"
ElseIf RadioButton3.Checked = True Then
teks = cbohari.Text
perintah = "Select * From view_penjualan where
YEAR(tgl_penjualan)='" & teks & "'"
ElseIf