Selasa, 23 November 2010

PROGRAM PENJUALAN dengan Visual basic 6.0







Langkah awal buat database dengan Microsoft Office Access 2003 atau 2007  dengan nama  database “PENJUALAN” dan buat tabel dengan nama “PENJUALAN” SAVE dengan format (mdb)






Program ini membutuhkan objek tambahan yaitu :
1. Microsoft Ado Data Control 6.0 (OLEDB)
2. Microsoft DataGrid Control 6.0 (OLEDB
3. Microsoft  Tabbed  Dialog Control 6.0


Tambahkan objek diatas dengan memilih menu Project, Component, dan tandai objek-objek diatas serta, akhiri dengan tekan OK.





Coding :
Option Explicit

Private koneksi As ADODB.Connection
Dim rspenjualan    As New ADODB.Recordset
Private Function konek() As Boolean
    On Error GoTo out
        Set koneksi = New ADODB.Connection
        koneksi.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\PENJUALAN.mdb;Persist Security Info=False"
        koneksi.CursorLocation = adUseClient
        konek = True
out:
End Function
Sub proses()
TxtTotal.Text = Val(TxtHarga.Text) * Val(TxtJumlah.Text)
    List1.AddItem "Kode Barang = " & TxtKode.Text
   List1.AddItem "Nama Barang = " & TxtNama.Text
   List1.AddItem "Harga Barang = " & TxtHarga.Text & "  X  Jumlah Barang  " & TxtJumlah.Text
    List1.AddItem "Total Harga = " & TxtTotal.Text
   List1.AddItem "========================================================================="
End Sub

Private Sub CmdBaru_Click()
TxtKode.Text = ""
TxtNama.Text = ""
TxtHarga.Text = ""
TxtJumlah.Text = ""
TxtBayar.Text = ""
TxtTotal.Text = ""
End Sub

Private Sub CmdCari_Click()
 If Adodc1.Recordset.RecordCount <= 0 Then Exit Sub
    
     Adodc1.Recordset.MoveFirst
     Adodc1.Recordset.Find "KODE='" & TxtCari.Text & "'"

End Sub

Private Sub CmdExit_Click()
Unload Me
End Sub
Private Sub CmdProses_Click()
proses
End Sub

Private Sub CmdSimpan_Click()
With Adodc1.Recordset
.AddNew
.Fields("KODE") = TxtKode.Text
.Fields("NAMA") = TxtNama.Text
.Fields("HARGA") = TxtHarga.Text
.Fields("JUMLAH") = TxtJumlah.Text
.Fields("TOTAL") = TxtTotal.Text
.Update
End With
Call CmdBaru_Click
End Sub

Private Sub Form_Activate()
TxtKode.SetFocus
End Sub

Private Sub Form_Load()
If Not konek() Then
        MsgBox "Gak bisa terhubung ke database!", vbCritical
        End
    End If
    Set rspenjualan = New ADODB.Recordset
    rspenjualan.Open "PENJUALAN", koneksi, adOpenKeyset, adLockOptimistic
    Adodc1.ConnectionString = koneksi.ConnectionString
    Adodc1.RecordSource = "PENJUALAN"
    Set DataGrid1.DataSource = Adodc1
End Sub

Private Sub TxtBayar_Change()
TxtKembali.Text = Val(TxtBayar.Text) - Val(TxtTotal.Text)
End Sub

Private Sub TxtHarga_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtJumlah.SetFocus
End If
End Sub

Private Sub TxtJumlah_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtBayar.SetFocus
End If
proses
End Sub
Private Sub TxtKode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtNama.SetFocus
End If
End Sub

Private Sub TxtNama_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
TxtHarga.SetFocus
End If
End Sub
 




PENJUALAN PRG.rar


MEMBUAT PROGRAM PENJUALAN SEDERHANA.ppsx

6 komentar:

  1. Dikembangkan Lagi karya-karya nya biar jadi ilmu juga bagi yang Lain Om.

    BalasHapus
  2. gan yg on error goto outnya ko label not defined, itu kenapa ya?

    BalasHapus
  3. Gmn cra u/memanggil menu.statusbar1.panels() diform menu ke form penjualan ya(lain form). Tq advice nya🙏

    BalasHapus