+ All Categories
Home > Documents > Source Code Toko Kelontong

Source Code Toko Kelontong

Date post: 07-Apr-2018
Category:
Upload: fahmi-ahmad-burhan
View: 247 times
Download: 1 times
Share this document with a friend
57
Source Code modul koneksi : Global conn As ADODB.Connection Global rsBarang As ADODB.Recordset Global rsPembelian As ADODB.Recordset Global rsPenjualan As ADODB.Recordset Global rsPenjualan2 As ADODB.Recordset Global rsReturBeli As ADODB.Recordset Global rsLogin As ADODB.Recordset Global rsSupplier As ADODB.Recordset Global rsHutang As ADODB.Recordset  'sekarang fungsi untuk koneksi ke database  Sub koneksi() Set conn = New ADODB.Connection conn.Provider = "microsoft.jet.oledb.4.0" conn.CursorLocation = adUseClient conn.Open App.Path & "\T okoDB.mdb" End Sub  Source Code modul log_file : Sub saveLaporan(pesan As String, namafile As String) Open App.Path & "\LAPORAN\" & namafile & ".txt" For Append As #1 Print #1, pesan Close #1 End Sub  Sub saveMemo2(pesan As String) Open App.Path & "\FileHash.txt" For Append As #1 Print #1, pesan Close #1 End Sub  Source Code MDIForm1 : Private Sub AddBeli_Click() frmBeli.Show End Sub  Private Sub AddBrg_Click() frmAddBrg.Show End Sub
Transcript
Page 1: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 1/57

Source Code modul koneksi :

Global conn As ADODB.Connection

Global rsBarang As ADODB.Recordset

Global rsPembelian As ADODB.Recordset

Global rsPenjualan As ADODB.Recordset

Global rsPenjualan2 As ADODB.Recordset

Global rsReturBeli As ADODB.Recordset

Global rsLogin As ADODB.Recordset

Global rsSupplier As ADODB.Recordset

Global rsHutang As ADODB.Recordset

 

'sekarang fungsi untuk koneksi ke database

 

Sub koneksi()

Set conn = New ADODB.Connection

conn.Provider = "microsoft.jet.oledb.4.0"

conn.CursorLocation = adUseClient

conn.Open App.Path & "\TokoDB.mdb"

End Sub

 

Source Code modul log_file :

Sub saveLaporan(pesan As String, namafile As String)

Open App.Path & "\LAPORAN\" & namafile & ".txt" For Append As #1

Print #1, pesan

Close #1

End Sub

 

Sub saveMemo2(pesan As String)

Open App.Path & "\FileHash.txt" For Append As #1

Print #1, pesan

Close #1

End Sub

 

Source Code MDIForm1 :

Private Sub AddBeli_Click()

frmBeli.Show

End Sub

 

Private Sub AddBrg_Click()

frmAddBrg.Show

End Sub

Page 2: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 2/57

 

Private Sub AddJual_Click()

frmJual.Show

End Sub

 

Private Sub AddSupplier_Click()

frmAddSupplier.Show

End Sub

 

Private Sub ByrHtg_Click()

frmByrUtang.Show

End Sub

 

Private Sub DelBrg_Click()

frmDelBrg.Show

End Sub

 

Private Sub DelSupplier_Click()

frmDelSupplier.Show

End Sub

 

Private Sub EditBrg_Click()

frmEditBrg.Show

End Sub

 

Private Sub EditSupplier_Click()

frmEditSupplier.Show

End Sub

 

Private Sub fileExit_Click()

End

End Sub

 

Private Sub fileLogin_Click()

frmDataLogin.Show

End Sub

 

Private Sub mnuLapBeli_Click()

frmLapBeli.Show

End Sub

 

Page 3: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 3/57

Private Sub mnuLapByrHutang_Click()

frmLapByrUtang.Show

End Sub

 

Private Sub mnuLapJual_Click()

frmLapJual.Show

End Sub

 

Private Sub mnuLapKeu_Click()

frmLapKeu.Show

End Sub

 

Private Sub mnuLapReturBeli_Click()

frmLapReturBeli.Show

End Sub

 

Private Sub ReturBeli_Click()

frmReturBeli.Show

End Sub

 

Source Code form Login :

Private Sub cmdBatal_Click()

End

End Sub

 

Private Sub cmdOK_Click()

 

If txtUsername.Text <> "" And txtPassword.Text <> "" Then

 

Set rsLogin = New ADODB.Recordset

rsLogin.LockType = adLockOptimistic

rsLogin.CursorType = adOpenDynamic

rsLogin.Open "SELECT * FROM data_login WHERE username = '" & txtUsername.Text & "' AND password = '"& txtPassword.Text & "'", conn, , , adCmdText

 

If Not rsLogin.EOF Then

If rsLogin!posisi = "Administrator" Then

'load menu utk admin

MDIForm1.fileLogin.Enabled = True

MDIForm1.mnuBarang.Enabled = True

MDIForm1.mnuSupplier.Enabled = True

Page 4: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 4/57

MDIForm1.mnuTransaksi.Enabled = True

MDIForm1.mnuLaporan.Enabled = True

MDIForm1.Show

Unload Me

Else

'load menu utk operator

MDIForm1.fileLogin.Enabled = False

MDIForm1.mnuBarang.Enabled = False

MDIForm1.mnuSupplier.Enabled = False

MDIForm1.mnuTransaksi.Enabled = True

MDIForm1.mnuLaporan.Enabled = False

MDIForm1.Show

Unload Me

End If 

 

Else

MsgBox "Username dan Password Salah", vbCritical

Exit Sub

End If 

 

End If 

End Sub

 

Private Sub Form_Load()

koneksi

End Sub

 

Source Code utk form DataLogin :

Public dataIndex As Integer

Public tmpUser As String

Public tmpPass As String

 

Private Sub cmdDelete_Click()

Dim tanya

tmpUser = txtUsername.Text

tmpPass = txtPassword.Text

 

tanya = MsgBox("Hapus Data Pengguna ?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

Page 5: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 5/57

Do Until rsLogin.EOF

If rsLogin!UserName = tmpUser And rsLogin!Password = tmpPass Then

With rsLogin

.Delete

.UpdateBatch

End With

 

MsgBox "Data Terhapus", vbInformation

kondisiNormal

 

Exit Do

End If 

rsLogin.MoveNext

 

Loop

 

Else

kondisiNormal

End If 

 

End Sub

 

Private Sub cmdEdit_Click()

cmdNew.Enabled = False

cmdDelete.Enabled = False

Select Case cmdEdit.Caption

Case "Ubah":

cmdEdit.Caption = "Simpan"

cmbPosisi.Locked = False

txtUsername.Locked = False

txtPassword.Locked = False

txtPassword2.Locked = False

txtUsername.SetFocus

tmpUser = txtUsername.Text

tmpPass = txtPassword.Text

 

Case "Simpan":

cmdEdit.Caption = "Ubah"

rsLogin.MoveFirst

Do Until rsLogin.EOF

Page 6: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 6/57

If rsLogin!UserName = tmpUser And rsLogin!Password = tmpPass Then

With rsLogin

!UserName = txtUsername.Text

!Password = txtPassword.Text

!posisi = cmbPosisi.Text

.Update

End With

 

MsgBox "Data Tersimpan", vbInformation

kondisiNormal

 

Exit Do

End If 

rsLogin.MoveNext

 

Loop

 

End Select

End Sub

 

Private Sub cmdFirst_Click()

If Not rsLogin.EOF Then

rsLogin.MoveFirst

txtUsername.Text = rsLogin!UserName

txtPassword.Text = rsLogin!Password

cmbPosisi.Text = rsLogin!posisi

dataIndex = 0

End If 

End Sub

 

Private Sub cmdLast_Click()

If Not rsLogin.EOF Then

rsLogin.MoveLast

txtUsername.Text = rsLogin!UserName

txtPassword.Text = rsLogin!Password

cmbPosisi.Text = rsLogin!posisi

dataIndex = rsLogin.RecordCount - 1

End If 

End Sub

Page 7: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 7/57

 

Private Sub cmdNew_Click()

 

Dim statuspass As Boolean

 

cmdEdit.Enabled = False

cmdDelete.Enabled = False

 

statuspass = False

 

Select Case cmdNew.Caption

Case "Baru":

cmbPosisi.ListIndex = 0

txtUsername.Text = ""

txtPassword.Text = ""

txtPassword2.Text = ""

cmbPosisi.Locked = False

txtUsername.Locked = False

txtPassword.Locked = False

 

txtPassword2.Locked = False

txtUsername.SetFocus

 

cmdNew.Caption = "Simpan"

 

Case "Simpan":

If txtPassword.Text <> txtPassword2.Text Then

MsgBox "Penulisan kembali Password Salah", vbInformation

txtPassword.SetFocus

Else

'cek apa us dan psw udah kedftr

rsLogin.MoveFirst

Do Until rsLogin.EOF

If rsLogin!UserName = txtUsername.Text And rsLogin!Password = txtPassword.Text Then

statuspass = True

Else

statuspass = False

End If 

 

rsLogin.MoveNext

Loop

Page 8: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 8/57

 

If statuspass = False Then

With rsLogin

.AddNew

!UserName = txtUsername.Text

!Password = txtPassword.Text

!posisi = cmbPosisi.Text

.Update

End With

 

MsgBox "Data Tersimpan", vbInformation

kondisiNormal

 

Else

MsgBox "Data dengan Username dan Password tersebut sudah ada", vbInformation

kondisiNormal

End If 

End If 

End Select

End Sub

 

Private Sub cmdNext_Click()

On Error GoTo pesan

If Not rsLogin.EOF And dataIndex < rsLogin.RecordCount - 1 Then

rsLogin.MoveNext

txtUsername.Text = rsLogin!UserName

txtPassword.Text = rsLogin!Password

cmbPosisi.Text = rsLogin!posisi

dataIndex = dataIndex + 1

End If 

 

Exit Sub

 

pesan: cmdLast_Click

End Sub

 

Private Sub cmdPrev_Click()

On Error GoTo pesan

If Not rsLogin.EOF And dataIndex > 0 Then

rsLogin.MovePrevious

txtUsername.Text = rsLogin!UserName

Page 9: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 9/57

txtPassword.Text = rsLogin!Password

cmbPosisi.Text = rsLogin!posisi

dataIndex = dataIndex - 1

End If 

 

Exit Sub

 

pesan: cmdFirst_Click

End Sub

 

Private Sub Form_Load()

koneksi

kondisiNormal

End Sub

 

Sub refreshData()

Set rsLogin = New ADODB.Recordset

rsLogin.LockType = adLockOptimistic

rsLogin.CursorType = adOpenDynamic

rsLogin.Open "SELECT * FROM data_login", conn, , , adCmdText

 

End Sub

Sub kondisiNormal()

cmbPosisi.ListIndex = 0

txtUsername.Text = ""

txtPassword.Text = ""

txtPassword2.Text = ""

 

cmbPosisi.Locked = True

txtUsername.Locked = True

txtPassword.Locked = True

txtPassword2.Locked = True

 

cmdNew.Enabled = True

cmdEdit.Enabled = True

cmdDelete.Enabled = True

 

refreshData

End Sub

 

Page 10: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 10/57

Source Code utk Form AddBrg :

Sub refreshDG()

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang", conn, , , adCmdText

 

Set DGBarang.DataSource = rsBarang

 

End Sub

 

Sub clearTxt()

txtKodeBarang.Text = ""

txtNamaBarang.Text = ""

txtMerkBarang.Text = ""

txtHargaBeli.Text = ""

txtHargaJual.Text = ""

txtBatasStok.Text = ""

 

txtKodeBarang.SetFocus

End Sub

 

Private Sub cmdSave_Click()

On Error GoTo pesan

 

Dim tanya

 

tanya = MsgBox("Apakah Data Barang Telah Diisi Lengkap?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

 

'cek apakah kode sudah terdaftar

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimisticrsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & txtKodeBarang.Text & "'", conn, , ,adCmdText

 

If rsBarang.EOF Then

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

Page 11: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 11/57

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang", conn, , , adCmdText

 

With rsBarang

.AddNew

!kodebarang = txtKodeBarang.Text

!namabarang = txtNamaBarang.Text

!merkbarang = txtMerkBarang.Text

!hargabeli = Val(txtHargaBeli.Text)

!hargajual = Val(txtHargaJual.Text)

!limitstok = Val(txtBatasStok.Text)

.Update

End With

MsgBox "Data Barang Tersimpan", vbInformation

refreshDG

clearTxt

Else

MsgBox "Barang dengan kode " & txtKodeBarang.Text & " telah terdaftar." & vbCrLf & _

"Mohon Ganti Kode Barang...", vbInformation

txtKodeBarang.SetFocus

Exit Sub

End If 

 

Else

clearTxt

Exit Sub

End If 

Exit Sub

 

pesan: MsgBox "Pengisian Data Belum Lengkap", vbInformation

clearTxt

Exit Sub

 

End Sub

 

Private Sub Form_Load()

koneksi

refreshDG

End Sub

 

Page 12: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 12/57

Private Sub txtBatasStok_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Private Sub txtHargaBeli_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Private Sub txtHargaJual_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source Code utk form EditBrg :

Public tmpKodeBarang As String

Sub clearTxt()

txtKodeBarang.Text = ""

txtNamaBarang.Text = ""

txtMerkBarang.Text = ""

txtHargaBeli.Text = ""

txtHargaJual.Text = ""

txtBatasStok.Text = ""

txtCari.Text = ""

End Sub

Sub kondisiNormal()

cmbKriteria.ListIndex = 0

tmpKodeBarang = ""

clearTxt

refreshDGEnd Sub

 

Sub refreshDG()

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang", conn, , , adCmdText

Page 13: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 13/57

 

Set DGBarang.DataSource = rsBarang

 

End Sub

 

Private Sub cmbKriteria_KeyPress(KeyAscii As Integer)

KeyAscii = 0

End Sub

 

Private Sub cmdSave_Click()

On Error GoTo pesan

 

Dim tanya

 

tanya = MsgBox("Apakah Data Barang Telah Diisi Lengkap?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

 

'cek apakah kode ubahan sudah terdaftar (jika kode diubah)

If txtKodeBarang.Text <> tmpKodeBarang Then

 

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & txtKodeBarang.Text & "'", conn, , ,adCmdText

 

If rsBarang.EOF Then

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & tmpKodeBarang & "'", conn, , ,adCmdText

 

With rsBarang

!kodebarang = txtKodeBarang.Text

!namabarang = txtNamaBarang.Text

!merkbarang = txtMerkBarang.Text

!hargabeli = Val(txtHargaBeli.Text)

!hargajual = Val(txtHargaJual.Text)

!limitstok = Val(txtBatasStok.Text)

.Update

Page 14: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 14/57

End With

MsgBox "Data Barang Tersimpan", vbInformation

kondisiNormal

txtCari.SetFocus

Else

MsgBox "Barang dengan kode " & txtKodeBarang.Text & " telah terdaftar." & vbCrLf & _

"Mohon Ganti Kode Barang...", vbInformation

txtKodeBarang.SetFocus

Exit Sub

End If 

Else 'jika kode barang tidak diubah

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & tmpKodeBarang & "'", conn, , ,

adCmdText 

With rsBarang

!kodebarang = txtKodeBarang.Text

!namabarang = txtNamaBarang.Text

!merkbarang = txtMerkBarang.Text

!hargabeli = Val(txtHargaBeli.Text)

!hargajual = Val(txtHargaJual.Text)

!limitstok = Val(txtBatasStok.Text)

.Update

End With

MsgBox "Data Barang Tersimpan", vbInformation

kondisiNormal

txtCari.SetFocus

End If 

Else

kondisiNormal

Exit Sub

End If 

 

Exit Sub

 

pesan: MsgBox "Pengisian Data Belum Lengkap", vbInformation

kondisiNormal

txtCari.SetFocus

Exit Sub

Page 15: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 15/57

End Sub

 

Private Sub DGbarang_DblClick()

On Error GoTo pesan

tmpKodeBarang = DGBarang.Columns(0).Text

txtKodeBarang.Text = DGBarang.Columns(0).Text

txtNamaBarang.Text = DGBarang.Columns(1).Text

txtMerkBarang.Text = DGBarang.Columns(2).Text

txtHargaBeli.Text = DGBarang.Columns(3).Text

txtHargaJual.Text = DGBarang.Columns(4).Text

txtBatasStok.Text = DGBarang.Columns(6).Text

Exit Sub

 

pesan:

kondisiNormal

Exit Sub

End Sub

 

Private Sub Form_Load()

koneksi

kondisiNormal

End Sub

 

Private Sub txtCari_Change()

Dim kriteria As String

kriteria = ""

Select Case cmbKriteria.Text

Case "Kode Barang": kriteria = "kodebarang"

Case "Nama Barang": kriteria = "namabarang"

End Select

 

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE " & kriteria & " like '" & txtCari.Text & "%'", conn, , ,adCmdText

 

Set DGBarang.DataSource = rsBarang

 

End Sub

 

Page 16: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 16/57

Private Sub txtBatasStok_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Private Sub txtHargaBeli_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Private Sub txtHargaJual_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source Code utk form DelBrg :

Public tmpKodeBarang As String

Sub clearTxt()

txtKodeBarang.Text = ""

txtNamaBarang.Text = ""

txtMerkBarang.Text = ""

txtHargaBeli.Text = ""

txtHargaJual.Text = ""

txtBatasStok.Text = ""

txtCari.Text = ""

End Sub

Sub kondisiNormal()

cmbKriteria.ListIndex = 0

tmpKodeBarang = ""

clearTxtrefreshDG

End Sub

 

Sub refreshDG()

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

Page 17: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 17/57

rsBarang.Open "SELECT * FROM data_barang", conn, , , adCmdText

 

Set DGBarang.DataSource = rsBarang

 

End Sub

 

Private Sub cmbKriteria_KeyPress(KeyAscii As Integer)

KeyAscii = 0

End Sub

 

Private Sub cmdHapus_Click()

Dim tanya

 

tanya = MsgBox("Hapus Barang dengan Kode " & tmpKodeBarang & " ?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & tmpKodeBarang & "'", conn, , ,adCmdText

 

rsBarang.Delete

rsBarang.UpdateBatch

 

kondisiNormal

txtCari.SetFocus

Else

kondisiNormal

txtCari.SetFocus

Exit Sub

End If 

End Sub

 

Private Sub DGbarang_DblClick()

On Error GoTo pesan

tmpKodeBarang = DGBarang.Columns(0).Text

txtKodeBarang.Text = DGBarang.Columns(0).Text

txtNamaBarang.Text = DGBarang.Columns(1).Text

txtMerkBarang.Text = DGBarang.Columns(2).Text

txtHargaBeli.Text = DGBarang.Columns(3).Text

Page 18: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 18/57

txtHargaJual.Text = DGBarang.Columns(4).Text

txtBatasStok.Text = DGBarang.Columns(6).Text

Exit Sub

 

pesan:

kondisiNormal

Exit Sub

End Sub

 

Private Sub Form_Load()

koneksi

kondisiNormal

End Sub

 

Private Sub txtCari_Change()

Dim kriteria As String

kriteria = ""

Select Case cmbKriteria.Text

Case "Kode Barang": kriteria = "kodebarang"

Case "Nama Barang": kriteria = "namabarang"

End Select

 

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE " & kriteria & " like '" & txtCari.Text & "%'", conn, , ,adCmdText

 

Set DGBarang.DataSource = rsBarang

 

End Sub

 

Private Sub txtBatasStok_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Private Sub txtHargaBeli_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

Page 19: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 19/57

End If 

End Sub

 

Private Sub txtHargaJual_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source Code utk AddSupplier :

Sub refreshDG()

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

Set DGSupplier.DataSource = rsSupplier

 

End Sub

 

Sub clearTxt()

txtNama.Text = ""

txtAlamat.Text = ""

txtTelpon.Text = ""

 

txtNama.SetFocus

End Sub

 

Private Sub cmdSave_Click()

On Error GoTo pesan

 

Dim tanya

 

tanya = MsgBox("Apakah Data Supplier Telah Diisi Lengkap?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

 

'cek apakah nama supplier sudah terdaftar

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

Page 20: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 20/57

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & txtNama.Text & "'", conn, , , adCmdText

 

If rsSupplier.EOF Then

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

With rsSupplier

.AddNew

!nama = txtNama.Text

!alamat = txtAlamat.Text

!telepon = txtTelpon.Text

.Update

End With

MsgBox "Data supplier Tersimpan", vbInformation

refreshDG

clearTxt

Else

MsgBox "Supplier dengan nama " & txtNama.Text & " telah terdaftar." & vbCrLf & _

"Mohon Ganti nama supplier...", vbInformation

txtNama.SetFocus

Exit Sub

End If 

 

Else

clearTxt

Exit Sub

End If 

 

Exit Sub

 

pesan: MsgBox "Pengisian Data Belum Lengkap", vbInformation

clearTxt

Exit Sub

 

End Sub

 

Private Sub Form_Load()

koneksi

refreshDG

Page 21: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 21/57

End Sub

 

Private Sub txtTelpon_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source Code utk EditSupplier :

Public tmpNama As String

Sub clearTxt()

txtNama.Text = ""

txtAlamat.Text = ""

txtTelpon.Text = ""

txtCari.Text = ""

End Sub

Sub kondisiNormal()

tmpNama = ""

clearTxt

refreshDG

End Sub

 

Sub refreshDG()

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

Set DGSupplier.DataSource = rsSupplier

 

End Sub

 

Private Sub cmbKriteria_KeyPress(KeyAscii As Integer)

KeyAscii = 0

End Sub

 

Private Sub cmdSave_Click()

'On Error GoTo pesan

 

Dim tanya

 

Page 22: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 22/57

tanya = MsgBox("Apakah Data Supplier Telah Diisi Lengkap?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

 

'cek apakah nama ubahan sudah terdaftar (jika nama diubah)

If txtNama.Text <> tmpNama Then

 

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & txtNama.Text & "'", conn, , , adCmdText

 

If rsSupplier.EOF Then

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & tmpNama & "'", conn, , , adCmdText

 

With rsSupplier

!nama = txtNama.Text

!alamat = txtAlamat.Text

!telepon = txtTelpon.Text

.Update

End With

MsgBox "Data Supplier Tersimpan", vbInformation

kondisiNormal

txtCari.SetFocus

Else

MsgBox "Supplier dengan nama " & txtNama.Text & " telah terdaftar." & vbCrLf & _

"Mohon Ganti Nama Supplier...", vbInformation

txtNama.SetFocus

Exit Sub

End If 

Else 'jika kode supplier tidak diubah

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & tmpNama & "'", conn, , , adCmdText

 

With rsSupplier

!nama = txtNama.Text

Page 23: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 23/57

!alamat = txtAlamat.Text

!telepon = txtTelpon.Text

.Update

End With

MsgBox "Data Supplier Tersimpan", vbInformation

kondisiNormal

txtCari.SetFocus

End If 

Else

kondisiNormal

Exit Sub

End If 

 

Exit Sub

 

pesan: MsgBox "Pengisian Data Belum Lengkap", vbInformation

kondisiNormal

txtCari.SetFocus

Exit Sub

End Sub

 

Private Sub DGsupplier_DblClick()

On Error GoTo pesan

tmpNama = DGSupplier.Columns(0).Text

txtNama.Text = DGSupplier.Columns(0).Text

txtAlamat.Text = DGSupplier.Columns(1).Text

txtTelpon.Text = DGSupplier.Columns(2).Text

Exit Sub

 

pesan:

kondisiNormal

Exit Sub

End Sub

 

Private Sub Form_Load()

koneksi

kondisiNormal

End Sub

 

Private Sub txtCari_Change()

Set rsSupplier = New ADODB.Recordset

Page 24: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 24/57

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama like '" & txtCari.Text & "%'", conn, , ,adCmdText

 

Set DGSupplier.DataSource = rsSupplier

 

End Sub

 

Private Sub txtTelpon_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source Code utk DelSupplier :

Public tmpNama As String

 

Sub clearTxt()

txtNama.Text = ""

txtAlamat.Text = ""

txtTelpon.Text = ""

txtCari.Text = ""

End Sub

Sub kondisiNormal()

tmpNama = ""

clearTxt

refreshDG

End Sub

 

Sub refreshDG()

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

Set DGSupplier.DataSource = rsSupplier

 

End Sub

 

Page 25: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 25/57

Private Sub cmdHapus_Click()

Dim tanya

 

tanya = MsgBox("Hapus Supplier dengan nama " & tmpNama & " ?", vbQuestion + vbYesNo)

 

If tanya = vbYes And txtNama.Text <> "" Then

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & tmpNama & "'", conn, , , adCmdText

 

rsSupplier.Delete

rsSupplier.UpdateBatch

 

kondisiNormal

txtCari.SetFocus

Else

kondisiNormal

txtCari.SetFocus

Exit Sub

End If 

End Sub

 

Private Sub cmdSave_Click()

 

End Sub

 

Private Sub DGsupplier_DblClick()

On Error GoTo pesan

tmpNama = DGSupplier.Columns(0).Text

txtNama.Text = DGSupplier.Columns(0).Text

txtAlamat.Text = DGSupplier.Columns(1).Text

txtTelpon.Text = DGSupplier.Columns(2).Text

Exit Sub

 

pesan:

kondisiNormal

Exit Sub

End Sub

 

Private Sub Form_Load()

Page 26: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 26/57

koneksi

kondisiNormal

End Sub

 

Private Sub txtCari_Change()

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama like '" & txtCari.Text & "%'", conn, , ,adCmdText

 

Set DGSupplier.DataSource = rsSupplier

 

End Sub

 

Private Sub txtTelpon_KeyPress(KeyAscii As Integer)If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source code utk form Beli :

 

Sub kondisiNormal()

refreshDG

 

tglBeli.Value = Date

txtFaktur.Text = ""

 

txtKodeBarang.Text = ""

txtMerkBarang.Text = ""

txtNamaBarang.Text = ""

txtHargaBeli.Text = ""

 loadBarang

loadSupplier

 

txtJmlBeli.Text = ""

txtTotal.Text = ""

txtBayar.Text = ""

txtKembali.Text = ""

Page 27: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 27/57

txtHutang.Text = ""

 

txtFaktur.SetFocus

End Sub

 

Sub loadBarang()

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE stok <= limitstok ", conn, , , adCmdText

 

If Not rsBarang.EOF Then

Set DGBarang.DataSource = rsBarang

Else

'cek apakah data barang kosong

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang", conn, , , adCmdText

 

If rsBarang.EOF Then

frmAddBrg.Show

Unload Me

Else

MsgBox "Belum Ada Barang yang Perlu Dibeli", vbInformation

End If 

End If 

End Sub

 

Sub loadSupplier()

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

If Not rsSupplier.EOF Then

cmbSupplier.Clear

rsSupplier.MoveFirst

Do Until rsSupplier.EOF

cmbSupplier.AddItem rsSupplier!nama

Page 28: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 28/57

Page 29: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 29/57

If txtHutang.Text = "" Then

'UPDATE STOK BARANG

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & txtKodeBarang.Text & "'",

conn, , , adCmdText

 

With rsBarang

!stok = Val(rsBarang!stok) + Val(txtJmlBeli.Text)

.Update

End With

 

'SIMPAN DATA PEMBELIAN

Set rsPembelian = New ADODB.Recordset

rsPembelian.LockType = adLockOptimisticrsPembelian.CursorType = adOpenDynamic

rsPembelian.Open "SELECT * FROM data_pembelian", conn, , , adCmdText

 

With rsPembelian

.AddNew

!kodefaktur = txtFaktur.Text

!tanggalbeli = tglBeli.Value

!namasupplier = cmbSupplier.Text

!kodebarang = txtKodeBarang.Text

!merkbarang = txtMerkBarang.Text

!namabarang = txtNamaBarang.Text

!jumlahbeli = txtJmlBeli.Text

!total = txtTotal.Text

.Update

End With

 

kondisiNormal

 

MsgBox "Data Pembelian Tersimpan", vbInformation

 

Else

'UPDATE HUTANG SUPPLIER

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

Page 30: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 30/57

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & cmbSupplier.Text & "'", conn, , ,adCmdText

 

rsSupplier!Hutang = rsSupplier!Hutang + Val(txtHutang.Text)

rsSupplier.Update

 

'UPDATE STOK BARANG

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE kodebarang = '" & txtKodeBarang.Text & "'",conn, , , adCmdText

 

With rsBarang

!stok = Val(rsBarang!stok) + Val(txtJmlBeli.Text)

.Update

End With

 

'SIMPAN DATA PEMBELIAN

Set rsPembelian = New ADODB.Recordset

rsPembelian.LockType = adLockOptimistic

rsPembelian.CursorType = adOpenDynamic

rsPembelian.Open "SELECT * FROM data_pembelian", conn, , , adCmdText

 

With rsPembelian

.AddNew

!kodefaktur = txtFaktur.Text

!tanggalbeli = tglBeli.Value

!namasupplier = cmbSupplier.Text

!kodebarang = txtKodeBarang.Text

!merkbarang = txtMerkBarang.Text

!namabarang = txtNamaBarang.Text

!jumlahbeli = txtJmlBeli.Text

!total = txtTotal.Text

.Update

End With

 

kondisiNormal

 

MsgBox "Data Pembelian Tersimpan", vbInformation

End If 

Page 31: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 31/57

Else

Exit Sub

End If 

 

Exit Sub

 

pesan:

MsgBox "Pengisian Data Belum Lengkap", vbInformation

kondisiNormal

End Sub

 

Private Sub DGbarang_DblClick()

txtKodeBarang.Text = DGBarang.Columns(0).Text

txtNamaBarang.Text = DGBarang.Columns(1).Text

txtMerkBarang.Text = DGBarang.Columns(2).Text

txtHargaBeli.Text = DGBarang.Columns(3).Text

End Sub

 

Private Sub Form_Load()

koneksi

'kondisiNormal

refreshDG

loadBarang

loadSupplier

End Sub

 

Private Sub txtBayar_Change()

If Val(txtBayar.Text) >= Val(txtTotal.Text) Then

txtKembali.Text = Val(txtBayar.Text) - Val(txtTotal.Text)

txtHutang.Text = ""

Else

txtHutang.Text = Val(txtTotal.Text) - Val(txtBayar.Text)

txtKembali.Text = ""

End If 

End Sub

 

Private Sub txtBayar_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

Page 32: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 32/57

 

End Sub

 

Private Sub txtJmlBeli_Change()

txtTotal.Text = Val(txtHargaBeli.Text) * Val(txtJmlBeli.Text)

End Sub

 

Private Sub txtJmlBeli_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

 

End Sub

 

Source Code utk Form Jual :

Public tmpKode As String

 

Sub loadBarang()

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang WHERE stok > 0", conn, , , adCmdText

 

Set DGBarang.DataSource = rsBarang

 

End Sub

 

Sub kondisiNormal()

loadBarang

tglJual.Value = Date

tmpKode = ""

txtKodeFaktur.Text = ""

txtKodeBarang.Text = ""

txtNamaBarang.Text = ""

txtMerkBarang.Text = ""

txthargasatuan.Text = ""

txtJmlBeli.Text = ""

txtDiskon.Text = ""

txtTotal.Text = ""

txtBayar.Text = ""

txtKembali.Text = ""

Page 33: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 33/57

End Sub

 

Sub refreshDGSementara()

Dim subtotal As Double

 

subtotal = 0

 

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan_sementara", conn, , , adCmdText

 

If Not rsPenjualan.EOF Then

rsPenjualan.MoveFirst

 

Do Until rsPenjualan.EOF

subtotal = subtotal + Val(rsPenjualan!total)

rsPenjualan.MoveNext

Loop

 

txtTotal.Text = subtotal

 

Set DGPenjSementara.DataSource = rsPenjualan

 

Else

txtTotal.Text = "0"

Set DGPenjSementara.DataSource = rsPenjualan

End If 

End Sub

 

Private Sub cmdAdd_Click()

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan_sementara where kodebarang = '" &txtKodeBarang.Text & "'", conn, , , adCmdText

 

If rsPenjualan.EOF Then

'============================================

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

Page 34: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 34/57

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan_sementara", conn, , , adCmdText

 

With rsPenjualan

.AddNew

!kodebarang = txtKodeBarang.Text

!namabarang = txtNamaBarang.Text

!merkbarang = txtMerkBarang.Text

!jumlahjual = txtJmlBeli.Text

!disc = Val(txtDiskon.Text)

!total = (Val(txtJmlBeli.Text) * Val(txthargasatuan.Text)) - ((Val(txtDiskon.Text) / 100) *Val(txtJmlBeli.Text) * Val(txthargasatuan.Text))

.Update

End With

'==================================================

Else'==================================================

With rsPenjualan

!jumlahjual = !jumlahjual + Val(txtJmlBeli.Text)

!total = !total + (Val(txtJmlBeli.Text) * Val(txthargasatuan.Text)) - ((Val(txtDiskon.Text) / 100) *Val(txtJmlBeli.Text) * Val(txthargasatuan.Text))

.Update

End With

 

'==================================================

End If 

txtKodeBarang.Text = ""

txtNamaBarang.Text = ""

txtMerkBarang.Text = ""

txthargasatuan.Text = ""

txtJmlBeli.Text = ""

txtDiskon.Text = ""

 

refreshDGSementara

End Sub

 

Sub hapusDGSementara()

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan_sementara", conn, , , adCmdText

 

Page 35: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 35/57

If Not rsPenjualan.EOF Then

rsPenjualan.MoveFirst

 

Do Until rsPenjualan.EOF

rsPenjualan.Delete

rsPenjualan.UpdateBatch

rsPenjualan.MoveNext

Loop

 

refreshDGSementara

End If 

 

End Sub

 

Private Sub cmdBatal_Click()

Dim tanya

 

tanya = MsgBox("Batalkan Transaksi Penjualan Barang?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

hapusDGSementara

kondisiNormal

Else

Exit Sub

End If 

 

End Sub

 

Private Sub cmdBayar_Click()

If Val(txtBayar.Text) < Val(txtTotal.Text) Then

MsgBox "Uang Anda Kurang Rp." & Val(txtTotal.Text) - Val(txtBayar.Text) & " ", vbCritical

Exit Sub

Else

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan_sementara", conn, , , adCmdText

 

If Not rsPenjualan.EOF Then

rsPenjualan.MoveFirst

 

Page 36: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 36/57

Do Until rsPenjualan.EOF

Set rsPenjualan2 = New ADODB.Recordset

rsPenjualan2.LockType = adLockOptimistic

rsPenjualan2.CursorType = adOpenDynamic

rsPenjualan2.Open "SELECT * FROM data_penjualan", conn, , , adCmdText

 

With rsPenjualan2

.AddNew

!kodefaktur = txtKodeFaktur.Text

!tanggaljual = tglJual.Value

!kodebarang = rsPenjualan!kodebarang

!namabarang = rsPenjualan!namabarang

!merkbarang = rsPenjualan!merkbarang

!jumlahjual = rsPenjualan!jumlahjual

!disc = rsPenjualan!disc

!total = rsPenjualan!total

.Update

End With

 

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang where kodebarang = '" & rsPenjualan!kodebarang & "'",conn, , , adCmdText

 

With rsBarang

!stok = !stok - Val(rsPenjualan!jumlahjual)

.Update

End With

 

rsPenjualan.MoveNext

Loop

 

MsgBox "Data Penjualan Tersimpan", vbInformation

kondisiNormal

hapusDGSementara

End If 

End If 

End Sub

 

Private Sub Command1_Click()

Page 37: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 37/57

Page 38: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 38/57

Else

txtKembali.Text = ""

End If 

End Sub

 

Private Sub txtBayar_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

 

End Sub

 

Private Sub txtDiskon_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

 

End Sub

 

Private Sub txtJmlBeli_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

 

End Sub

 

Source Code utk form ReturBeli :

 

Sub loadBarang()

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang", conn, , , adCmdText

 

If Not rsBarang.EOF Then

Set DGBarang.DataSource = rsBarang

End If 

End Sub

 

Sub loadSupplier()

Set rsSupplier = New ADODB.Recordset

Page 39: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 39/57

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

If Not rsSupplier.EOF Then

cmbSupplier.Clear

rsSupplier.MoveFirst

Do Until rsSupplier.EOF

cmbSupplier.AddItem rsSupplier!nama

rsSupplier.MoveNext

Loop

 

cmbSupplier.ListIndex = 0

 

Else

frmSupplier_New.Show

Unload Me

End If 

End Sub

 

Sub kondisiNormal()

tglRetur.Value = Date

txtKodeRetur.Text = ""

txtJmlRetur.Text = ""

 

txtKodeBarang.Text = "" 'DGPembelian.Columns(3).Text

txtNamaBarang.Text = "" 'DGPembelian.Columns(5).Text

txtMerkBarang.Text = "" 'DGPembelian.Columns(4).Text

txtStok.Text = "" 'DGPembelian.Columns(6).Text

 

loadSupplier

loadBarang

 

End Sub

 

Private Sub cmbSupplier_KeyPress(KeyAscii As Integer)

KeyAscii = 0

End Sub

 

Private Sub cmdRetur_Click()

On Error GoTo pesan

Page 40: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 40/57

Dim tanya

 

tanya = MsgBox("Retur Barang dengan Kode " & txtKodeBarang.Text & " sebanyak " & txtJmlRetur.Text & " ?",vbQuestion + vbYesNo)

 

If tanya = vbYes Then

'simpan ke tabel retur beli

Set rsReturBeli = New ADODB.Recordset

rsReturBeli.LockType = adLockOptimistic

rsReturBeli.CursorType = adOpenDynamic

rsReturBeli.Open "SELECT * FROM data_returbeli", conn, , , adCmdText

 

With rsReturBeli

.AddNew

!koderetur = txtKodeRetur.Text

!tanggalretur = tglRetur.Value!kodebarang = txtKodeBarang.Text

!namabarang = txtNamaBarang.Text

!merkbarang = txtMerkBarang.Text

!jumlahretur = Val(txtJmlRetur.Text)

!returkepada = cmbSupplier.Text

.Update

End With

 

'update jumlah stok barang

Set rsBarang = New ADODB.Recordset

rsBarang.LockType = adLockOptimistic

rsBarang.CursorType = adOpenDynamic

rsBarang.Open "SELECT * FROM data_barang where kodebarang = '" & txtKodeBarang.Text & "'", conn, , ,adCmdText

 

With rsBarang

!stok = !stok - Val(txtJmlRetur.Text)

.Update

End With

 

kondisiNormal

 

MsgBox "Data Retur Tersimpan", vbInformation

 

Else

Exit Sub

Page 41: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 41/57

Page 42: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 42/57

koneksi

loadBarang

loadSupplier

End Sub

 

Private Sub txtJmlRetur_Change()

If Val(txtJmlRetur.Text) > Val(txtStok.Text) Then

MsgBox "Jumlah Barang yang Diretur Kebanyakan", vbInformation

txtJmlRetur.Text = ""

End If 

End Sub

 

Private Sub txtJmlRetur_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

End Sub

 

Source Code utk form ByrHutang :

Sub refreshDG()

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

Set DGSupplier.DataSource = rsSupplier

End Sub

 

Sub kondisiNormal()

txtBayarUtang.Text = ""

txtNama.Text = ""

txtSisa.Text = ""

tglBayar.Value = Date

refreshDG

End Sub

 

Private Sub cmdBayar_Click()

Dim tanya

 

tanya = MsgBox("Bayar Hutang?", vbQuestion + vbYesNo)

 

Page 43: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 43/57

If tanya = vbYes Then

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier WHERE nama = '" & txtNama.Text & "'", conn, , ,adCmdText

 

With rsSupplier

If Val(txtSisa.Text) > Val(txtBayarUtang.Text) Then

!Hutang = Val(txtSisa.Text) - Val(txtBayarUtang.Text)

.Update

Else

!Hutang = 0

.Update

MsgBox "Kembalian Pembayaran : " & Val(txtBayarUtang.Text) - Val(txtSisa.Text) & ".", vbInformation

End If End With

 

Set rsHutang = New ADODB.Recordset

rsHutang.LockType = adLockOptimistic

rsHutang.CursorType = adOpenDynamic

rsHutang.Open "SELECT * FROM data_hutang", conn, , , adCmdText

 

With rsHutang

.AddNew

!tgl_bayar = tglBayar.Value

!nama_supplier = txtNama.Text

!jumlah_bayar = txtBayarUtang.Text

.Update

End With

 

MsgBox "Data Pembayaran Hutang Tersimpan", vbInformation

 

kondisiNormal

 

Else

kondisiNormal

End If 

End Sub

 

Private Sub DGsupplier_DblClick()

Page 44: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 44/57

txtNama.Text = DGSupplier.Columns(0).Text

txtSisa.Text = DGSupplier.Columns(3).Text

End Sub

 

Private Sub Form_Load()

koneksi

kondisiNormal

End Sub

 

Private Sub txtBayarUtang_KeyPress(KeyAscii As Integer)

If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or KeyAscii = vbKeyBack) Then

KeyAscii = 0

End If 

 

End Sub

 

Source Code utk form LapBeli :

Public namaberkas As String

Public tmpTotal As Long

Public pesan As String

Public tmpnamaberkas As String

Private Sub cmdCari_Click()

 

Set rsPembelian = New ADODB.Recordset

rsPembelian.LockType = adLockOptimistic

rsPembelian.CursorType = adOpenDynamic

rsPembelian.Open "SELECT * FROM data_pembelian WHERE tanggalbeli >= #" & tglAwal.Value & "# ANDtanggalbeli <= #" & tglAkhir.Value & "#", conn, , , adCmdText

If Not rsPembelian.EOF Then

 

Set DGPembelian.DataSource = rsPembelian

 

Else

MsgBox "Data yang dicari tidak ada"

End If 

 

End Sub

Private Sub Command1_Click()

Page 45: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 45/57

End Sub

Private Sub cmdHapus_Click()

On Error GoTo pesan

 

Dim tanya

tanya = MsgBox("Hapus File " & File1.FileName & " ?", vbQuestion + vbYesNo)

If tanya = vbYes Then

Kill File1.Path & "\" & File1.FileName

File1.Path = App.Path & "\LAPORAN\"

File1.Refresh

RTFBeli.Text = ""

Else

Exit Sub

End If 

 

Exit Sub

pesan: MsgBox "File belum dipilih", vbInformation

End Sub

Private Sub cmdSave_Click()

namaberkas = ""

 

namaberkas = "LAP_PEMBELIAN (" & tglAwal.Day & " " & tglAwal.Month & " " & tglAwal.Year & ") HINGGA (" &tglAkhir.Day & " " & tglAkhir.Month & " " & tglAkhir.Year & ")"

 

If namaberkas = tmpnamaberkas Then

MsgBox "Laporan Pembelian Tersebut Sudah Ada", vbInformation

Exit Sub

Else

Set rsPembelian = New ADODB.Recordset

rsPembelian.LockType = adLockOptimistic

rsPembelian.CursorType = adOpenDynamic

rsPembelian.Open "SELECT * FROM data_pembelian WHERE tanggalbeli >= #" & tglAwal.Value & "# ANDtanggalbeli <= #" & tglAkhir.Value & "#", conn, , , adCmdText

If Not rsPembelian.EOF Then

Page 46: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 46/57

Call saveLaporan("Laporan Pembelian dari " & tglAwal.Value & ") s/d (" & tglAkhir.Value & ")" & vbCrLf,namaberkas)

Call saveLaporan(vbCrLf, namaberkas)

rsPembelian.MoveFirst

tmpTotal = 0

 

Do Until rsPembelian.EOF

Call saveLaporan(rsPembelian!tanggalbeli & vbTab & rsPembelian!kodefaktur & vbTab & rsPembelian!namasupplier & vbTab & rsPembelian!namabarang & vbTab & rsPembelian!merkbarang & vbTab & rsPembelian!jumlahbeli & vbTab & rsPembelian!total, namaberkas)

tmpTotal = tmpTotal + Val(rsPembelian!total)

rsPembelian.MoveNext

Loop

 

Call saveLaporan(vbCrLf & vbCrLf & "TOTAL PEMBELIAN : Rp." & tmpTotal, namaberkas)

 

tmpnamaberkas = namaberkas

File1.Refresh

Else

MsgBox "Data yang dicari tidak ada"

End If 

End If 

End Sub

Private Sub File1_Click()

RTFBeli.FileName = File1.Path & "\" & File1.FileNameEnd Sub

Private Sub Form_Load()

koneksi

File1.Path = App.Path & "\LAPORAN\"

End Sub

 

Source Code utk form LapJual :Public namaberkas As String

Public tmpTotal As Long

Public pesan As String

Public tmpnamaberkas As String

Private Sub cmdCari_Click()

 

Page 47: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 47/57

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan WHERE tanggaljual >= #" & tglAwal.Value & "# ANDtanggaljual <= #" & tglAkhir.Value & "#", conn, , , adCmdText

If Not rsPenjualan.EOF Then

 

Set DGPenjualan.DataSource = rsPenjualan

 

Else

MsgBox "Data yang dicari tidak ada"

End If 

 

End Sub

Private Sub cmdHapus_Click()

On Error GoTo pesan

 

Dim tanya

tanya = MsgBox("Hapus File " & File1.FileName & " ?", vbQuestion + vbYesNo)

If tanya = vbYes Then

Kill File1.Path & "\" & File1.FileName

File1.Path = App.Path & "\LAPORAN\"

File1.Refresh

RTFJual.Text = ""

Else

Exit Sub

End If 

 

Exit Sub

pesan: MsgBox "File belum dipilih", vbInformation

End Sub

Private Sub cmdSave_Click()

namaberkas = ""

 

Page 48: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 48/57

 

namaberkas = "LAP_PENJUALAN (" & tglAwal.Day & " " & tglAwal.Month & " " & tglAwal.Year & ") HINGGA (" &tglAkhir.Day & " " & tglAkhir.Month & " " & tglAkhir.Year & ")"

 

If namaberkas = tmpnamaberkas Then

MsgBox "Laporan Penjualan Tersebut Sudah Ada", vbInformation

Exit Sub

Else

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan WHERE tanggaljual >= #" & tglAwal.Value & "# ANDtanggaljual <= #" & tglAkhir.Value & "#", conn, , , adCmdText

If Not rsPenjualan.EOF Then

Call saveLaporan("Laporan Penjualan dari " & tglAwal.Value & ") s/d (" & tglAkhir.Value & ")" & vbCrLf,

namaberkas)

Call saveLaporan(vbCrLf, namaberkas)

rsPenjualan.MoveFirst

tmpTotal = 0

 

Do Until rsPenjualan.EOF

Call saveLaporan(rsPenjualan!tanggaljual & vbTab & rsPenjualan!kodefaktur & vbTab & rsPenjualan!namabarang & vbTab & rsPenjualan!merkbarang & vbTab & rsPenjualan!jumlahjual & vbTab & rsPenjualan!total,namaberkas)

tmpTotal = tmpTotal + Val(rsPenjualan!total)

rsPenjualan.MoveNext

Loop

 

Call saveLaporan(vbCrLf & vbCrLf & "TOTAL PENJUALAN : Rp." & tmpTotal, namaberkas)

 

tmpnamaberkas = namaberkas

File1.Refresh

Else

MsgBox "Data yang dicari tidak ada"

End If End If 

End Sub

Private Sub File1_Click()

RTFJual.FileName = File1.Path & "\" & File1.FileName

End Sub

Page 49: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 49/57

Private Sub Form_Load()

koneksi

File1.Path = App.Path & "\LAPORAN\"

End Sub

Source Code utk form LapReturBeli :

Public namaberkas As String

Public tmpTotal As Long

Public pesan As String

Public tmpnamaberkas As String

 

Private Sub cmdCari_Click()

 

Set rsReturBeli = New ADODB.Recordset

rsReturBeli.LockType = adLockOptimistic

rsReturBeli.CursorType = adOpenDynamic

rsReturBeli.Open "SELECT * FROM data_returbeli WHERE tanggalretur >= #" & tglAwal.Value & "# ANDtanggalretur <= #" & tglAkhir.Value & "#", conn, , , adCmdText

 

If Not rsReturBeli.EOF Then

 

Set DGReturBeli.DataSource = rsReturBeli

 

Else

MsgBox "Data yang dicari tidak ada"End If 

 

End Sub

 

Private Sub Command1_Click()

 

End Sub

 

Private Sub cmdHapus_Click()

On Error GoTo pesan

 

Dim tanya

 

tanya = MsgBox("Hapus File " & File1.FileName & " ?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

Page 50: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 50/57

Kill File1.Path & "\" & File1.FileName

File1.Path = App.Path & "\LAPORAN\"

File1.Refresh

RTFRetur.Text = ""

Else

Exit Sub

End If 

 

Exit Sub

 

pesan: MsgBox "File belum dipilih", vbInformation

End Sub

 

Private Sub cmdSave_Click()

namaberkas = ""

 

namaberkas = "LAP_RETUR (" & tglAwal.Day & " " & tglAwal.Month & " " & tglAwal.Year & ") HINGGA (" &tglAkhir.Day & " " & tglAkhir.Month & " " & tglAkhir.Year & ")"

 

If namaberkas = tmpnamaberkas Then

MsgBox "Laporan Retur Tersebut Sudah Ada", vbInformation

Exit Sub

Else

Set rsReturBeli = New ADODB.Recordset

rsReturBeli.LockType = adLockOptimistic

rsReturBeli.CursorType = adOpenDynamic

rsReturBeli.Open "SELECT * FROM data_returbeli WHERE tanggalretur >= #" & tglAwal.Value & "# ANDtanggalretur <= #" & tglAkhir.Value & "#", conn, , , adCmdText

 

If Not rsReturBeli.EOF Then

Call saveLaporan("Laporan Retur Barang dari " & tglAwal.Value & ") s/d (" & tglAkhir.Value & ")" & vbCrLf,namaberkas)

Call saveLaporan(vbCrLf, namaberkas)

rsReturBeli.MoveFirst

'tmpTotal = 0

 

Do Until rsReturBeli.EOF

Call saveLaporan(rsReturBeli!tanggalretur & vbTab & rsReturBeli!koderetur & vbTab & rsReturBeli!returkepada & vbTab & rsReturBeli!namabarang & vbTab & rsReturBeli!merkbarang & vbTab & rsReturBeli!jumlahretur, namaberkas)

' tmpTotal = tmpTotal + Val(rsreturbeli!total)

rsReturBeli.MoveNext

Page 51: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 51/57

Loop

 

tmpnamaberkas = namaberkas

File1.Refresh

Else

MsgBox "Data yang dicari tidak ada"

End If 

End If 

End Sub

 

Private Sub File1_Click()

RTFRetur.FileName = File1.Path & "\" & File1.FileName

End Sub

 

Private Sub Form_Load()

koneksi

File1.Path = App.Path & "\LAPORAN\"

End Sub

 

Source Code utk form LapByrUtang :

Public namaberkas As String

Public tmpTotal As Long

Public pesan As String

Public tmpnamaberkas As String

 

Private Sub cmdCari_Click()

 

Set rsHutang = New ADODB.Recordset

rsHutang.LockType = adLockOptimistic

rsHutang.CursorType = adOpenDynamic

rsHutang.Open "SELECT * FROM data_hutang WHERE tgl_bayar >= #" & tglAwal.Value & "# AND tgl_bayar<= #" & tglAkhir.Value & "#", conn, , , adCmdText

 

If Not rsHutang.EOF Then

 

Set DGHutang.DataSource = rsHutang

 

Else

MsgBox "Data yang dicari tidak ada"

End If 

 

Page 52: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 52/57

End Sub

 

Private Sub cmdHapus_Click()

On Error GoTo pesan

 

Dim tanya

 

tanya = MsgBox("Hapus File " & File1.FileName & " ?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

Kill File1.Path & "\" & File1.FileName

File1.Path = App.Path & "\LAPORAN\"

File1.Refresh

RTFHutang.Text = ""

Else

Exit Sub

End If 

 

Exit Sub

 

pesan: MsgBox "File belum dipilih", vbInformation

End Sub

 

Private Sub cmdSave_Click()

namaberkas = ""

 

namaberkas = "LAP_PEMBAYARAN HUTANG (" & tglAwal.Day & " " & tglAwal.Month & " " & tglAwal.Year & ")HINGGA (" & tglAkhir.Day & " " & tglAkhir.Month & " " & tglAkhir.Year & ")"

 

If namaberkas = tmpnamaberkas Then

MsgBox "Laporan Pembayaran Hutang Tersebut Sudah Ada", vbInformation

Exit Sub

Else

Set rsHutang = New ADODB.Recordset

rsHutang.LockType = adLockOptimistic

rsHutang.CursorType = adOpenDynamic

rsHutang.Open "SELECT * FROM data_hutang WHERE tgl_bayar >= #" & tglAwal.Value & "# AND tgl_bayar<= #" & tglAkhir.Value & "#", conn, , , adCmdText

 

If Not rsHutang.EOF Then

Page 53: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 53/57

Call saveLaporan("Laporan Pembayaran Hutang dari " & tglAwal.Value & ") s/d (" & tglAkhir.Value & ")" &vbCrLf, namaberkas)

Call saveLaporan(vbCrLf, namaberkas)

rsHutang.MoveFirst

 

Do Until rsHutang.EOF

Call saveLaporan(rsHutang!tgl_bayar & vbTab & rsHutang!nama_supplier & vbTab & rsHutang!jumlah_bayar, namaberkas)

'tmpTotal = tmpTotal + Val(rsHutang!total)

rsHutang.MoveNext

Loop

 

tmpnamaberkas = namaberkas

File1.Refresh

Else

MsgBox "Data yang dicari tidak ada"

End If 

End If 

End Sub

 

Private Sub File1_Click()

RTFHutang.FileName = File1.Path & "\" & File1.FileName

End Sub

 

Private Sub Form_Load()

koneksi

File1.Path = App.Path & "\LAPORAN\"

End Sub

 

Source Code utk form LapKeu :

Public tmpUtang As Double

Public tmpBeli As Double

Public tmpJual As Double

Public tmpnamaberkas As String

Public namaberkas As String

 

Sub loadUtang()

tmpUtang = 0

Set rsSupplier = New ADODB.Recordset

rsSupplier.LockType = adLockOptimistic

Page 54: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 54/57

rsSupplier.CursorType = adOpenDynamic

rsSupplier.Open "SELECT * FROM data_supplier", conn, , , adCmdText

 

If Not rsSupplier.EOF Then

rsSupplier.MoveFirst

 

Do Until rsSupplier.EOF

tmpUtang = tmpUtang + rsSupplier!Hutang

rsSupplier.MoveNext

Loop

 

End If 

 

txtHutang.Text = tmpUtang

 

End Sub

 

Sub loadPembelian()

tmpBeli = 0

Set rsPembelian = New ADODB.Recordset

rsPembelian.LockType = adLockOptimistic

rsPembelian.CursorType = adOpenDynamic

rsPembelian.Open "SELECT * FROM data_pembelian WHERE tanggalbeli >= #" & tglAwal.Value & "# ANDtanggalbeli <= #" & tglAkhir.Value & "#", conn, , , adCmdText

 

If Not rsPembelian.EOF Then

rsPembelian.MoveFirst

 

Do Until rsPembelian.EOF

tmpBeli = tmpBeli + Val(rsPembelian!total)

rsPembelian.MoveNext

Loop

End If 

 

txtPembelian.Text = tmpBeli

 

End Sub

 

Sub loadPenjualan()

tmpJual = 0

Page 55: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 55/57

Set rsPenjualan = New ADODB.Recordset

rsPenjualan.LockType = adLockOptimistic

rsPenjualan.CursorType = adOpenDynamic

rsPenjualan.Open "SELECT * FROM data_penjualan WHERE tanggaljual >= #" & tglAwal.Value & "# ANDtanggaljual <= #" & tglAkhir.Value & "#", conn, , , adCmdText

 

If Not rsPenjualan.EOF Then

rsPenjualan.MoveFirst

 

Do Until rsPenjualan.EOF

tmpJual = tmpJual + Val(rsPenjualan!total)

rsPenjualan.MoveNext

Loop

End If 

 

txtPenjualan.Text = tmpJual 

End Sub

 

Private Sub cmdCari_Click()

loadPembelian

loadPenjualan

loadUtang

End Sub

 

Private Sub cmdHapus_Click()

On Error GoTo pesan

 

Dim tanya

 

tanya = MsgBox("Hapus File " & File1.FileName & " ?", vbQuestion + vbYesNo)

 

If tanya = vbYes Then

Kill File1.Path & "\" & File1.FileName

File1.Path = App.Path & "\LAPORAN\"

File1.Refresh

RTFKeuangan.Text = ""

Else

Exit Sub

End If 

 

Page 56: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 56/57

Exit Sub

 

pesan: MsgBox "File belum dipilih", vbInformation

 

End Sub

 

Private Sub cmdSimpan_Click()

namaberkas = ""

 

namaberkas = "LAP_KEUANGAN (" & tglAwal.Day & " " & tglAwal.Month & " " & tglAwal.Year & ") HINGGA (" &tglAkhir.Day & " " & tglAkhir.Month & " " & tglAkhir.Year & ")"

 

If namaberkas = tmpnamaberkas Then

MsgBox "Laporan Pembelian Tersebut Sudah Ada", vbInformation

Exit SubElse

 

Call saveLaporan("Laporan Keuangan dari " & tglAwal.Value & ") s/d (" & tglAkhir.Value & ")" & vbCrLf,namaberkas)

Call saveLaporan(vbCrLf, namaberkas)

Call saveLaporan("TOTAL PENJUALAN : " & txtPenjualan.Text, namaberkas)

Call saveLaporan("==========================================", namaberkas)

Call saveLaporan("TOTAL PEMBELIAN : " & txtPembelian.Text, namaberkas)

Call saveLaporan("SISA HUTANG : " & txtHutang.Text, namaberkas)

Call saveLaporan("==========================================", namaberkas)

Call saveLaporan(vbCrLf & vbCrLf & "SELISIH : Rp." & (Val(txtPenjualan.Text)) - (Val(txtPembelian.Text) +Val(txtHutang.Text)), namaberkas)

 

tmpnamaberkas = namaberkas

File1.Refresh

 

End If 

 

End Sub

 

Private Sub File1_Click()

RTFKeuangan.FileName = File1.Path & "\" & File1.FileName

End Sub

 

Private Sub Form_Load()

koneksi

Page 57: Source Code Toko Kelontong

8/4/2019 Source Code Toko Kelontong

http://slidepdf.com/reader/full/source-code-toko-kelontong 57/57

File1.Path = App.Path & "\LAPORAN\"

End Sub


Recommended