Tb_penjualan
No_nota
Tb_Stok
Pk Kode_barang
Nama_barang
Jumlah
Satuan
Harga_jual
Tanggal_update
Jumlah_minimal
Tanggal
Fk
Kode_barang
Nama_barang
Jumlah
Satuan
Harga
Total
Pk
Id_jual
n
Relasi Tabel 2
Tb_stok
PK
Kode_barang
Nama_barang
Jumlah
Satuan
Harga_jual
Tanggal_update
Jumlah_minimal
Tb_supplier
PK
Kode_supplier
Nama_supplier
Alamat
No_telp
Note
Tb_pembelian
No_urut
n
No_nota
Tanggal
FK Kode_barang
Nama_barang
Jumlah
Harga
Satuan
FK Kode_supplier
Nama_supplier
Total
PK Id_beli
n
n
Tb_ABC
PK Kode_barang
FK Volume_bulanan
Tb_stok
PK
Kode_barang
Nama_barang
Jumlah
Satuan
Harga_jual
Tanggal_update
Jumlah_minimal
FK Biaya_unit
Vol_rup_bul
Persentase_vol_rup_bul
Kelas
Tb_penjualan
No_nota
Tanggal
Kode_barang
Nama_barang
Jumlah
Satuan
Harga
Total
PK Id_jual
n
n
Relasi Tabel 4
Tb_laba_kotor
PK Kode_barang
FK Kelas
Jumlah_stok
Stok_awal
Pembelian
Barang_tersedia_dijual
Stok_akhir
HPP
Total_penjualan
Laba_kotor
Tb_ABC
PK Kode_barang
Volume_bulanan
Biaya_unit
Vol_rup_bul
Persentase_vol_rup_bul
Kelas
1
Tb_laba_kotor
PK Kode_barang
Kelas
FK Jumlah_stok
Stok_awal
FK Pembelian
Barang_tersedia_dijual
Stok_akhir
HPP
Total_penjualan
Laba_kotor
Tb_pembelian
No_urut
No_nota
Tanggal
Kode_barang
Nama_barang
Jumlah
Harga
Satuan
Kode_supplier
Nama_supplier
Total
PK Id_beli
n
1
n
Relasi Tabel 6
Tb_laba_kotor
PK Kode_barang
Kelas
Jumlah_stok
Stok_awal
Pembelian
Barang_tersedia_dijual
Stok_akhir
HPP
FK Total_penjualan
Laba_kotor
Tb_penjualan
PK No_nota
Tanggal
Kode_barang
Nama_barang
Jumlah
Satuan
Harga
Total
Id_jual
n
Tb_laba_kotor
PK Kode_barang
Kelas
Jumlah_stok
FK Stok_awal
Pembelian
Barang_tersedia_dijual
Stok_akhir
HPP
Total_penjualan
Laba_kotor
Tb_logfile
PK Id
No_nota
Tanggal
Kode_barang
Transaksi
Kode_supplier
Jumlah
Harga
Total
Jumlah_stok
1
Lampiran 4
Coding Login
Private Sub cmdCancel_Click() Unload Me
End Sub
Private Sub cmdOK_Click()
If txtUserName.Text = "" Or txtPassword.Text = "" Then
MsgBox "Username dan Password harus diisi.!", vbCritical, "xx" Exit Sub
Else
Adodc1.RecordSource = "select * from tb_user where username = '" + txtUserName + "'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "Username salah.!", vbCritical, "xx" Exit Sub
ElseIf Not Adodc1.Recordset!Password = txtPassword Then MsgBox "Password salah.!", vbCritical, "xx"
Exit Sub Else
xuser = Adodc1.Recordset!UserName xstat = Adodc1.Recordset!Status MsgBox "Selamat datang.!" & vbCrLf & _
"Anda telah login sebagai " + xstat + " .", vbInformation, "vv"
menuutama.Lbuser.Caption = xuser menuutama.Lbstatus.Caption = xstat menuutama.mndata.Enabled = True Unload Me
End If End If End Sub
Coding Form Stok Barang
Dim pesan, proses As StringSub TXT(a As Boolean, b As Boolean) Txtkode.Enabled = a
Txtnama.Enabled = a Txtjumlah.Enabled = b Cbosatuan.Enabled = a Txtharga.Enabled = a Txtmin.Enabled = a End Sub
Sub CMD(h As Boolean, j As Boolean) Cmdupdate.Enabled = h
Txtharga.Text = "" Txtmin.Text = "" End Sub
Private Sub Cmdcetak_Click() On Error Resume Next
'Adodc1.RecordSource = "select * from tb_stok" 'Adodc1.Refresh
With Adodc1.Recordset Printer.FontSize = 14 Printer.FontBold = True
Printer.Print "LAPORAN STOK BARANG" Printer.FontSize = 10
Printer.Print Tab(1); "Periode waktu : "; Printer.Print Tab(25); Format(Date) Printer.FontBold = False
Printer.Print "---" & _
"---"
Printer.Print Tab(1); "Kode Barang"; Printer.Print Tab(20); "Nama Barang"; Printer.Print Tab(50); "Saldo"; Printer.Print Tab(65); "Min Saldo"; Printer.Print Tab(80); "Satuan";
Printer.Print Tab(95); "Tanggal Update"
Printer.Print "---" & _
"---"
Do While Not .EOF
Printer.Print Tab(1); !kode_barang; Printer.Print Tab(20); !nama_barang; Printer.Print Tab(50); !jumlah;
Printer.Print Tab(65); !jumlah_minimal; Printer.Print Tab(80); !satuan;
Printer.Print Tab(95); !tanggal_update .MoveNext
Loop .MoveFirst
Printer.Print "---" & _
"---"
End With End Sub
Private Sub Cmddelete_Click() proses = "delete"
Unload Me End Sub
Private Sub Cmdinsert_Click() If Cmdinsert.Caption = "Baru" Then proses = "insert"
Cmdinsert.Caption = "Batal" Call CMD(False, True) Call TXT(True, True) Txtkode.SetFocus
ElseIf Cmdinsert.Caption = "Batal" Then Cmdinsert.Caption = "Baru"
Call KOSONG
Call CMD(True, False) Call TXT(False, False)
Adodc1.RecordSource = "select * from tb_stok" Adodc1.Refresh
End If End Sub
Private Sub Cmdsave_Click()
If Txtkode.Text = "" Or Txtnama.Text = "" Or Txtjumlah.Text = "" Or Cbosatuan.Text = "" Or Txtharga.Text = "" Or Txtmin.Text = "" Then
MsgBox "Data belum lengkap.!", vbCritical, "xx" Exit Sub
Else
If proses = "insert" Then
Adodc1.RecordSource = "select * from tb_stok where kode_barang = '" + Txtkode + "'"
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then
MsgBox "Data sudah ada.!", vbCritical, "xx" Exit Sub
Else
Adodc1.RecordSource = "select * from tb_stok" Adodc1.Refresh
Adodc1.Recordset.AddNew End If
ElseIf proses = "update" Then
Adodc1.RecordSource = "select * from tb_stok where kode_barang = '" + Txtkode + "'"
Adodc1.Refresh End If
With Adodc1.Recordset !kode_barang = Txtkode !nama_barang = Txtnama !jumlah = Val(Txtjumlah) !satuan = Cbosatuan
!harga_jual = Val(Txtharga) !tanggal_update = Dtanggal.Value !jumlah_minimal = Val(Txtmin) .Update
End With
MsgBox "Data telah disimpan.!", vbInformation, "vv" End If
Call LOGFILE
End Sub
Private Sub Cmdupdate_Click() proses = "update"
Call UPDEL End Sub
Private Sub Form_Load() Dtanggal.Value = Format(Date) Call TXT(False, False)
Call CMD(True, False)
If menuutama.Lbuser.Caption = "admin" Then Frlock.Visible = False
Else
Frlock.Visible = True End If
End Sub
Private Sub Form_Unload(Cancel As Integer) menuutama.mndata.Enabled = True
menuutama.mnlogout.Enabled = True End Sub
Sub UPDEL()
pesan = InputBox("Masukkan kode barang untuk melakukan proses.!") If pesan = "" Then
Exit Sub Else
Adodc1.RecordSource = "select * from tb_stok where kode_barang = '" + pesan + "'"
Adodc1.Refresh
If Not Adodc1.Recordset.EOF Then With Adodc1.Recordset
Txtkode.Text = !kode_barang Txtnama.Text = !nama_barang Txtjumlah.Text = !jumlah Cbosatuan.Text = !satuan Txtharga.Text = !harga_jual Txtmin.Text = !jumlah_minimal End With
If proses = "update" Then Call TXT(True, False) Call CMD(False, True) Cmdinsert.Caption = "Batal" Txtkode.SetFocus
ElseIf proses = "delete" Then
If MsgBox("Anda yakin ingin menghapus data barang tersebut.?", vbYesNo + vbQuestion, "hmm") = vbYes Then
Adodc1.Recordset.Delete
MsgBox "Data barang telah dihapus.!", vbInformation, "vv"
Adodc1.Refresh End If
End If Else
MsgBox "Data tidak ditemukan.!", vbCritical, "xx" Adodc1.RecordSource = "select * from tb_stok" Adodc1.Refresh
End If End If End Sub
Sub LOGFILE() Dim awalx As String
If proses = "insert" Then awalx = "Stok Awal" Else
awalx = "-" End If
adoLog.RecordSource = "select * from tb_logfile" adoLog.Refresh
adoLog.Recordset.AddNew With adoLog.Recordset !no_nota = "-"
!tanggal = Dtanggal.Value !kode_barang = Txtkode !transaksi = awalx !kode_supplier = "-" !jumlah = Val(Txtjumlah) !harga = Val(Txtharga)
!total = Val(Txtjumlah) * Val(Txtharga) !jumlah_stok = Val(Txtjumlah)
.Update End With End Sub
Private Sub Txtjumlah_KeyPress(KeyAscii As Integer) If Not KeyAscii < 48 And KeyAscii > 57 Then
MsgBox "Input salah.", vbCritical, "xx" KeyAscii = 0
End If End Sub
Coding Analisis ABC
Dim VolBul, TotVolBul, VolRupBul, TotVolRupBul, SenVolRupBul, totkel As Double
Dim KodBar, Kel As String Private Sub Command1_Click() On Error GoTo salahtanggal
'utk mencari volume bulanan, total volume bulanan, volume rupiah bulanan, dan total volume bulanan
TotVolBul = 0 TotVolRupBul = 0 'hapus record yg ada
Adodc1.RecordSource = "select * from tb_stok" Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF VolBul = 0
VolRupBul = 0
KodBar = Adodc1.Recordset!kode_barang
Adodc2.RecordSource = "select * from tb_penjualan where tanggal >= '" + Format(Dt1, "yyyy-mm-dd") + "' and tanggal <= '" + Format(Dt2, "yyyy-mm-dd") + "'"
Adodc2.Refresh
If Format(Dt1, "yyyy-mm-dd") > Format(Dt2, "yyyy-mm-dd") Then MsgBox "Input tanggal awal dan akhir salah.!", vbCritical, "xx"
Exit Sub End If
Adodc2.Recordset.Filter = "kode_barang like '*" + KodBar + "*'"
Do While Not Adodc2.Recordset.EOF
VolBul = VolBul + Val(Adodc2.Recordset!jumlah) TotVolBul = TotVolBul + VolBul
Adodc2.Recordset.MoveNext Loop
VolRupBul = Val(VolBul) * Val(Adodc1.Recordset!harga_jual) TotVolRupBul = TotVolRupBul + VolRupBul
Adodc3.RecordSource = "select * from tb_abc" Adodc3.Refresh
Adodc3.Recordset.AddNew With Adodc3.Recordset
!kode_barang = Adodc1.Recordset!kode_barang !volume_bulanan = VolBul
!biaya_unit = Adodc1.Recordset!harga_jual !vol_rup_bul = VolRupBul
.Update End With
Adodc1.Recordset.MoveNext Loop
Adodc3.RecordSource = "select * from tb_abc" Adodc3.Refresh
Do While Not Adodc3.Recordset.EOF
SenVolRupBul = Format(Val(Adodc3.Recordset!vol_rup_bul) / TotVolRupBul, "0.000")
If SenVolRupBul >= 0.2 Then Kel = "A"
ElseIf SenVolRupBul > 0.05 And SenVolRupBul < 0.2 Then Kel = "B"
Else
Kel = "C" End If
!persentase_vol_rup_bul = Format(Val(SenVolRupBul) * 100, "0.00")
!kelas = Kel .Update End With
Adodc3.Recordset.MoveNext Loop
Adodc3.RecordSource = "select * from tb_abc where kelas = '" + "A" + "'"
Adodc3.Refresh
With Adodc3.Recordset totkel = 0
Do While Not .EOF
totkel = totkel + Format(Val(!persentase_vol_rup_bul) / 100, "0.00")
.MoveNext Loop
grA.Height = 4455 * totkel
grA.Top = 2400 + 4440 - grA.Height End With
Adodc3.RecordSource = "select * from tb_abc where kelas = '" + "B" + "'"
Adodc3.Refresh With Adodc3.Recordset totkel = 0 Do While Not .EOF
totkel = totkel + Format(Val(!persentase_vol_rup_bul) / 100, "0.00")
.MoveNext Loop
grB.Height = 4455 * totkel
grB.Top = 2400 + 4440 - grB.Height End With
Adodc3.RecordSource = "select * from tb_abc where kelas = '" + "C" + "'"
Adodc3.Refresh With Adodc3.Recordset totkel = 0 Do While Not .EOF
totkel = totkel + Format(Val(!persentase_vol_rup_bul) / 100, "0.00")
.MoveNext Loop
grC.Height = 4455 * totkel
grC.Top = 2400 + 4440 - grC.Height End With
Adodc3.RecordSource = "select * from tb_abc" Adodc3.Refresh
Exit Sub
salahtanggal:
MsgBox "Tanggal Transaksi Salah", vbCritical, "xx" Exit Sub
End Sub
Dt2.Value = Format(Date) End Sub
Private Sub Form_Unload(Cancel As Integer) menuutama.mndata.Enabled = True
menuutama.mnlogout.Enabled = True End Sub
Coding Perhitungan Laba Kotor
Dim kdbar As String
Dim HPP, sediaawal, sediajual, jumBeli, totJual, totBeli, Labakotor, rtBeli, sediaakhir, xstok, Totalx As Double
Private Sub Command1_Click() If cboABC.Text = "" Then
MsgBox "Kelas Belum Dipilih", vbCritical, "xx" Exit Sub
End If
If Format(Dt1, "yyyy-mm-dd") > Format(Dt2, "yyyy-mm-dd") Then MsgBox "Input tanggal awal dan akhir salah.!", vbCritical, "xx"
Exit Sub End If
Adodc5.RecordSource = "select * from tb_laba_kotor" Adodc5.Refresh
Do While Not Adodc5.Recordset.EOF Adodc5.Recordset.Delete Adodc5.Recordset.MoveNext Loop
Totalx = 0
Adodc3.RecordSource = "select * from tb_abc where kelas = '" + cboABC + "'"
Adodc3.Refresh
Do While Not Adodc3.Recordset.EOF kdbar = Adodc3.Recordset!kode_barang sediaawal = 0
sediajual = 0 jumBeli = 0 totBeli = 0 rtBeli = 0 sediaakhir = 0 totJual = 0 Labakotor = 0
Adodc6.RecordSource = "select * from tb_logfile where kode_barang = '" + kdbar + "' and transaksi = '" + "Stok Awal" + "'"
Adodc6.Refresh
Adodc2.RecordSource = "select * from tb_pembelian where tanggal >= '" + Format(Dt1, "yyyy-mm-dd") + "' and tanggal <= '" + Format(Dt2, "yyyy-mm-dd") + "' and kode_barang = '" + kdbar + "'" Adodc2.Refresh
If Format(Dt1, "yyyy-mm-dd") > Format(Dt2, "yyyy-mm-dd") Then MsgBox "Input tanggal awal dan akhir salah.!", vbCritical, "xx"
Exit Sub End If
Do While Not Adodc2.Recordset.EOF
jumBeli = jumBeli + Val(Adodc2.Recordset!jumlah) 'jumlah pembelian barang
totBeli = totBeli + Val(Adodc2.Recordset!total) 'total harga pmbelian barang
rtBeli = Format(Val(totBeli) / Val(jumBeli), "0.00") Adodc4.RecordSource = "select * from tb_stok where kode_barang = '" + kdbar + "'"
Adodc4.Refresh
xstok = Adodc4.Recordset!jumlah 'megetahui stok barang yg ada
sediaakhir = Format(Val(xstok) * Val(rtBeli), "0.00") Adodc2.Recordset.MoveNext
Loop
If Adodc2.Recordset.EOF Then
Adodc4.RecordSource = "select * from tb_stok where kode_barang = '" + kdbar + "'"
Adodc4.Refresh
xstok = Adodc4.Recordset!jumlah End If
sediajual = Val(sediaawal) + Val(totBeli) HPP = Val(sediajual) - Val(sediaakhir)
Adodc1.RecordSource = "select * from tb_penjualan where tanggal >= '" + Format(Dt1, "yyyy-mm-dd") + "' and tanggal <= '" + Format(Dt2, "yyyy-mm-dd") + "' and kode_barang = '" + kdbar + "'" Adodc1.Refresh
Do While Not Adodc1.Recordset.EOF
totJual = Val(totJual) + Val(Adodc1.Recordset!total) Adodc1.Recordset.MoveNext
Loop
Labakotor = Val(totJual) - Val(HPP)
Adodc5.Recordset.AddNew With Adodc5.Recordset !kode_barang = kdbar !kelas = cboABC.Text !jumlah_stok = xstok !stok_awal = sediaawal !pembelian = totBeli
!barang_tersedia_dijual = sediajual !stok_akhir = sediaakhir
!HPP = HPP
!total_penjualan = totJual !laba_kotor = Labakotor .Update
End With
End Sub
Private Sub Command2_Click() Unload Me
End Sub
Private Sub Command3_Click() On Error Resume Next
With Adodc5.Recordset Printer.FontSize = 14 Printer.FontBold = True
Printer.Print "PERHITUNGAN LABA KOTOR" Printer.FontSize = 10
Printer.Print Tab(1); "Periode waktu : "; Printer.Print Tab(25); Dt1.Value
Printer.Print Tab(25); Dt2.Value ' Printer.FontBold = False
Printer.Print "---" & _
"---"
Do While Not .EOF
Printer.FontBold = False
Printer.Print Tab(1); "KODE BARANG :"; Printer.Print Tab(31); !kode_barang Printer.Print Tab(1); "NAMA BARANG :";
Adodc4.RecordSource = "select * from tb_stok where kode_barang = '" + Adodc5.Recordset!kode_barang + "'" Adodc4.Refresh
Printer.Print Tab(31); Adodc4.Recordset!nama_barang Printer.Print Tab(1); "Stok Awal";
Printer.Print Tab(31); !stok_awal Printer.Print Tab(1); "Pembelian"; Printer.Print Tab(31); !pembelian
Printer.Print Tab(31); "--- (+)" Printer.Print Tab(1); "Barang Tersedia Dijual"; Printer.Print Tab(31); !barang_tersedia_dijual Printer.Print Tab(1); "Stok Akhir";
Printer.Print Tab(31); !stok; akhir Printer.Print Tab(31); "--- (-)" Printer.Print Tab(1); "H P P";
Printer.Print Tab(31); !HPP Printer.Print Tab(100); "v";
Printer.Print Tab(1); "Total Penjualan"; Printer.Print Tab(31); !total_penjualan Printer.Print Tab(1); "H P P";
Printer.Print Tab(31); !HPP
Printer.Print Tab(31); "--- (-)" Printer.Print Tab(1); "Laba Kotor"; Printer.Print Tab(31); !laba_kotor
"---"
.MoveNext Loop
.MoveFirst
Printer.Print "---" & _
"---"
Printer.Print Tab(1); "Total Laba Kotor :"; Printer.Print Tab(31); Totalx
End With End Sub
Private Sub Form_Load() Dt1.Value = Format(Date) Dt2.Value = Format(Date) End Sub
Private Sub Form_Unload(Cancel As Integer) menuutama.mndata.Enabled = True