Membuat Program Penjualan Visual Basic

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Membuat Program Penjualan Visual Basic as PDF for free.

More details

  • Words: 1,159
  • Pages: 11
TUGAS Program penjualan Buku menggunakan VB dengan database Access

Khodri Rhomadoni 3 Tel 7

A. MEMBUAT DATABASE 1. Membuat TABLE BUKU Table buku digunakan dengan untuk mengisi semua buku yang akan dimasukan. Table Name: TABLE_BUKU Name Kode_buku Judul_buku Jenis_buku Karang_buku Terbit_buku Tahun_buku Harga_buku Stok_buku

Type Text Text Text Text Text Text Currency Single

Size 6 20 10 20 20 4 8 4

Keterangan

Kunci Primary Key

Pengarang buku Penerbit buku Tahun terbit buku

- Setelah semua field selesai ditulis buatlah PRIMARY KEY . 2. Membuat TABLE PELANGGAN Table Name: TABLE_PELANGGAN Name Kode_pelanggan Nama_pelanggan Alamat_pelanggan Telpon_pelanggan

Type Text Text Text Text

Size

Keterangan

Kunci Primary Key

Size

Keterangan

Kunci Primary Key

6 20 10 20

3. Membuat TABLE USER Table Name: TABLE_USER Name Id_user Nama_user Type_user Telpon_user Alamat_user Password_user

Type Text Text Text Text Text Text

4 20 15 15 30 10

4. Membuat TABLE TRANSAKSI Table Name: TABLE_TRANSAKSI

Name No_faktur Tgl_faktur Kode_pelanggan Id_user Biaya_kirim Total_bayar

Type Text Date/Time Text Text Currency Currency

Size 10 8 6 4 8 8

Keterangan Kunci Nomor Faktur Primary Key Tanggal Faktur harus sama dengan Table_pelanggan harus sama dengan Table_user

5. Membuat TABLE DETAIL Table Name: TABLE_DETAIL Name No_faktur

Type Text

10

Kode_buku Jumlah_beli Total_harga

Text Single Currency

6 4 8

Size

Keterangan harus sama dengan Table_transaksi harus sama dengan Table_buku

Kunci Tidak Ada

Size

Keterangan harus sama dengan Table_transaksi harus sama dengan Table_buku

Kunci Tidak Ada

6. Membuat Table Bantu Table Name: TABLE_BANTU Name No_faktur

Type Text

10

Kode_buku Jumlah_beli Total_harga

Text Single Currency

6 4 8

7. Membuat Table Bayar Table Name: TABLE_BAYAR Name No_faktur Uang_bayar Uang_kembali

Type Text Currency Currency

Size 10 8 8

Keterangan Kunci harus sama dengan Table_transaksiTidak Ada

- Akhirnya semua table telah dibuat dan pembuatan database telah selesai dilakukan. - Untuk membuka database yang telah kita buat caranya adalah: pilih ADD-INS – VISUAL DATA MANAGER – FILE – OPEN DATABASE – MICROSOFT ACCESS – cari database buku yang tadi kita buat dan buka.

B. MEMBUAT FORM - 1. Membuat FORM BUKU

NAME Label1 Label2 Label3 Label4 Label5 Label6 Label7 Label8 Label9 Cbojenis Txtkd1 Txtkode Txtjudul Txtkarang Txtterbit Txttahun

CAPTION/TEXT Jenis buku Kode buku Judul buku Pengarang Penerbit Tahun terbit Harga Stok Masukan kode -

KETERANGAN Label Label Label Label Label Label Label Label Label Combo Box Textbox Textbox Textbox Textbox Textbox Textbox

TAMBAHAN

Txtharga Txtstok Txtfind Cmdadd Cmdclear Cmdsave Cmdedit Cmddelete Cmdexit Data1 Dbgrid1 Buku Cmdprint CR

&add &clear &save &edit &delete &exit Data Buku &print -

Textbox Textbox Textbox Command Button Command Button Command Button Command Button Command Button Command Button Data Dbgrid Form Command Button Crystal Report

Data source : data1 Jika punya Crystal Report Jika punya Crystal Report

- Simpan Form Buku yang telah kita buat dengan nama BUKU.frm - Adapun LISTING PROGRAM dari Form buku ini adalah: Private Sub Form_Load() Data1.DatabaseName = App.Path & "/buku.mdb" Data1.RecordSource = "select * from Table_buku order by Kode_buku" Cbojenis.additem “AGAMA” Cbojenis.additem “KOMPUTER” Cbojenis.additem “PENDIDIKAN” Cbojenis.additem “UMUM” Cbojenis.additem “NOVEL” Cbojenis.additem “KOMIK” End Sub Sub aktif() TXTKODE.Enabled = True TXTJUDUL.Enabled = True TXTKARANG.Enabled = True TXTTERBIT.Enabled = True TXTTAHUN.Enabled = True TXTHARGA.Enabled = True TXTSTOK.Enabled = True End Sub Sub nonaktif() TXTJUDUL.Enabled = False TXTKARANG.Enabled = False TXTTERBIT.Enabled = False

TXTTAHUN.Enabled = False TXTHARGA.Enabled = False TXTSTOK.Enabled = False End Sub Private Sub Form_Activate() Call nonaktif TXTKODE.Enabled = False txtkd1.Enabled = False CBOJENIS.Enabled = False CMDCLEAR.Enabled = False CMDSAVE.Enabled = False CMDEDIT.Enabled = False CMDDELETE.Enabled = False End Sub Private Sub CBOJENIS_Click() TXTKODE.Enabled = True TXTKODE.Text = "" TXTKODE.SetFocus If CBOJENIS.Text = "AGAMA" Then txtkd1.Text = "AG" Else If CBOJENIS.Text = "KOMPUTER" Then txtkd1.Text = "KP" Else If CBOJENIS.Text = "PENDIDIKAN" Then txtkd1.Text = "PD" Else If CBOJENIS.Text = "UMUM" Then txtkd1.Text = "UM" Else If CBOJENIS.Text = "NOVEL" Then txtkd1.Text = "NV" Else If CBOJENIS.Text = "KOMIK" Then txtkd1.Text = "KM" End If End If End If End If End If End If End Sub

Private Sub TXTKODE_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then Data1.Recordset.FindFirst "Kode_buku=’" & (txtkd1.Text & TXTKODE.Text) & "’" & "" If Not Data1.Recordset.NoMatch Then MsgBox "Kode sudah ada !", vbOKOnly, "peringatan" Else Call aktif TXTJUDUL.SetFocus End If End If If Not (IsNumeric(Chr(KeyAscii)) Or KeyAscii = vbKeyBack) Then Beep KeyAscii = 0 End If End Sub

Private Sub TXTFIND_Change() Data1.RecordSource = "SELECT*FROM Table_buku WHERE Kode_buku LIKE’*" & TXTFIND.Text & "*’" DBGrid1.Refresh Data1.Refresh CMDEDIT.Enabled = True CMDDELETE.Enabled = True If Data1.Recordset.EOF Then MsgBox "DATA TIDAK ADA !" CMDEDIT.Enabled = False CMDDELETE.Enabled = False End If If TXTFIND.Text = "" Then CMDEDIT.Enabled = False CMDDELETE.Enabled = False End If End Sub

Sub kosong() TXTJUDUL.Text = "" TXTKARANG.Text = "" TXTTERBIT.Text = "" TXTTAHUN.Text = "" TXTHARGA.Text = ""

TXTSTOK.Text = "" End Sub

Private Sub CMDADD_Click() Call kosong CBOJENIS.Enabled = True CMDADD.Enabled = False CMDCLEAR.Enabled = True CMDSAVE.Enabled = True CMDEDIT.Enabled = False CMDDELETE.Enabled = False TXTFIND.Enabled = False End Sub Private Sub CMDCLEAR_Click() txtkd1.Text = "" TXTKODE.Text = "" CBOJENIS.Text = "" TXTKODE.Enabled = False CBOJENIS.Enabled = False txtkd1.Enabled = False Call kosong Call nonaktif TXTFIND.Text = "" CMDADD.Enabled = True CMDSAVE.Enabled = False CMDCLEAR.Enabled = False TXTFIND.Enabled = True End Sub Private Sub CMDSAVE_Click() With Data1.Recordset .AddNew !Kode_buku = (txtkd1.Text & TXTKODE.Text) !Judul_buku = TXTJUDUL.Text !Jenis_buku = CBOJENIS.Text !Karang_buku = TXTKARANG.Text !Terbit_buku = TXTTERBIT.Text !Tahun_buku = TXTTAHUN.Text !Harga_buku = Val(TXTHARGA.Text) !Stok_buku = Val(TXTSTOK.Text) .Update End With Data1.Refresh

DBGrid1.Refresh MsgBox "data telah disimpan" Call nonaktif CMDADD.Enabled = True CMDCLEAR.Enabled = False CMDEDIT.Enabled = False CMDDELETE.Enabled = False TXTFIND.Enabled = True CMDSAVE.Enabled = False Call kosong TXTKODE.Text = "" txtkd1.Text = "" CBOJENIS.Text = "" TXTKODE.Enabled = False CBOJENIS.Enabled = False End Sub

Private Sub CMDEDIT_Click() If CMDEDIT.Caption = "&EDIT" Then Call tampil Call aktif CMDSAVE.Enabled = False CMDCLEAR.Enabled = False CMDADD.Enabled = False CMDDELETE.Enabled = False CMDEDIT.Caption = "&UPDATE" TXTFIND.Enabled = False Else With Data1.Recordset .Edit !Kode_buku = (txtkd1.Text & TXTKODE.Text) !Judul_buku = TXTJUDUL.Text !Jenis_buku = CBOJENIS.Text !Karang_buku = TXTKARANG.Text !Terbit_buku = TXTTERBIT.Text !Tahun_buku = TXTTAHUN.Text !Harga_buku = Val(TXTHARGA.Text) !Stok_buku = Val(TXTSTOK.Text) .Update End With Call kosong CMDEDIT.Caption = "&EDIT" CMDADD.Enabled = True CMDEDIT.Enabled = False

Call nonaktif TXTFIND.Text = "" TXTKODE.Text = "" txtkd1.Text = "" CBOJENIS.Text = "" TXTFIND.Enabled = True End If Sub tampil() On Error Resume Next With Data1.Recordset CBOJENIS.Text = !Jenis_buku txtkd1.Text = Left(!Kode_buku, 2) TXTKODE.Text = Right(!Kode_buku, 4) TXTJUDUL.Text = !Judul_buku TXTKARANG.Text = !Karang_buku TXTTERBIT.Text = !Terbit_buku TXTTAHUN.Text = !Tahun_buku TXTHARGA.Text = !Harga_buku TXTSTOK.Text = !Stok_buku End With End Sub Private Sub CMDDELETE_Click() CMDADD.Enabled = False CMDCLEAR.Enabled = False CMDEDIT.Enabled = False a = MsgBox("YAKIN ANDA MAU MENGAHAPUS DATA INI ?", vbQuestion + vbYesNo, "KONFIRMASI") If a = vbYes Then Data1.Recordset.Delete TXTKODE.Text = "" txtkd1.Text = "" CBOJENIS.Text = "" Call kosong MsgBox "DATA TELAH BERHASIL DIHAPUS", vbOKOnly, "INFO" TXTFIND.Text = "" TXTFIND.Enabled = True Data1.Refresh DBGrid1.Refresh CMDADD.Enabled = True Else CMDDELETE.Enabled = False CMDADD.Enabled = True TXTFIND.Text = "" TXTFIND.Enabled = True

End If End Sub Private Sub CMDEXIT_Click() Unload Me End Sub Private Sub CMDPRINT_Click() ‘CR.ReportFileName = App.Path & "\BUKU.rpt" ‘CR.WindowState = crptMaximized ‘CR.RetrieveDataFiles ‘CR.Action = 1

Related Documents