You are on page 1of 18

Makalah Visual Basic

Tentang Aplikasi Apotek

1/30/2012 Isti Novia Lestari Semester III-C (10260094)

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 pemrograman zaman 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

Isti Novia Lestari | BAB I

2

BAB II Perancangan Program
2.1 Rancangan Database Membuat tabel relationship diagram

1. Tabel Obat y y y y y y y # Kode Obat Nama Obat Jenis Obat Kemasan Satuan Jumlah Obat Harga Satuan

2. Tabel Pegawai y # NIP y y Nama Pegawai Jenis Kelamin

Isti Novia Lestari | BAB II

3

y y

Alamat Telepon

3. Tabel Antrian y y y y y # Kode Antrian Kode Obat NIP Total Tanggal

2.2 Rancangan Interface Menu Utama

Isti Novia Lestari | Perancangan Program

4

Tabel Log-In

Public Class fmLogin Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If (txtUser.Text = "isti") And (txtPass.Text = "10260094") Then MDIParent1.MasterToolStripMenuItem.Enabled = True Close() Else MessageBox.Show("Maaf Password yang Anda Masukkan Salah") Close() End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Close() End Sub End Class

Isti Novia Lestari | Perancangan Program

5

Tabel Obat

Dim daObat As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection(Koneksi("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\Kuliah\VB\Apotek\dbApotek.mdb")) Dim dtObat As New DataTable() Dim drObat 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 fmObat_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dc(1) As DataColumn Try daObat = New OleDb.OleDbDataAdapter("select * from Obat", con) daObat = New OleDb.OleDbDataAdapter("select * from Obat", con) daObat.Fill(dtObat) dc(0) = dtObat.Columns("kode_obat") dtObat.PrimaryKey = dc

Isti Novia Lestari | Perancangan Program

6

dgObat.DataSource = dtObat Catch errConn As OleDb.OleDbException MsgBox(errConn.Message) End Try End Sub Private Sub btClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClear.Click kosong() End Sub Private Sub kosong() txtKodeObat.Text = "" txtNamaObat.Text = "" cbSatuan.Text = "" cbJO.Text = "" cbKemasan.Text = "" txtJumlah.Text = "" txtHarga.Text = "" txtKodeObat.Focus() End Sub Private Sub btTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btTambah.Click Try Dim cbObat As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daObat) drObat = dtObat.NewRow drObat("kode_obat") = txtKodeObat.Text() drObat("nama_obat") = txtNamaObat.Text() drObat("satuan") = cbSatuan.Text() drObat("jenis_obat") = cbJO.Text() drObat("kemasan") = cbKemasan.Text() drObat("jumlah_obat") = Val(txtJumlah.Text) drObat("harga_satuan") = Val(txtHarga.Text) dtObat.Rows.Add(drObat) con.Open() daObat.Update(dtObat) dtObat.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 drObat = dtObat.Rows.Find(txtKodeObat.Text)

Isti Novia Lestari | Perancangan Program

7

txtNamaObat.Text = drObat("nama_obat").ToString cbJO.Text = drObat("jenis_obat").ToString cbKemasan.Text = drObat("kemasan").ToString cbSatuan.Text = drObat("Satuan").ToString txtJumlah.Text = drObat("jumlah_obat").ToString txtHarga.Text = drObat("harga_satuan").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 cbObat As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daObat) drObat.Delete() daObat.DeleteCommand = cbObat.GetDeleteCommand daObat.Update(dtObat) dtObat.AcceptChanges() daObat.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() End Sub End Class

Isti Novia Lestari | Perancangan Program

8

Tabel Pegawai

Public Class fmPegawai Dim daPegawai As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection(Koneksi("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\Kuliah\VB\Apotek\dbApotek.mdb")) Dim dtPegawai As New DataTable() Dim drPegawai 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 fmPegawai_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim dc(1) As DataColumn Try daPegawai = New OleDb.OleDbDataAdapter("select * from pegawai", con) daPegawai = New OleDb.OleDbDataAdapter("select * from pegawai", con) daPegawai.Fill(dtPegawai) dc(0) = dtPegawai.Columns("NIP") dtPegawai.PrimaryKey = dc dgPegawai.DataSource = dtPegawai

Isti Novia Lestari | Perancangan Program

9

Catch errConn As OleDb.OleDbException MsgBox(errConn.Message) End Try End Sub Private Sub kosong() txtNIP.Text = "" txtNama.Text = "" cbJK.Text = "" txtAlamat.Text = "" txtTlp.Text = "" txtNIP.Focus() End Sub Private Sub btClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClear.Click kosong() End Sub Private Sub btTambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btTambah.Click Try Dim cbPegawai As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daPegawai) drPegawai = dtPegawai.NewRow drPegawai("NIP") = txtNIP.Text() drPegawai("nama_pegawai") = txtNama.Text() drPegawai("jenis_kelamin") = cbJK.Text() drPegawai("alamat") = txtAlamat.Text() drPegawai("telepon") = txtTlp.Text() dtPegawai.Rows.Add(drPegawai) con.Open() daPegawai.Update(dtPegawai) dtPegawai.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 drPegawai = dtPegawai.Rows.Find(txtNIP.Text) txtNama.Text = drPegawai("nama_pegawai").ToString cbJK.Text = drPegawai("jenis_kelamin").ToString txtAlamat.Text = drPegawai("alamat").ToString txtTlp.Text = drPegawai("telepon").ToString

Isti Novia Lestari | Perancangan Program

10

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 cbPegawai As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daPegawai) drPegawai.Delete() daPegawai.DeleteCommand = cbPegawai.GetDeleteCommand daPegawai.Update(dtPegawai) dtPegawai.AcceptChanges() daPegawai.DeleteCommand.Connection.Close() Catch errHapus As Exception MsgBox(errHapus.Message) End Try End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Close() End Sub End Class

Isti Novia Lestari | Perancangan Program

11

Tabel Transaksi

Public Class fmTransaksi Dim daObat As OleDb.OleDbDataAdapter Dim daPegawai As OleDb.OleDbDataAdapter Dim daTransaksi As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection(Koneksi("Provider=Microsoft.Jet.OLEDB.4.0;Da ta Source=D:\Kuliah\VB\Apotek\dbApotek.mdb")) Dim dtObat As New DataTable() Dim dtPegawai As New DataTable() Dim dttransaksi As New DataTable() Dim drObat As DataRow Dim drPegawai As DataRow Dim drTransaksi 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 daObat = New OleDb.OleDbDataAdapter("select * from Obat", con) daObat.Fill(dtObat) dc(0) = dtObat.Columns("kode_obat") dtObat.PrimaryKey = dc

Isti Novia Lestari | Perancangan Program

12

With lbKodeObat .DataSource = dtObat .DisplayMember = "kode_obat" .ValueMember = "kode_obat" End With daPegawai = New OleDb.OleDbDataAdapter("select * from Pegawai", con) daPegawai.Fill(dtPegawai) dc(0) = dtPegawai.Columns("NIP") dtPegawai.PrimaryKey = dc With cbNIP .DataSource = dtPegawai .DisplayMember = "NIP" .ValueMember = "NIP" End With daTransaksi = New OleDb.OleDbDataAdapter("select * from Antrian", con) daTransaksi.Fill(dttransaksi) dc(0) = dttransaksi.Columns("id_antrian") dttransaksi.PrimaryKey = dc Catch errConn As OleDb.OleDbException MsgBox(errConn.Message) End Try kosong() End Sub Private Sub kosong() txtKodeTrans.Text = "" txtNoAntrian.Text = "" cbNIP.Text = "" lbKodeObat.Text = "" txtNamaObat.Text = "" txtHargaObat.Text = "" txtJumlahObat.Text = "" txtTotal.Text = "" txtPenerimaan.Text = "" lbKembali.Text = "" txtKodeTrans.Focus() End Sub Private Sub btClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btClear.Click kosong() End Sub Private Sub btKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btKeluar.Click Close() End Sub Private Sub lbKodeObat_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

Isti Novia Lestari | Perancangan Program

13

lbKodeObat.SelectedIndexChanged Try Dim drObat As DataRow drObat = dtObat.Rows.Find(lbKodeObat.Text) txtNamaObat.Text = drObat("nama_obat").ToString txtHargaObat.Text = drObat("harga_satuan").ToString Catch errTampil As Exception End Try 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 txtJumlahObat_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtJumlahObat.TextChanged Dim hb, harga, banyak, total, obat, ppn As Integer harga = Val(txtHargaObat.Text) banyak = Val(txtJumlahObat.Text) obat = Val(txtHargaObat.Text) ppn = 0.1 * harga hb = harga + ppn total = hb * banyak txtTotal.Text = total End Sub Private Sub btSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSimpan.Click Try Dim cbTransaksi As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(daTransaksi) drTransaksi = dttransaksi.NewRow drTransaksi("id_antrian") = txtNoAntrian.Text() drTransaksi("kode_obat") = lbKodeObat.Text() drTransaksi("NIP") = cbNIP.Text() drTransaksi("total") = txtTotal.Text() drTransaksi("tgl") = DateTimePicker1.Text() dttransaksi.Rows.Add(drTransaksi) con.Open() daTransaksi.Update(dttransaksi) dttransaksi.AcceptChanges()

Isti Novia Lestari | Perancangan Program

14

con.Close() Catch errTambah As Exception MsgBox(errTambah.Message) End Try kosong() End Sub Private Sub cbNIP_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbNIP.SelectedIndexChanged Try Dim drPegawai As DataRow drPegawai = dtPegawai.Rows.Find(cbNIP.Text) Catch errTampil As Exception End Try End Sub End Class

Isti Novia Lestari | Perancangan Program

15

Report Obat

Report Pegawai

Isti Novia Lestari | Perancangan Program

16

Report Transaksi

3.2

Cara Pengkonekkan ke DataBase Access Caranya mengoneksikann terlebih dahulu database ke Program

Aplikasi Apotek dengan cara :  Tools ± Connect to database

Isti Novia Lestari | Perancangan Program

17

BAB III PENUTUP
4.1. Kesimpulan Aplikasi Apotek ini bisa membantu untuk pekerja apotek yang ingin mengunakan pemrograman dengan mudah dan gampang dimengerti. Kelebihan:   Lebih memudahkan sipengguna untuk mentrasaksikan obat Lebih cepat mengetahui stock obat

Kekurangan:  Mahal untuk membeli suatu program.

Isti Novia Lestari | BAB III

18