View
278
Download
10
Category
Preview:
Citation preview
1
MODUL PRAKTEKKOMPUTERISASI AKUNTANSI
PERTEMUAN I
Merancang Menu Utama Program Aplikasi SIA dengan Microsoft Visual Studio 20101. Buka aplikasi Viusal Studio 2010
2. Pilih File New Project. Ubah nama project menjadi aplikasiSIA atau sesuaikeinginan Anda. Pilih tempat penyimpanannya lewat tombol Browse lalu OK.
3. Muncul lembar kerja Visual Basic 2010
2
4. Isi lembar kerja Form1 dengan men-drag tools dari Toolbox yang berada di sebelah lembarkerja Form1. Drag tool MenuStrip kemudian isi dengan menu berikut :a. File Data User, Bagan Akun, Keluarb. Input Data Data Pelanggan, Data Pemasok, Data Barang Dagangc. Transaksi Penjualan, Pembelian, Penerimaan Piutang, Pembayaran Utang, Jurnal
Umumd. Laporan Laporan Laba Rugi, Laporan Perubahan Modal, Laporan Neraca, Laporan
Arus Kas
5. Kita bisa memodifikasi form Menu Utama sesuai keinginan kita melalui jendela Porpertiesyang berada di sebelah kanan lembar kerja. Seperti merubah nama header form, padaAppearance ubah Text menjadi Menu Utama. Kemudian menambahkan background padarancangan form Menu Utama, pada Appearance, BackGroundImage, klik . Pilih LocalSource, Import. Pilih gambar yang diinginkan lalu OK. Ubah BackGroundImageLayoutmenjadi Stretch. Ubah WindowsState menjadi Maximized. Kita juga bisa merubah namaForm1 untuk memudahkan kita memanggilnya kembali dengan cara klik kanan Form1.vbyang berada pada jendela Solution lalu ubah namanya menjadi formMenuUtama.
6. Ketikkan listing berikut pada lembar kerja formMenuUtama
Public Class formMenuUtama
Private Sub formMenuUtama_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
End Sub
Private Sub DataUserToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles DataUserToolStripMenuItem.Click
formUser.Show()End Sub
Private Sub BaganAkunToolStripMenuItem_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles BaganAkunToolStripMenuItem.Click
formBaganAkun.Show()End Sub
Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles KeluarToolStripMenuItem.Click
EndEnd Sub
Private Sub DataPelangganToolStripMenuItem_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Handles DataPelangganToolStripMenuItem.Click
formPelanggan.Show()End Sub
3
Private Sub DataPemasokToolStripMenuItem_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles DataPemasokToolStripMenuItem.Click
formPemasok.Show()End Sub
Private Sub DataBarangDagangToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles DataBarangDagangToolStripMenuItem.Click
formBarang.Show()End Sub
Private Sub PenjualanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles PenjualanToolStripMenuItem.Click
formPenjualan.Show()End Sub
Private Sub PembelianToolStripMenuItem_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles PembelianToolStripMenuItem.Click
formPembelian.Show()End Sub
Private Sub PenerimaanPiutangToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles PenerimaanPiutangToolStripMenuItem.Click
formPiutang.Show()End Sub
Private Sub PembayaranUtangToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles PembayaranUtangToolStripMenuItem.Click
formUtang.Show()End Sub
Private Sub JurnalUmumToolStripMenuItem_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles JurnalUmumToolStripMenuItem.Click
formJurnal.Show()End Sub
End Class
4
PERTEMUAN II
Perancangan Database SIA1. Buka aplikasi SQL Server 2008 R2, klik Connect
2. Klik kanan Databases, pilih New Database. Isi Database name dengan aplikasiSIA atausesuai keinginan. Pilih Path penyimpanan database diD:\aplikasiSIA\aplikasiSIA\aplikasiSIA\bin\Debug lalu OK.
3. Buka Databases aplikasiSIA klik kanan Tables New Table. Buat tabel-tabeldengan informasi sebagai berikut :a. tbUser idUser char(10), namaUser varchar(50), pass varchar(50)b. tbBagan kodeAkun char(10), namaAkun varchar(50)c. tbBarang idBarang char(10), namaBarang varchar(50), hargaBeli money, hargaJual
money, stok int
5
d. tbBeli noFaktur char(10), tglBeli datetime, idUser char(10), idPemasok char(10),namaPemasok varchar(50), idBarang char(10), namaBarang varchar(50), hargaBelimoney, jlhTerima int, total money
e. tbJual noFaktur char(10), tglJual datetime, idUser char(10), idPelanggan char(10),namaPelanggan varchar(50), idBarang char(10), namaBarang varchar(50), hargaJualmoney, jlhBeli int, total money
f. tbJurnal kodeJurnal char(10), tanggal datetime, noBukti char(10), keteranganvarchar(50), kodeAkun char(10), namaAkun varchar(50), debit money, kredit money
g. tbPelanggan idPelanggan char(10), namaPelanggan varchar(50), alamat varchar(50),telepon varchar(50)
h. tbPemasok idPemasok char(10), namaPemasok varchar(50), alamat varchar(50),telepon varchar(50)
i. tbPiutang noFaktur char(10), tglTerima datetime, idUser char(10), idPelangganvarchar(50), namaPelanggan varchar(50), piutang money
j. tbUtang noFaktur char(10), tglBayar datetime, idUser char(10), idPemasokvarchar(50), namaPemasok varchar(50), utang money
4. Buka Programmability klik kanan Stored Procedures New Stored Procedure.
6
5. Hapus isi dari lembar kerja Stored Procedure lalu ketikkan procedure-procedure berikut inikemudian Execute.
tbUsercreate procedure tampilasselect * from tbUserexec tampil
create procedure tambah(@idUser char(10),@namaUser varchar(50),@pass varchar(50))asinsert into tbUservalues(@idUser,@namaUser,@pass)
create procedure ubah@idUser char(10),@namaUser varchar(50),@pass varchar(50)asupdate tbUser setnamaUser=@namaUser,pass=@passwhere idUser=@idUserselect * from tbUser
create procedure hapus@idUser char(10)asdelete from tbUser where idUser=@idUser
tbBagancreate procedure tampilBaganasselect * from tbBaganexec tampilBagan
create procedure tambahBagan(@kodeAkun char(10),@namaAkun varchar(50))asinsert into tbBaganvalues(@kodeAkun,@namaAkun)
create procedure ubahBagan@kodeAkun char(10),@namaAkun varchar(50)asupdate tbBagan setnamaAkun=@namaAkunwhere kodeAkun=@kodeAkunselect * from tbBagan
create procedure hapusBagan@kodeAkun char(10)asdelete from tbBagan where kodeAkun=@kodeAkun
tbBarangcreate procedure tampilBarang
7
asselect * from tbBarangexec tampilBarang
create procedure tambahBarang(@idBarang char(10),@namaBarang varchar(50),@hargaBeli money,@hargaJual money,@stok int)asinsert into tbBarangvalues(@idBarang,@namaBarang,@hargaBeli,@hargaJual,@stok)
create procedure ubahBarang@idBarang char(10),@namaBarang varchar(50),@hargaBeli money,@hargaJual money,@stok intasupdate tbBarang setnamaBarang=@namaBarang,hargaBeli=@hargaBeli,hargaJual=@hargaJual,stok=@stokwhere idBarang=@idBarangselect * from tbBarang
create procedure hapusBarang@idBarang char(10)asdelete from tbBarang where idBarang=@idBarang
tbBelicreate procedure tampilBeliasselect * from tbBeliexec tampilBeli
create procedure tambahBeli(@noFaktur char(10),@tglBeli datetime,@idUser char(10),@idPemasok char(10),@namaPemasok varchar(50),@idBarang char(10),@namaBarang varchar(50),@hargaBeli money,@jlhTerima int,@total money)asinsert into tbBelivalues(@noFaktur,@tglBeli,@idUser,@idPemasok,@namaPemasok,@idBarang,@namaBarang,@hargaBeli,@jlhTerima,@total)
create procedure ubahBeli@noFaktur char(10),@tglBeli datetime,@idUser char(10),@idPemasok char(10),@namaPemasok varchar(50),@idBarang char(10),@namaBarang varchar(50),@hargaBeli money,@jlhTerima int,
8
@total moneyasupdate tbBeli settglBeli=@tglBeli,idUser=@idUser,idPemasok=@idPemasok,namaPemasok=@namaPemasok,idBarang=@idBarang,namaBarang=@namaBarang,hargaBeli=@hargaBeli,jlhTerima=@jlhTerima,total=@totalwhere noFaktur=@noFakturselect * from tbBeli
create procedure hapusBeli@noFaktur char(10)asdelete from tbBeli where noFaktur=@noFaktur
tbJualcreate procedure tampilJualasselect * from tbJualexec tampilJual
create procedure tambahJual(@noFaktur char(10),@tglJual datetime,@idUser char(10),@idPelanggan char(10),@namaPelanggan varchar(50),@idBarang char(10),@namaBarang varchar(50),@hargaJual money,@jlhBeli int,@total money)asinsert into tbJualvalues(@noFaktur,@tglJual,@idUser,@idPelanggan,@namaPelanggan,@idBarang,@namaBarang,@hargaJual,@jlhBeli,@total)
create procedure ubahJual@noFaktur char(10),@tglJual datetime,@idUser char(10),@idPelanggan char(10),@namaPelanggan varchar(50),@idBarang char(10),@namaBarang varchar(50),@hargaJual money,@jlhBeli int,@total moneyasupdate tbJual settglJual=@tglJual,idUser=@idUser,idPelanggan=@idPelanggan,namaPelanggan=@namaPelanggan,idBarang=@idBarang,namaBarang=@namaBarang,hargaJual=@hargaJual,jlhBeli=@jlhBeli,total=@totalwhere noFaktur=@noFakturselect * from tbJual
create procedure hapusJual@noFaktur char(10)asdelete from tbJual where noFaktur=@noFaktur
tbJurnalcreate procedure tampilJurnalasselect * from tbJurnal
9
exec tampilJurnal
create procedure tambahJurnal(@kodeJurnal char(10),@tanggal datetime,@noBukti char(10),@keterangan varchar(50),@kodeAkun char(10),@namaAkun varchar(50),@deb_kred varchar(50),@jumlah money)asinsert into tbJurnalvalues(@kodeJurnal,@tanggal,@noBukti,@keterangan,@kodeAkun,@namaAkun,@deb_kred,@jumlah)
create procedure ubahJurnal@kodeJurnal char(10),@tanggal datetime,@noBukti char(10),@keterangan varchar(50),@kodeAkun char(10),@namaAkun varchar(50),@deb_kred varchar(50),@jumlah moneyasupdate tbJurnal settanggal=@tanggal,noBukti=@noBukti,keterangan=@keterangan,kodeAkun=@kodeAkun,namaAkun=@namaAkun,deb_kred=@deb_kred,jumlah=@jumlahwhere kodeJurnal=@kodeJurnalselect * from tbJurnal
create procedure hapusJurnal@kodeJurnal char(10)asdelete from tbJurnal where kodeJurnal=@kodeJurnal
tbPelanggancreate procedure tampilPelangganasselect * from tbPelangganexec tampilPelanggan
create procedure tambahPelanggan(@idPelanggan char(10),@namaPelanggan varchar(50),@alamat varchar(50),@telepon varchar(50))asinsert into tbPelangganvalues(@idPelanggan,@namaPelanggan,@alamat,@telepon)
create procedure ubahPelanggan@idPelanggan char(10),@namaPelanggan varchar(50),@alamat varchar(50),@telepon varchar(50)asupdate tbPelanggan setnamaPelanggan=@namaPelanggan,alamat=@alamat,telepon=@teleponwhere idPelanggan=@idPelangganselect * from tbPelanggan
create procedure hapusPelanggan
10
@idPelanggan char(10)asdelete from tbPelanggan where idPelanggan=@idPelanggan
tbPemasokcreate procedure tampilPemasokasselect * from tbPemasokexec tampilPemasok
create procedure tambahPemasok(@idPemasok char(10),@namaPemasok varchar(50),@alamat varchar(50),@telepon varchar(50))asinsert into tbPemasokvalues(@idPemasok,@namaPemasok,@alamat,@telepon)
create procedure ubahPemasok@idPemasok char(10),@namaPemasok varchar(50),@alamat varchar(50),@telepon varchar(50)asupdate tbPemasok setnamaPemasok=@namaPemasok,alamat=@alamat,telepon=@teleponwhere idPemasok=@idPemasokselect * from tbPemasok
create procedure hapusPemasok@idPemasok char(10)asdelete from tbPemasok where idPemasok=@idPemasok
tbPiutangcreate procedure tampilPiutangasselect * from tbPiutangexec tampilPiutang
create procedure tambahPiutang(@noFaktur char(10),@tglTerima datetime,@idUser char(10),@idPelanggan char(50),@namaPelanggan varchar(50),@piutang money)asinsert into tbPiutangvalues(@noFaktur,@tglTerima,@idUser,@idPelanggan,@namaPelanggan,@piutang)
create procedure ubahPiutang@noFaktur char(10),@tglTerima datetime,@idUser char(10),@idPelanggan char(50),@namaPelanggan varchar(50),@piutang moneyasupdate tbPiutang set
11
tglTerima=@tglTerima,idUser=@idUser,idPelanggan=@idPelanggan,namaPelanggan=@namaPelanggan,piutang=@piutangwhere noFaktur=@noFakturselect * from tbPiutang
create procedure hapusPiutang@noFaktur char(10)asdelete from tbPiutang where noFaktur=@noFaktur
tbUtangcreate procedure tampilUtangasselect * from tbUtangexec tampilUtang
create procedure tambahUtang(@noFaktur char(10),@tglBayar datetime,@idUser char(10),@idPemasok char(50),@namaPemasok varchar(50),@utang money)asinsert into tbUtangvalues(@noFaktur,@tglBayar,@idUser,@idPemasok,@namaPemasok,@Utang)
create procedure ubahUtang@noFaktur char(10),@tglBayar datetime,@idUser char(10),@idPemasok char(50),@namaPemasok varchar(50),@utang moneyasupdate tbUtang settglBayar=@tglBayar,idUser=@idUser,idPemasok=@idPemasok,namaPemasok=@namaPemasok,utang=@utangwhere noFaktur=@noFakturselect * from tbUtang
create procedure hapusUtang@noFaktur char(10)asdelete from tbUtang where noFaktur=@noFaktu
12
Membuat Koneksi Database1. Pilih Data Add New Data Source Database, klik Next
2. Pilih Dataset, klik Next
13
3. Pilih New Connection
4. Pilih server name yang sesuai dengan Database PC kita kemudian pilih databaseaplikasiSIA lalu klik Test Connection. Jika sukses klik OK.
5. Klik Next
14
6. Klik Next
7. Beri centang pada Tables lalu Finish
8. Selanjutnya buat Modul untuk koneksi. Pilih Project Add Module, klik Add
15
9. Ketikkan listing berikut pada lembar kerja Module1
Imports System.Data.SqlClientModule Module1
Public conn As SqlConnectionPublic da As SqlDataAdapterPublic ds As New DataSetPublic cmd As SqlCommandPublic rd As SqlDataReaderPublic str As String
Public Sub koneksi()str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;Integrated
Security=True"conn = New SqlConnection(str)If conn.State = ConnectionState.Closed Then
conn.Open()End If
End SubEnd Module
16
PERTEMUAN III
Merancang Form Input Bagan Akun1. Pilih Project Add Windows Form, beri nama formBaganAkun, klik Add
2. Gunakan tools Label, TextBox, Button, dan DataGridView yang diambil dari jendelaToolBox
3. Modifikasi sehingga menjadi seperti ini :
17
4. Ketikkan listing berikut pada lembar kerja formBaganAkun
Imports System.Data.SqlClientPublic Class formBaganAkun
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""TextBox2.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilBagan(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 2
.Columns(0).Name = "Kode Akun"
.Columns(1).Name = "Nama Akun"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbBagan"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(1) As Stringbaris(0) = rd(0) 'Kode Akunbaris(1) = rd(1) 'Nama AkunxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
18
Private Sub formBaganAkun_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilBagan(DataGridView1)End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(1, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" ThenMsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")
ElseDim cmd As New SqlCommand("tambahBagan", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@kodeAkun", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@namaAkun", SqlDbType.VarChar, 50).Value =TextBox2.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBagan(DataGridView1)
End IfCall bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahBagan", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@kodeAkun", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@namaAkun", SqlDbType.VarChar, 50).Value = TextBox2.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finally
19
koneksi.Close()End TryCall tampilBagan(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusBagan", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@kodeAkun", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBagan(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
5. Buat form untuk data user dengan nama formUser
6. Ketikkan listing berikut pada lembar kerja formUser
Imports System.Data.SqlClientPublic Class formUser
20
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""TextBox2.Text = ""TextBox3.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampil(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 3
.Columns(0).Name = "ID User"
.Columns(1).Name = "Username"
.Columns(2).Name = "Password"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbUser"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(2) As Stringbaris(0) = rd(0) 'ID Userbaris(1) = rd(1) 'Usernamebaris(2) = rd(2) 'PasswordxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formUser_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
Call tampil(DataGridView1)End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(1, DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(2, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
21
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" ThenMsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")
ElseDim cmd As New SqlCommand("tambah", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@namaUser", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@pass", SqlDbType.VarChar, 50).Value = TextBox3.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampil(DataGridView1)
End IfCall bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubah", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@namaUser", SqlDbType.VarChar, 50).Value = TextBox2.Text
.Parameters.Add("@pass", SqlDbType.VarChar, 50).Value = TextBox3.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampil(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapus", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As Exception
22
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")Finally
koneksi.Close()End TryCall tampil(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
23
PERTEMUAN IV
Merancang Form Input Pelanggan1. Buat form dengan nama formPelanggan
2. Ketikkan listing berikut pada lembar kerja formPelanggan
Imports System.Data.SqlClientPublic Class formPelanggan
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""TextBox2.Text = ""TextBox3.Text = ""TextBox4.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilPelanggan(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 4
.Columns(0).Name = "ID Pelanggan"
.Columns(1).Name = "Nama Pelanggan"
.Columns(2).Name = "Alamat"
.Columns(3).Name = "Telepon"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbPelanggan"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(3) As String
24
baris(0) = rd(0) 'ID Pelangganbaris(1) = rd(1) 'Nama Pelangganbaris(2) = rd(2) 'Alamatbaris(3) = rd(3) 'TeleponxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formPelanggan_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilPelanggan(DataGridView1)End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(1, DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(2, DataGridView1.CurrentRow.Index).ValueMe.TextBox4.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" OrTextBox4.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahPelanggan", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@namaPelanggan", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@alamat", SqlDbType.VarChar, 50).Value =TextBox3.Text
.Parameters.Add("@telepon", SqlDbType.VarChar, 50).Value =TextBox4.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPelanggan(DataGridView1)
End IfCall bersih()
25
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahPelanggan", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@namaPelanggan", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@alamat", SqlDbType.VarChar, 50).Value = TextBox3.Text
.Parameters.Add("@telepon", SqlDbType.VarChar, 50).Value = TextBox4.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPelanggan(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusPelanggan", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPelanggan(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
26
Merancang Form Input Pemasok1. Buat form dengan nama formPemasok
2. Ketikkan listing berikut pada lembar kerja formPemasok
Imports System.Data.SqlClientPublic Class formPemasok
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""TextBox2.Text = ""TextBox3.Text = ""TextBox4.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilPemasok(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 4
.Columns(0).Name = "ID Pemasok"
.Columns(1).Name = "Nama Pemasok"
.Columns(2).Name = "Alamat"
.Columns(3).Name = "Telepon"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbPemasok"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(3) As Stringbaris(0) = rd(0) 'ID Pemasokbaris(1) = rd(1) 'Nama Pemasokbaris(2) = rd(2) 'Alamat
27
baris(3) = rd(3) 'TeleponxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formPemasok_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilPemasok(DataGridView1)End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(1, DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(2, DataGridView1.CurrentRow.Index).ValueMe.TextBox4.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" OrTextBox4.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahPemasok", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@namaPemasok", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@alamat", SqlDbType.VarChar, 50).Value =TextBox3.Text
.Parameters.Add("@telepon", SqlDbType.VarChar, 50).Value =TextBox4.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPemasok(DataGridView1)
End IfCall bersih()
End Sub
28
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahPemasok", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@namaPemasok", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@alamat", SqlDbType.VarChar, 50).Value = TextBox3.Text
.Parameters.Add("@telepon", SqlDbType.VarChar, 50).Value = TextBox4.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPemasok(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusPemasok", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPemasok(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
29
Merancang Form Input Barang Dagang1. Buat form dengan nama formBarang
2. Ketikkan lisitng berikut pada lembar kerja formBarang
Imports System.Data.SqlClientPublic Class formBarang
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""TextBox2.Text = ""TextBox3.Text = ""TextBox4.Text = ""TextBox5.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilBarang(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 5
.Columns(0).Name = "ID Barang"
.Columns(1).Name = "Nama Barang"
.Columns(2).Name = "Harga Beli"
.Columns(3).Name = "Harga Jual"
.Columns(4).Name = "Stok"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbBarang"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(4) As Stringbaris(0) = rd(0) 'ID Barangbaris(1) = rd(1) 'Nama Barang
30
baris(2) = rd(2) 'Harga Belibaris(3) = rd(3) 'Harga Jualbaris(4) = rd(4) 'StokxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formBarang_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilBarang(DataGridView1)End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(1, DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(2, DataGridView1.CurrentRow.Index).ValueMe.TextBox4.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueMe.TextBox5.Text = Me.DataGridView1.Item(4, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" OrTextBox4.Text = "" Or TextBox5.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahBarang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@namaBarang", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@hargaBeli", SqlDbType.Money).Value = TextBox3.Text
.Parameters.Add("@hargaJual", SqlDbType.Money).Value = TextBox4.Text
.Parameters.Add("@stok", SqlDbType.Int).Value = TextBox5.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBarang(DataGridView1)
End IfCall bersih()
End Sub
31
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahBarang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@namaBarang", SqlDbType.VarChar, 50).Value =TextBox2.Text
.Parameters.Add("@hargaBeli", SqlDbType.Money).Value = TextBox3.Text
.Parameters.Add("@hargaJual", SqlDbType.Money).Value = TextBox4.Text
.Parameters.Add("@stok", SqlDbType.Int).Value = TextBox5.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBarang(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusBarang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBarang(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
32
PERTEMUAN V
Merancang Form Input Jurnal Transaksi1. Buat form dengan nama formJurnal. Pada ComboBox Debit/Kredit klik kanan, Edit Items
tambahkan Debit dan Kredit.
2. Ketikkan listing berikut pada lembar kerja formJurnal
Imports System.Data.SqlClientPublic Class formJurnal
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""TextBox2.Text = ""TextBox3.Text = ""TextBox4.Text = ""ComboBox2.Text = ""TextBox5.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilJurnal(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 8
.Columns(0).Name = "Kode Jurnal"
.Columns(1).Name = "Tanggal"
.Columns(2).Name = "No Bukti"
.Columns(3).Name = "Keterangan"
.Columns(4).Name = "Kode Akun"
.Columns(5).Name = "Nama Akun"
.Columns(6).Name = "Debit"
.Columns(7).Name = "Kredit"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbJurnal"Dim cmd As New SqlCommand(sSql, koneksi)Try
33
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(7) As Stringbaris(0) = rd(0) 'Kode Jurnalbaris(1) = rd(1) 'Tanggalbaris(2) = rd(2) 'No Buktibaris(3) = rd(3) 'Keteranganbaris(4) = rd(4) 'Kode Akunbaris(5) = rd(5) 'Nama Akunbaris(6) = rd(6) 'Debitbaris(7) = rd(7) 'KreditxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formJurnal_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilJurnal(DataGridView1)Dim sSql As StringsSql = "select * from tbBagan"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox1.Items.Add(rd.Item("namaAkun"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" OrTextBox4.Text = "" Or
ComboBox1.Text = "" Or ComboBox2.Text = "" Or TextBox5.Text = "" ThenMsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")
ElseDim cmd As New SqlCommand("tambahJurnal", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@kodeJurnal", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@tanggal", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@noBukti", SqlDbType.Char, 10).Value = TextBox2.Text
.Parameters.Add("@keterangan", SqlDbType.VarChar, 50).Value =TextBox3.Text
34
.Parameters.Add("@kodeAkun", SqlDbType.Char, 10).Value =TextBox4.Text
.Parameters.Add("@namaAkun", SqlDbType.VarChar, 50).Value =ComboBox1.Text
If ComboBox2.Text = "Debit" Then.Parameters.Add("@debit", SqlDbType.Money).Value = TextBox5.Text.Parameters.Add("@kredit", SqlDbType.Money).Value = "0"
Else.Parameters.Add("@debit", SqlDbType.Money).Value = "0".Parameters.Add("@kredit", SqlDbType.Money).Value = TextBox5.Text
End If.ExecuteNonQuery()
End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilJurnal(DataGridView1)
End IfCall bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
formMenuUtama.Show()End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbBagan where namaAkun='" & ComboBox1.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox4.Text = rd.Item("kodeAkun")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End SubEnd Class
35
PERTEMUAN VI
Merancang Form Input Penjualan1. Buat form dengan nama formPenjualan
2. Ketikkan listing berikut pada lembar kerja formPenjualan
Imports System.Data.SqlClientPublic Class formPenjualan
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""ComboBox1.Text = ""TextBox2.Text = ""ComboBox2.Text = ""TextBox3.Text = ""ComboBox3.Text = ""TextBox4.Text = ""TextBox5.Text = ""TextBox6.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilJual(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 10
.Columns(0).Name = "No Faktur"
.Columns(1).Name = "Tanggal Penjualan"
.Columns(2).Name = "ID User"
.Columns(3).Name = "ID Pelanggan"
.Columns(4).Name = "Nama Pelanggan"
.Columns(5).Name = "ID Barang"
.Columns(6).Name = "Nama Barang"
.Columns(7).Name = "Harga Barang"
.Columns(8).Name = "Jumlah Beli"
.Columns(9).Name = "Total Bayar"
36
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbJual"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(9) As Stringbaris(0) = rd(0) 'No Fakturbaris(1) = rd(1) 'Tanggal Penjualanbaris(2) = rd(2) 'ID Userbaris(3) = rd(3) 'ID Pelangganbaris(4) = rd(4) 'Nama Pelangganbaris(5) = rd(5) 'ID Barangbaris(6) = rd(6) 'Nama Barangbaris(7) = rd(7) 'Harga Barangbaris(8) = rd(8) 'Jumlah Belibaris(9) = rd(9) 'Total BayarxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formPenjualan_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilJual(DataGridView1)
Dim sSql As StringsSql = "select * from tbUser"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox1.Items.Add(rd.Item("idUSer"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
Dim aSql As StringaSql = "select * from tbPelanggan"Dim com As New SqlCommand(aSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = com.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox2.Items.Add(rd.Item("namaPelanggan"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
Dim Sql As StringSql = "select * from tbBarang"Dim cmm As New SqlCommand(Sql, koneksi)
37
Trykoneksi.Open()Dim rd As SqlDataReader = cmm.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox3.Items.Add(rd.Item("namaBarang"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or ComboBox1.Text = "" Or TextBox2.Text = "" OrComboBox2.Text = "" Or TextBox3.Text = "" Or
ComboBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" OrTextBox6.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahJual", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@tglJual", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value =TextBox2.Text
.Parameters.Add("@namaPelanggan", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value =TextBox3.Text
.Parameters.Add("@namaBarang", SqlDbType.VarChar, 50).Value =ComboBox3.Text
.Parameters.Add("@hargaJual", SqlDbType.Money).Value = TextBox4.Text
.Parameters.Add("@jlhBeli", SqlDbType.Int).Value = TextBox5.Text
.Parameters.Add("@total", SqlDbType.Money).Value = TextBox6.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilJual(DataGridView1)
End IfCall bersih()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.DateTimePicker1.Text = Me.DataGridView1.Item(1,
DataGridView1.CurrentRow.Index).Value
38
Me.ComboBox1.Text = Me.DataGridView1.Item(2,DataGridView1.CurrentRow.Index).Value
Me.TextBox2.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueMe.ComboBox2.Text = Me.DataGridView1.Item(4,
DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(5, DataGridView1.CurrentRow.Index).ValueMe.ComboBox3.Text = Me.DataGridView1.Item(6,
DataGridView1.CurrentRow.Index).ValueMe.TextBox4.Text = Me.DataGridView1.Item(7, DataGridView1.CurrentRow.Index).ValueMe.TextBox5.Text = Me.DataGridView1.Item(8, DataGridView1.CurrentRow.Index).ValueMe.TextBox6.Text = Me.DataGridView1.Item(9, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahJual", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@tglJual", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value = TextBox2.Text
.Parameters.Add("@namaPelanggan", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value = TextBox3.Text
.Parameters.Add("@namaBarang", SqlDbType.VarChar, 50).Value =ComboBox3.Text
.Parameters.Add("@hargaJual", SqlDbType.Money).Value = TextBox4.Text
.Parameters.Add("@jlhBeli", SqlDbType.Int).Value = TextBox5.Text
.Parameters.Add("@total", SqlDbType.Money).Value = TextBox6.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilJual(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusJual", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
39
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilJual(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbPelanggan where namaPelanggan='" & ComboBox2.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox2.Text = rd.Item("idPelanggan")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox3.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbBarang where namaBarang='" & ComboBox3.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox3.Text = rd.Item("idBarang")TextBox4.Text = rd.Item("hargaJual")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
TextBox6.Text = Val(TextBox4.Text) * Val(TextBox5.Text)End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
40
PERTEMUAN VII
Merancang Form Input Penerimaan Piutang1. Buat form dengan nama formPiutang
2. Ketikkan listing berikut pada lembar kerja formPiutang
Imports System.Data.SqlClientPublic Class formPiutang
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""ComboBox1.Text = ""TextBox2.Text = ""ComboBox2.Text = ""TextBox3.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilPiutang(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 6
.Columns(0).Name = "No Faktur"
.Columns(1).Name = "Tanggal Penerimaan"
.Columns(2).Name = "ID User"
.Columns(3).Name = "ID Pelanggan"
.Columns(4).Name = "Nama Pelanggan"
.Columns(5).Name = "Piutang"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbPiutang"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReader
41
If rd.HasRows ThenWhile rd.Read
Dim baris(5) As Stringbaris(0) = rd(0) 'No Fakturbaris(1) = rd(1) 'Tanggal Penerimaanbaris(2) = rd(2) 'ID Userbaris(3) = rd(3) 'ID Pelangganbaris(4) = rd(4) 'Nama Pelangganbaris(5) = rd(5) 'PiutangxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formPiutang_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilPiutang(DataGridView1)
Dim sSql As StringsSql = "select * from tbUser"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox1.Items.Add(rd.Item("idUSer"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
Dim aSql As StringaSql = "select * from tbPelanggan"Dim com As New SqlCommand(aSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = com.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox2.Items.Add(rd.Item("namaPelanggan"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.DateTimePicker1.Text = Me.DataGridView1.Item(1,
DataGridView1.CurrentRow.Index).ValueMe.ComboBox1.Text = Me.DataGridView1.Item(2,
DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueMe.ComboBox2.Text = Me.DataGridView1.Item(4,
DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(5, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = False
42
Button3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or ComboBox1.Text = "" Or TextBox2.Text = "" OrComboBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahPiutang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@tglTerima", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value =TextBox2.Text
.Parameters.Add("@namaPelanggan", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@piutang", SqlDbType.Money).Value = TextBox3.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPiutang(DataGridView1)
End IfCall bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahPiutang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@tglTerima", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPelanggan", SqlDbType.Char, 10).Value = TextBox2.Text
.Parameters.Add("@namaPelanggan", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@piutang", SqlDbType.Money).Value = TextBox3.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finally
43
koneksi.Close()End TryCall tampilPiutang(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusPiutang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilPiutang(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbPelanggan where namaPelanggan='" & ComboBox2.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox2.Text = rd.Item("idPelanggan")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
PERTEMUAN VIII
Ujian Tengah Semester (UTS)
44
PERTEMUAN IX
Merancang Form Input Pembelian1. Buat form dengan nama formPembelian
2. Ketikkan listing berikut pada lembar kerja formPembelian
Imports System.Data.SqlClientPublic Class formPembelian
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""ComboBox1.Text = ""TextBox2.Text = ""ComboBox2.Text = ""TextBox3.Text = ""ComboBox3.Text = ""TextBox4.Text = ""TextBox5.Text = ""TextBox6.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilBeli(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 10
.Columns(0).Name = "No Faktur"
.Columns(1).Name = "Tanggal Pembelian"
.Columns(2).Name = "ID User"
.Columns(3).Name = "ID Pemasok"
.Columns(4).Name = "Nama Pemasok"
.Columns(5).Name = "ID Barang"
.Columns(6).Name = "Nama Barang"
.Columns(7).Name = "Harga Barang"
.Columns(8).Name = "Jumlah Terima"
.Columns(9).Name = "Total Bayar"
45
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbBeli"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(9) As Stringbaris(0) = rd(0) 'No Fakturbaris(1) = rd(1) 'Tanggal Pembelianbaris(2) = rd(2) 'ID Userbaris(3) = rd(3) 'ID Pemasokbaris(4) = rd(4) 'Nama Pemasokbaris(5) = rd(5) 'ID Barangbaris(6) = rd(6) 'Nama Barangbaris(7) = rd(7) 'Harga Barangbaris(8) = rd(8) 'Jumlah Terimabaris(9) = rd(9) 'Total BayarxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formPembelian_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilBeli(DataGridView1)
Dim sSql As StringsSql = "select * from tbUser"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox1.Items.Add(rd.Item("idUSer"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
Dim aSql As StringaSql = "select * from tbPemasok"Dim com As New SqlCommand(aSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = com.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox2.Items.Add(rd.Item("namaPemasok"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
Dim Sql As StringSql = "select * from tbBarang"Dim cmm As New SqlCommand(Sql, koneksi)
46
Trykoneksi.Open()Dim rd As SqlDataReader = cmm.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox3.Items.Add(rd.Item("namaBarang"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.DateTimePicker1.Text = Me.DataGridView1.Item(1,
DataGridView1.CurrentRow.Index).ValueMe.ComboBox1.Text = Me.DataGridView1.Item(2,
DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueMe.ComboBox2.Text = Me.DataGridView1.Item(4,
DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(5, DataGridView1.CurrentRow.Index).ValueMe.ComboBox3.Text = Me.DataGridView1.Item(6,
DataGridView1.CurrentRow.Index).ValueMe.TextBox4.Text = Me.DataGridView1.Item(7, DataGridView1.CurrentRow.Index).ValueMe.TextBox5.Text = Me.DataGridView1.Item(8, DataGridView1.CurrentRow.Index).ValueMe.TextBox6.Text = Me.DataGridView1.Item(9, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = TrueButton2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or ComboBox1.Text = "" Or TextBox2.Text = "" OrComboBox2.Text = "" Or TextBox3.Text = "" Or
ComboBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" OrTextBox6.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahBeli", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@tglBeli", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value =TextBox2.Text
.Parameters.Add("@namaPemasok", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value =TextBox3.Text
47
.Parameters.Add("@namaBarang", SqlDbType.VarChar, 50).Value =ComboBox3.Text
.Parameters.Add("@hargaBeli", SqlDbType.Money).Value = TextBox4.Text
.Parameters.Add("@jlhTerima", SqlDbType.Int).Value = TextBox5.Text
.Parameters.Add("@total", SqlDbType.Money).Value = TextBox6.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBeli(DataGridView1)
End IfCall bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahBeli", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@tglBeli", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value = TextBox2.Text
.Parameters.Add("@namaPemasok", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@idBarang", SqlDbType.Char, 10).Value = TextBox3.Text
.Parameters.Add("@namaBarang", SqlDbType.VarChar, 50).Value =ComboBox3.Text
.Parameters.Add("@hargaBeli", SqlDbType.Money).Value = TextBox4.Text
.Parameters.Add("@jlhTerima", SqlDbType.Int).Value = TextBox5.Text
.Parameters.Add("@total", SqlDbType.Money).Value = TextBox6.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilBeli(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusBeli", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As Exception
48
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")Finally
koneksi.Close()End TryCall tampilBeli(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbPemasok where namaPemasok='" & ComboBox2.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox2.Text = rd.Item("idPemasok")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox3.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbBarang where namaBarang='" & ComboBox3.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox3.Text = rd.Item("idBarang")TextBox4.Text = rd.Item("hargaBeli")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
TextBox6.Text = Val(TextBox4.Text) * Val(TextBox5.Text)End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
49
PERTEMUAN X
Merancang Form Input Pembayaran Utang1. Buat form dengan nama formUtang
2. Ketikkan listing berikut pada lembar kerja formUtang
Imports System.Data.SqlClientPublic Class formUtang
Dim str = "Data Source=TOSHIBA-PC;Initial Catalog=aplikasiSIA;IntegratedSecurity=True"
Dim koneksi As New SqlConnection(str)
Sub bersih()TextBox1.Text = ""ComboBox1.Text = ""TextBox2.Text = ""ComboBox2.Text = ""TextBox3.Text = ""Button1.Enabled = TrueButton2.Enabled = TrueButton3.Enabled = FalseButton4.Enabled = FalseButton5.Enabled = TrueTextBox1.Focus()
End Sub
Protected Sub tampilUtang(ByVal xGrid As DataGridView)With xGrid
.ColumnCount = 6
.Columns(0).Name = "No Faktur"
.Columns(1).Name = "Tanggal Pembayaran"
.Columns(2).Name = "ID User"
.Columns(3).Name = "ID Pemasok"
.Columns(4).Name = "Nama Pemasok"
.Columns(5).Name = "Utang"
.Rows.Clear()End WithDim sSql As StringsSql = "Select * from tbUtang"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()
50
Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadDim baris(5) As Stringbaris(0) = rd(0) 'No Fakturbaris(1) = rd(1) 'Tanggal Pembayaranbaris(2) = rd(2) 'ID Userbaris(3) = rd(3) 'ID Pemasokbaris(4) = rd(4) 'Nama Pemasokbaris(5) = rd(5) 'UtangxGrid.Rows.Add(baris)
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub formUtang_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call tampilUtang(DataGridView1)
Dim sSql As StringsSql = "select * from tbUser"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox1.Items.Add(rd.Item("idUSer"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
Dim aSql As StringaSql = "select * from tbPemasok"Dim com As New SqlCommand(aSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = com.ExecuteReaderIf rd.HasRows Then
While rd.ReadComboBox2.Items.Add(rd.Item("namaPemasok"))
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e AsSystem.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Me.TextBox1.Text = Me.DataGridView1.Item(0, DataGridView1.CurrentRow.Index).ValueMe.DateTimePicker1.Text = Me.DataGridView1.Item(1,
DataGridView1.CurrentRow.Index).ValueMe.ComboBox1.Text = Me.DataGridView1.Item(2,
DataGridView1.CurrentRow.Index).ValueMe.TextBox2.Text = Me.DataGridView1.Item(3, DataGridView1.CurrentRow.Index).ValueMe.ComboBox2.Text = Me.DataGridView1.Item(4,
DataGridView1.CurrentRow.Index).ValueMe.TextBox3.Text = Me.DataGridView1.Item(5, DataGridView1.CurrentRow.Index).ValueTextBox1.Enabled = FalseButton1.Enabled = True
51
Button2.Enabled = FalseButton3.Enabled = TrueButton4.Enabled = TrueButton5.Enabled = True
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Call bersih()End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button2.Click
If TextBox1.Text = "" Or ComboBox1.Text = "" Or TextBox2.Text = "" OrComboBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Data Masih Kosong", MsgBoxStyle.Information, "Perhatian!")Else
Dim cmd As New SqlCommand("tambahUtang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.Parameters.Add("@tglBayar", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value =TextBox2.Text
.Parameters.Add("@namaPemasok", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@utang", SqlDbType.Money).Value = TextBox3.Text
.ExecuteNonQuery()End WithMsgBox("Disimpan!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilUtang(DataGridView1)
End IfCall bersih()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button3.Click
Dim cmd As New SqlCommand("ubahUtang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value = TextBox1.Text
.Parameters.Add("@tglBayar", SqlDbType.DateTime).Value =DateTimePicker1.Text
.Parameters.Add("@idUser", SqlDbType.Char, 10).Value = ComboBox1.Text
.Parameters.Add("@idPemasok", SqlDbType.Char, 10).Value = TextBox2.Text
.Parameters.Add("@namaPemasok", SqlDbType.VarChar, 50).Value =ComboBox2.Text
.Parameters.Add("@utang", SqlDbType.Money).Value = TextBox3.Text
.ExecuteNonQuery()End WithMsgBox("Diubah!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
52
Finallykoneksi.Close()
End TryCall tampilUtang(DataGridView1)Call bersih()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button4.Click
If MessageBox.Show("Yakin Akan Dihapus?", "", MessageBoxButtons.YesNo) =Windows.Forms.DialogResult.Yes Then
Dim cmd As New SqlCommand("hapusUtang", koneksi)Dim xParam As New SqlParameterxParam.Direction = ParameterDirection.InputTry
koneksi.Open()With cmd
.CommandType = CommandType.StoredProcedure
.Parameters.Add("@noFaktur", SqlDbType.Char, 10).Value =TextBox1.Text
.ExecuteNonQuery()End WithMsgBox("Dihapus!", MsgBoxStyle.Information, "Perhatian!")
Catch ex As ExceptionMsgBox(ex.Message, MsgBoxStyle.Critical, "Error!")
Finallykoneksi.Close()
End TryCall tampilUtang(DataGridView1)Call bersih()
End IfEnd Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles ComboBox2.SelectedIndexChanged
Dim sSql As StringsSql = "select * from tbPemasok where namaPemasok='" & ComboBox2.Text & "'"Dim cmd As New SqlCommand(sSql, koneksi)Try
koneksi.Open()Dim rd As SqlDataReader = cmd.ExecuteReaderIf rd.HasRows Then
While rd.ReadTextBox2.Text = rd.Item("idPemasok")
End WhileEnd If
Catch ex As ExceptionMessageBox.Show(ex.Message)
End Trykoneksi.Close()
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button5.Click
formMenuUtama.Show()End Sub
End Class
3. Agar terlihat rapi, ubahlah StartPosition menjadi CenterScreen pada jendela Propertiesuntuk semua form.
53
PERTEMUAN XI
Merancang Laporan Keuangan
Laporan Laba Rugi1. Pilih Project Add Windows Form Reporting, klik Add
2. Klik OK
3. Pilih tabel yang akan kita gunakan untuk membuat laporan, klik Next
4. Pilih field-field yang ingin kita tampilkan pada laporan, klik Next
54
5. Selanjutnya Next, Next lalu Finish
6. Pilih Project Add Windows Form Toolbox, Reporting, masukkanCrystalReportDocument ke dalam formLapLabaRugi
7. Ketikkan listing berikut ini pada lembar kerja formLapLabaRugi
Imports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.Shared
Public Class formLapLabaRugiDim tblBagan As New DataTableDim tblJurnal As New DataTable
Public tgl_awal As StringPublic tgl_akhir As String
Sub hitunglabarugi()Dim kodeakun As StringDim debet As StringDim kredit As String
SQL = "SELECT kodeAkun,namaAkun FROM tbBagan WHERE kodeAkun = '4%' OR kodeAkun ='5%'"
tblBagan = conn.ExecuteQuery(SQL)Dim totaldebit As Integertotaldebet = 0
Dim totalkredit As Integertotalkredit = 0
For Each rowakun In tblBagan.Rowstotalkredit = 0totaldebit = 0kodeakun = rowakun("kodeAkun")SQL = "SELECT debit,kredit FROM tbJurnal WHERE kodeAkun = '" & kodeakun & "'
" &"AND tanggal>='" & tgl_awal & "' AND tanggal <= '" & tgl_akhir & "'"
tblJurnal = conn.ExecuteQuery(SQL)For Each rowdetail In tblJurnal.Rows
debit = rowdetail("debit")totaldebit += Convert.ToInt32(debit)kredit = rowdetail("kredit")totalkredit += Convert.ToInt32(kredit)
Next
SQL = "SELECT kodeAkun,namaAkun FROM tbBagan WHERE kodeAkun = '4%' OR kodeAkun ='5%'"
tblBagan = conn.ExecuteQuery(SQL)Dim totaldebitpendapatan As IntegerDim totalkreditpendapatan As IntegerDim totaldebitbeban As IntegerDim totalkreditbeban As Integer
totaldebitpendapatan = 0totalkreditpendapatan = 0totaldebitbeban = 0totalkreditbeban = 0
55
For Each rowakun In tblBagan.Rowskodeakun = rowakun("kodeAkun")debit = rowakun("debit")kredit = rowakun("kredit")If kodeakun = "4%" Then
totaldebitpendapatan += debittotalkreditpendapatan += kredit
ElseIf kodeakun = "5%" Thentotaldebitbeban += debittotalkreditbeban += kredit
ElseEnd If
NextDim labarugi As Integerlabarugi = (totaldebitpendapatan + totalkreditpendapatan) - (totaldebitbeban +
totalkreditbeban)
SQL = "UPDATE tb_perubahan_modal SET laba_rugi ='" & labarugi & "' " &"WHERE id = 'modal'"conn.ExecuteNonQuery(SQL)
End Sub
Private Sub formLapLabaRugi_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call hitunglabarugi()End Sub
End Class
Laporan Perubahan Modal
1. Buat Crystal Report dan Form seperti langkah di atas
2. Ketikkan listing berikut pada lembar kerja formLapPerubahanModal
Imports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.Shared
Public Class formLapPerubahanModalDim tblBagan As New DataTableDim tblJurnal As New DataTable
Public tgl_awal As StringPublic tgl_akhir As String
Sub hitungmodalawal()Dim kodeakun As String
Dim debet As StringDim kredit As String
Dim kodejenismodal As Stringkodejenismodal = "003"
SQL = "SELECT kode_akun,debet,kredit FROM tb_akun WHERE kode_jenis ='" &kodejenismodal & "'"
tblAkun = conn.ExecuteQuery(SQL)
Dim totaldebet As Integertotaldebet = 0
Dim totalkredit As Integertotalkredit = 0
For Each rowakun In tblAkun.Rowstotalkredit = 0totaldebet = 0kodeakun = rowakun("kode_akun")
56
SQL = "SELECT debet,kredit FROM tb_detail_transaksi_lain WHERE kode_akun = '"& kodeakun & "' " &
"AND tgl_trans >='" & tgl_awal & "' AND tgl_trans <= '" & tgl_akhir & "'"tblDetailTransaksi = conn.ExecuteQuery(SQL)For Each rowdetail In tblDetailTransaksi.Rows
debet = rowdetail("debet")totaldebet += Convert.ToInt32(debet)kredit = rowdetail("kredit")totalkredit += Convert.ToInt32(kredit)
Next'update totaldebet dan totalkredit untuk akun sekarangSQL = "UPDATE tb_akun SET debet = '" & totaldebet & "',kredit = '" &
totalkredit & "' " &"WHERE kode_akun = '" & kodeakun & "'"
conn.ExecuteNonQuery(SQL)Next
SQL = "SELECT kode_akun,debet,kredit FROM tb_akun WHERE kode_jenis ='" &kodejenismodal & "'"
tblAkun = conn.ExecuteQuery(SQL)
' ubah nilai debet/kredit apakah negatif atau positifFor Each rowakun In tblAkun.Rows
kodeakun = rowakun("kode_akun")debet = rowakun("debet")kredit = rowakun("kredit")
debet = Convert.ToString(0 - Convert.ToInt32(debet))kredit = kreditSQL = "UPDATE tb_akun SET debet ='" & debet & "', kredit = '" & kredit & "' "
&"WHERE kode_akun = '" & kodeakun & "'"
conn.ExecuteNonQuery(SQL)Next
totaldebet = 0totalkredit = 0
SQL = "SELECT kode_akun,debet,kredit FROM tb_akun WHERE kode_jenis ='" &kodejenismodal & "'"
tblAkun = conn.ExecuteQuery(SQL)
' dapatkan total modal AwalFor Each rowakun In tblAkun.Rows
debet = rowakun("debet")kredit = rowakun("kredit")totaldebet += debettotalkredit += kredit
NextSQL = "UPDATE tb_perubahan_modal SET modal_awal ='" & totaldebet + totalkredit &
"' " &"WHERE id = 'modal'"conn.ExecuteNonQuery(SQL)
End Sub
Sub hitunglabarugi()Dim kodeakun As StringDim debet As StringDim kredit As String
SQL = "SELECT kodeAkun,namaAkun FROM tbBagan WHERE kodeAkun = '4%' OR kodeAkun ='5%'"
tblBagan = conn.ExecuteQuery(SQL)Dim totaldebit As Integertotaldebet = 0
Dim totalkredit As Integertotalkredit = 0
57
For Each rowakun In tblBagan.Rowstotalkredit = 0totaldebit = 0kodeakun = rowakun("kodeAkun")SQL = "SELECT debit,kredit FROM tbJurnal WHERE kodeAkun = '" & kodeakun & "'
" &"AND tanggal>='" & tgl_awal & "' AND tanggal <= '" & tgl_akhir & "'"
tblJurnal = conn.ExecuteQuery(SQL)For Each rowdetail In tblJurnal.Rows
debit = rowdetail("debit")totaldebit += Convert.ToInt32(debit)kredit = rowdetail("kredit")totalkredit += Convert.ToInt32(kredit)
Next
SQL = "SELECT kodeAkun,namaAkun FROM tbBagan WHERE kodeAkun = '4%' OR kodeAkun ='5%'"
tblBagan = conn.ExecuteQuery(SQL)Dim totaldebitpendapatan As IntegerDim totalkreditpendapatan As IntegerDim totaldebitbeban As IntegerDim totalkreditbeban As Integer
totaldebitpendapatan = 0totalkreditpendapatan = 0totaldebitbeban = 0totalkreditbeban = 0
For Each rowakun In tblBagan.Rowskodeakun = rowakun("kodeAkun")debit = rowakun("debit")kredit = rowakun("kredit")If kodeakun = "4%" Then
totaldebitpendapatan += debittotalkreditpendapatan += kredit
ElseIf kodeakun = "5%" Thentotaldebitbeban += debittotalkreditbeban += kredit
ElseEnd If
NextDim labarugi As Integerlabarugi = (totaldebitpendapatan + totalkreditpendapatan) - (totaldebitbeban +
totalkreditbeban)
SQL = "UPDATE tb_perubahan_modal SET laba_rugi ='" & labarugi & "' " &"WHERE id = 'modal'"conn.ExecuteNonQuery(SQL)
End Sub
Sub hitungtotalmodalawal()Dim tblperubahanmodal As New DataTableDim modal_awal As StringDim laba_rugi As StringDim total_modal As String
SQL = "SELECT modal_awal, laba_rugi FROM tb_perubahan_modal WHERE id ='modal'"tblperubahanmodal = conn.ExecuteQuery(SQL)modal_awal = tblperubahanmodal.Rows(0).Item("modal_awal")laba_rugi = tblperubahanmodal.Rows(0).Item("laba_rugi")total_modal = Convert.ToInt32(modal_awal) + Convert.ToInt32(laba_rugi)SQL = "UPDATE tb_perubahan_modal SET total_modal ='" & total_modal & "' WHERE id
='modal'"conn.ExecuteNonQuery(SQL)
End Sub
Sub hitungjumlahprive()' kode akun prive adalah 006.001
58
Dim TblDetail As DataTableDim totalPrive As StringDim debet As StringDim kredit As StringDim totaldebet As IntegerDim totalkredit As Integer
SQL = "SELECT debet, kredit FROM tb_detail_transaksi_lain WHERE kode_akun ='006.001' " &
"AND tgl_trans >='" & tgl_awal & "' AND tgl_trans <= '" & tgl_akhir & "'"TblDetail = conn.ExecuteQuery(SQL)
For Each RowDetail In TblDetail.Rowsdebet = RowDetail("debet")totaldebet += Convert.ToInt32(debet)kredit = RowDetail("kredit")totalkredit += Convert.ToInt32(kredit)
Next'update totaldebet dan totalkredit untuk akun prive'update nilai positif atau negatif debet/kredit prive' debet (+) kredit(-)SQL = "UPDATE tb_akun SET debet = '" & totaldebet & "',kredit = '" & (0 -
totalkredit) & "' " &"WHERE kode_akun = '006.001'"
conn.ExecuteNonQuery(SQL)totalPrive = totaldebet - totalkredit' update ke dalam tb_perubahan modalSQL = "UPDATE tb_perubahan_modal SET prive ='" & totalPrive & "' WHERE id
='modal'"conn.ExecuteNonQuery(SQL)
End Sub
Sub hitungmodalakhir()Dim TblDetail As DataTableDim modal_akhir As StringDim modal_awal As StringDim prive As String
SQL = "SELECT total_modal, prive FROM tb_perubahan_modal WHERE id = 'modal'"TblDetail = conn.ExecuteQuery(SQL)modal_awal = TblDetail.Rows(0).Item("total_modal")prive = TblDetail.Rows(0).Item("prive")modal_akhir = Convert.ToInt32(modal_awal) - Convert.ToInt32(prive)
SQL = "UPDATE tb_perubahan_modal SET modal_akhir ='" & modal_akhir & "' WHERE id='modal'"
conn.ExecuteNonQuery(SQL)End Sub
Private Sub formLapLabaRugi_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
Call hitungmodalawal()Call hitunglabarugi()Call hitungtotalmodalawal()Call hitungjumlahprive()Call hitungmodalakhir()
End SubEnd Class
59
PERTEMUAN XII
Pembuatan Setup (Packaging) Program Aplikasi SIA
1. Sebelum melakukan setup kita harus me-detach database kita terlebih dahulu
2. Klik OK
3. Buka project aplikasiSIA
4. Pilih File New Project Other Project Types Setup Wizard
5. Buat nama “Aplikasi SIA”, pilih destinasi folder penyimpanan lalu OK
60
PERTEMUAN XIII
Presentasi
PERTEMUAN XIV
Presentasi
PERTEMUAN XV
Presentasi
PERTEMUAN XVI
Ujian Akhir Semester (UAS)
Recommended