1/30/2012

AMIKHASS BANDUNG

MAKALAH VISUAL BASIC.NET 2005

Imam Firmansyah (10260048) | Semester III

BAB I PENDAHULUAN
1.1.Latar Belakang VB.NET Adalah Salah Satu Bahasa Pemrograman Komputer Tingkat Tinggi. Bahasa Pemrograman Adalah Perintah-Perintah Yang Dimengerti Oleh Computer dan user Untuk Melakukan Tugas-Tugas TertentuBahasa Pemrograman VB.NET Dikembangkan Oleh Microsoft . 1.2.Masalah Bahasa pemrogramanzaman ke zaman lebih baik dan lebih

bagus,contohnya seperti program Vb.Net yang sudah mempunyai Graphical User Interface,

1.3.Tujuan pembahasan Supaya mahasiswa yang ingin belajar Vb.Net lebih mengerti,dan dapat membuat program

2

BAB II Perancangan Program
2.1 Rancangan Database Membuat tabel relationship diagram

1. Tabel Cat y y y y #Kode_Cat Nama_Cat Jenis_Cat Harga_Cat

3

2. Tabel Pegawai y # NIP y y y y y Nama Alamat Bagian Jenis_Kelamin Telepon

3. Tabel Pelanggan y y y y y # Id_Pelanggan Nama_Pelanggan Alamat_Pelanggan Telepon_Pelanggan Jenis_Brg

4. Tabel Pengecatan y y y #Kode_Pengecatan Jenis_Pengecatan Harga

5. Tabel Transaksi y y y y y y y # Id_Transaksi Kode_Cat NIP Id_Pelanggan Kode_Pengecatan Tanggal Total

4

2.2 Cara Mengkonekkan Ke DataBase Access Caranya dengan mengoneksikann terlebih dahulu database ke Program Aplikasi Painting Brush dengan cara : Klik Tools Connect To Database

2.3 Rancangan Interface Menu Utama

5

Tabel Log-In

Tabel Cat

6

Tabel Pegawai

Tabel Pelanggan

7

Table Pengecatan

Table Transaksi

8

Report Cat

Report Pengecatan

9

Report Transaksi

BAB III
Kodding 3.1 Log-In
Public Class fmLogin Private Sub btMasuk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btMasuk.Click If (txtUser.Text = "imam") And (txtPass.Text = "10260048") Then MDIParent1.MasterToolStripMenuItem.Enabled = True MDIParent1.TransaksiToolStripMenuItem.Enabled = True Close() Else MessageBox.Show("Maaf Password yang Anda Masukkan Salah") Close() End If End Sub Private Sub btBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btBatal.Click Close() End Sub End Class

10

Cat
Public Class fmCat Dim daCat As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection(Koneksi("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\Kuliah\VB\Painting Brush\Painting Brush\Painting.mdb")) Dim dtCat As New DataTable() Dim drCat As DataRow Function Koneksi(ByVal strDatabase As String) As String Dim kalimat As String kalimat = "Provider=Microsoft.Jet.OLEDB.4.0;" kalimat &= "Data Source=" & strDatabase & "" Return kalimat End Function Private Sub fmCat_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dc(1) As DataColumn Try daCat = New OleDb.OleDbDataAdapter("select * from Cat", con) daCat = New OleDb.OleDbDataAdapter("select * from Cat", con) daCat.Fill(dtCat) dc(0) = dtCat.Columns("Kode_Cat") dtCat.PrimaryKey = dc dgCat.DataSource = dtCat Catch errConn As OleDb.OleDbException MsgBox(errConn.Message) End Try End Sub Private Sub btKosong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btKosong.Click kosong() End Sub Private Sub kosong() txtKodeCat.Text = "" txtNamaCat.Text = "" txtJCat.Text = "" txtHargaCat.Text = "" txtKodeCat.Focus() End Sub Private Sub btSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSimpan.Click Try Dim cbCat As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daCat) drCat = dtCat.NewRow

11

drCat("Kode_Cat") = txtKodeCat.Text() drCat("Nama_Cat") = txtNamaCat.Text() drCat("Jenis_Cat") = txtJCat.Text() drCat("Harga_Cat") = Val(txtHargaCat.Text) dtCat.Rows.Add(drCat) con.Open() daCat.Update(dtCat) dtCat.AcceptChanges() con.Close() Catch errTambah As Exception MsgBox(errTambah.Message) End Try kosong() End Sub Private Sub btCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btCari.Click Try drCat = dtCat.Rows.Find(txtKodeCat.Text) txtNamaCat.Text = drCat("Nama_Cat").ToString txtJCat.Text = drCat("Jenis_Cat").ToString txtHargaCat.Text = drCat("Harga_Cat").ToString Catch errCari As Exception MsgBox(errCari.Message) End Try End Sub Private Sub btHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btHapus.Click Try Dim cbCat As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daCat) drCat.Delete() daCat.DeleteCommand = cbCat.GetDeleteCommand daCat.Update(dtCat) dtCat.AcceptChanges() daCat.DeleteCommand.Connection.Close() Catch errHapus As Exception MsgBox(errHapus.Message) End Try End Sub Private Sub btKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btKeluar.Click Me.Close()

12

End Sub End Class

Pengecatan
Public Class fmPengecatan Dim daPeng As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection(Koneksi("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\Kuliah\VB\Painting Brush\Painting Brush\Painting.mdb")) Dim dtPeng As New DataTable() Dim drPeng As DataRow Function Koneksi(ByVal strDatabase As String) As String Dim kalimat As String kalimat = "Provider=Microsoft.Jet.OLEDB.4.0;" kalimat &= "Data Source=" & strDatabase & "" Return kalimat End Function Private Sub fmPengecatan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dc(1) As DataColumn Try daPeng = New OleDb.OleDbDataAdapter("select * from Pengecatan", con) daPeng = New OleDb.OleDbDataAdapter("select * from Pengecatan", con) daPeng.Fill(dtPeng) dc(0) = dtPeng.Columns("Kode_Pengecatan") dtPeng.PrimaryKey = dc dgPengecatan.DataSource = dtPeng Catch errConn As OleDb.OleDbException MsgBox(errConn.Message) End Try End Sub Private Sub btSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSimpan.Click Try Dim cbPeng As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daPeng) drPeng = dtPeng.NewRow drPeng("Kode_Pengecatan") = txtKodePengecatan.Text() drPeng("Jenis_Pengecatan") = txtJPengecatan.Text() drPeng("Harga") = Val(txtHarga.Text)

13

dtPeng.Rows.Add(drPeng) con.Open() daPeng.Update(dtPeng) dtPeng.AcceptChanges() con.Close() Catch errTambah As Exception MsgBox(errTambah.Message) End Try kosong() End Sub Private Sub btcari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btcari.Click Try drPeng = dtPeng.Rows.Find(txtKodePengecatan.Text) txtJPengecatan.Text = drPeng("Jenis_Pengecatan").ToString txtHarga.Text = drPeng("Harga").ToString Catch errCari As Exception MsgBox(errCari.Message) End Try End Sub Private Sub btHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btHapus.Click Try Dim cbPeng As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daPeng) drPeng.Delete() daPeng.DeleteCommand = cbPeng.GetDeleteCommand daPeng.Update(dtPeng) dtPeng.AcceptChanges() daPeng.DeleteCommand.Connection.Close() Catch errHapus As Exception MsgBox(errHapus.Message) End Try End Sub Private Sub btKosong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btKosong.Click kosong() End Sub Private Sub kosong() txtKodePengecatan.Text = "" txtJPengecatan.Text = "" txtHarga.Text = ""

14

txtKodePengecatan.Focus() End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Me.Close() End Sub End Class

Transaksi
Public Class fmTransaksi Dim daCat As OleDb.OleDbDataAdapter Dim daPeg As OleDb.OleDbDataAdapter Dim daPel As OleDb.OleDbDataAdapter Dim daPeng As OleDb.OleDbDataAdapter Dim daTrans As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection(Koneksi("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\Kuliah\VB\Painting Brush\Painting Brush\Painting.mdb")) Dim dtCat As New DataTable() Dim dtPeg As New DataTable() Dim dtPel As New DataTable() Dim dtPeng As New DataTable() Dim dtTrans As New DataTable() Dim drCat As DataRow Dim drPeg As DataRow Dim drPeng As DataRow Dim drObat As DataRow Dim drTrans As DataRow Function Koneksi(ByVal strDatabase As String) As String Dim kalimat As String kalimat = "Provider=Microsoft.Jet.OLEDB.4.0;" kalimat &= "Data Source=" & strDatabase & "" Return kalimat End Function Private Sub fmTransaksi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dc(1) As DataColumn Try daCat = New OleDb.OleDbDataAdapter("select * from Cat", con) daCat.Fill(dtCat) dc(0) = dtCat.Columns("Kode_Cat") dtCat.PrimaryKey = dc With cbKCat .DataSource = dtCat

15

.DisplayMember = "Kode_Cat" .ValueMember = "Kode_Cat" End With daPeng = New OleDb.OleDbDataAdapter("select * from Pengecatan", con) daPeng.Fill(dtPeng) dc(0) = dtPeng.Columns("Kode_Pengecatan") dtPeng.PrimaryKey = dc With cbKPeng .DataSource = dtPeng .DisplayMember = "Kode_Pengecatan" .ValueMember = "Kode_Pengecatan" End With daPeg = New OleDb.OleDbDataAdapter("select * from Pegawai", con) daPeg.Fill(dtPeg) dc(0) = dtPeg.Columns("NIP") dtPeg.PrimaryKey = dc With cbNIP .DataSource = dtPeg .DisplayMember = "NIP" .ValueMember = "NIP" End With daPel = New OleDb.OleDbDataAdapter("select * from Pelanggan", con) daPel.Fill(dtPel) dc(0) = dtPel.Columns("Id_Pelanggan") dtPel.PrimaryKey = dc With cbPelanggan .DataSource = dtPel .DisplayMember = "Id_Pelanggan" .ValueMember = "Id_Pelanggan" End With daTrans = New OleDb.OleDbDataAdapter("select * from Transaksi", con) daTrans.Fill(dtTrans) dc(0) = dtTrans.Columns("Id_Transaksi") dtTrans.PrimaryKey = dc Catch errConn As OleDb.OleDbException MsgBox(errConn.Message) End Try kosong() End Sub Private Sub kosong() txtId_Trans.Text = "" cbKCat.Text = ""

16

cbNIP.Text = "" cbKCat.Text = "" cbKPeng.Text = "" cbPelanggan.Text = "" txtNamaCat.Text = "" txtJPengecatan.Text = "" txtHargaCat.Text = "" txtHargaPengecatan.Text = "" txtTotal.Text = "" txtPenerimaan.Text = "" lbKembali.Text = "" txtId_Trans.Focus() End Sub Private Sub btKosong_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btKosong.Click kosong() End Sub Private Sub btKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btKeluar.Click Me.Close() End Sub Private Sub btProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btProses.Click Dim dibayar, kembali, total As Integer total = Val(txtTotal.Text) dibayar = Val(txtPenerimaan.Text) kembali = dibayar - total lbKembali.Text = kembali End Sub Private Sub btSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSimpan.Click Try Dim cbTrans As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daTrans) drTrans = dtTrans.NewRow drTrans("Id_Transaksi") = txtId_Trans.Text() drTrans("Kode_Cat") = cbKCat.Text() drTrans("NIP") = cbNIP.Text() drTrans("Id_Pelanggan") = cbPelanggan.Text() drTrans("Kode_pengecatan") = cbKPeng.Text() drTrans("Tanggal") = DateTimePicker1.Text() drTrans("total") = txtTotal.Text() dtTrans.Rows.Add(drTrans) con.Open() daTrans.Update(dtTrans) dtTrans.AcceptChanges() con.Close()

17

Catch errTambah As Exception MsgBox(errTambah.Message) End Try kosong() End Sub Private Sub cbKCat_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbKCat.SelectedIndexChanged Try Dim drCat As DataRow drCat = dtCat.Rows.Find(cbKCat.Text) txtNamaCat.Text = drCat("Nama_Cat").ToString txtHargaCat.Text = drCat("Harga_Cat").ToString Catch errTampil As Exception End Try End Sub Private Sub cbKPeng_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbKPeng.SelectedIndexChanged Try Dim drPeng As DataRow drPeng = dtPeng.Rows.Find(cbKPeng.Text) txtJPengecatan.Text = drPeng("Jenis_Pengecatan").ToString txtHargaPengecatan.Text = drPeng("Harga").ToString Catch errTampil As Exception End Try End Sub Private Sub txtHargaPengecatan_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHargaPengecatan.TextChanged Dim hcat, hpeng, total As Integer hcat = Val(txtHargaCat.Text) hpeng = Val(txtHargaPengecatan.Text) total = hcat + hpeng txtTotal.Text = total End Sub Private Sub cbPelanggan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbPelanggan.SelectedIndexChanged Try Dim drPel As DataRow

18

drPel = dtPel.Rows.Find(cbPelanggan.Text) Catch errTampil As Exception End Try End Sub Private Sub cbNIP_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbNIP.SelectedIndexChanged Try Dim drPeg As DataRow drPeg = dtPeg.Rows.Find(cbNIP.Text) Catch errTampil As Exception End Try End Sub End Class

19

BAB IV PENUTUP
4.1. Kesimpulan Aplikasi Prainting Brush ini bisa membantu untuk counter kecil yang ingin mengunakan pemrograman. Kelebihan: Mudah untuk digunakan Mudah dikenalkan untuk orang awam Lebih cepat, akurat Kekurangan: Mahal untuk membeli programnya Rumit pembuatannya jika membuat sendiri Butuh waktu untuk membuatnya

20