Form Pembelian Barang


                Setelah kita membuat form-form untuk data master maka sekarang kita akan membuat form untuk proses transaksi. Proses yang akan kita catat dalam aplikasi ini ada lima transaksi yaitu :
1.       Transaksi pembelian.
2.       Transakasi retur pembelian.
3.       Transaksi penjualan grosir.
4.       Transaksi penjualan eceran.
5.       Transaksi retur penjualan.
Kita akan membahas satu per satu semua form-form transaksi tersebut. Yang pertama akan kita buat adalah form pembelian barang. Yang dibutuhkan untuk membuat form pembelian barang adalah :
Object
Properties
Setting
Form
Name
FrmBeliBarang

BorderStyle
0-None

BackColor
&H00FFC0C0&

StartUpPosition
2-CenterScreen
Label
Name
Label1

Font
Calibri

ForeColor
&H8000000D&

Caption
Form Pembelian Barang

Name
Label2

Font
Calibri

ForeColor
&H8000000D&

Caption
No Kwitansi

Name
Label3

Font
Calibri

ForeColor
&H8000000D&

Caption
Supplier

Name
Label4

Font
Calibri

ForeColor
&H8000000D&

Caption
Tanggal Transaksi

Name
Label5

Font
Calibri

ForeColor
&H8000000D&

Caption
TanggalKirim

Name
Label6

Font
Calibri

ForeColor
&H8000000D&

Caption
Nama Barang

Name
Label7

Font
Calibri

ForeColor
&H8000000D&

Caption
Jumlah

Name
Label8

Font
Calibri

ForeColor
&H8000000D&

Caption
Harga Beli

Name
Label3

Font
Calibri

ForeColor
&H8000000D&

Caption
Biaya Kirim
Textbox
Name
TxtKwitansi

Appearance
0-Flat

Height
330
TDBDate
Name
TxtTgl

DisplyFormat
dd mmmm yyy

ButtonVisible
1-True

Height
330

Name
TxtTglKirim

DisplyFormat
dd mmmm yyy

ButtonVisible
1-True

Height
330
SSOleDBCombo
Name
CmbSupplier

Height
330

BackColorOdd
&H00FFC0C0&

Name
CmbBarang

Height
330

BackColorOdd
&H00FFC0C0&
TDBNumber
Name
TxtJumlah

Height
330

appearance
0-Flat

DisplayFormat
###,###,###,##0.00;(###,###,###,##0.00)

Format
###,###,###,##0.00

Name
TxtHarga

Height
330

appearance
0-Flat

DisplayFormat
###,###,###,##0.00;(###,###,###,##0.00)

Format
###,###,###,##0.00

Name
TxtKirim

Height
330

appearance
0-Flat

DisplayFormat
###,###,###,##0.00;(###,###,###,##0.00)

Format
###,###,###,##0.00
VBButton
Name
CmdSave

ButtonType
4-Mac

Caption
&Save

Name
CmdCancel

ButtonType
4-Mac

Caption
&Cancel

Name
CmdInput

ButtonType
4-Mac

Caption
&Cari

Name
vbButton1

ButtonType
3-WindowsXP

Caption
-

BackColor
&H00FFC0C0&

Name
vbButton2

ButtonType
3-WindowsXP

Caption
X

BackColor
&H00FFC0C0&
TDBGrid
Name
Grid

DeadAreaColor
&H00FFC0C0&

ColumnFooter
False

MarqueeStyle
2-HighlightCell
TDBGrid. Column(0)
DataField
Noket

Caption
Nomor
TDBGrid. Column(1)
DataField
Kodebarang

Caption
KodeBarang

Visible
False
TDBGrid. Column(2)
DataField
 NamaBarang

Caption
Nama Barang
TDBGrid. Column(3)
DataField
Jumlah

Caption
Jumlah
TDBGrid. Column(4)
DataField
HargaBeli

Caption
Harga Beli
TDBGrid. Column(5)
DataField
BiayaKirim

Caption
Biaya Kirim
Adodc
Name
AdoBarang

Visible
False

Name
AdoSupplier

Visible
False

Tampilan design form pembelian barang


Tampilan form pembelian barang saat dijalankan


Source code program:
Dim RsTemp2 As New ADODB.Recordset

Private Sub CmbBarang_DropDown()
AdoBarang.RecordSource = ""
SQL = "Select KodeBarang,NamaBarang from Barang order by kodeBarang"
Set RSFind = DbCon.Execute(SQL)
If RSFind.BOF Then Exit Sub
AdoBarang.RecordSource = SQL
AdoBarang.Refresh
With CmbBarang
    .DataSourceList = AdoBarang
    .DataFieldList = "NamaBarang"
    .Columns(0).Visible = False
    .Columns(1).Width = 2000
End With
End Sub

Private Sub CmbBarang_GotFocus()
If Trim(CmbSupplier) = "" Or Not CmbSupplier.IsItemInList Then
    MsgBox "Supplier Belum Dipilih"
    CmbSupplier.SetFocus
    Exit Sub
ElseIf TxtTgl = Null Then
    MsgBox "Tanggal Beli Kosong"
    TxtTgl.SetFocus
    Exit Sub
ElseIf TxtTglKirim = Null Then
    MsgBox "Tanggal Kosong Kosong"
    TxtTglKirim.SetFocus
    Exit Sub
End If
End Sub

Private Sub CmbSupplier_DropDown()
AdoSupplier.RecordSource = ""
SQL = "Select KodeSupplier,NamaSupplier from Supplier order by kodeSupplier"
Set RSFind = DbCon.Execute(SQL)
If RSFind.BOF Then Exit Sub
AdoSupplier.RecordSource = SQL
AdoSupplier.Refresh
With CmbSupplier
    .DataSourceList = AdoSupplier
    .DataFieldList = "NamaSupplier"
    .Columns(0).Visible = False
    .Columns(1).Width = 2000
End With
End Sub

Private Sub CmdCancel_Click()
Form_Load
End Sub

Private Sub CmdInput_Click()
If Trim(CmbBarang) = "" Or Not CmbBarang.IsItemInList Then
    MsgBox "Barang Belum Dipilih"
    CmbBarang.SetFocus
    Exit Sub
ElseIf TxtJumlah = 0 Then
    MsgBox "Jumlah Masih 0"
    TxtJumlah.SetFocus
    Exit Sub
ElseIf TxtHarga = 0 Then
    MsgBox "Harga Beli Masih 0"
    TxtHarga.SetFocus
    Exit Sub
ElseIf TxtKirim = 0 Then
    MsgBox "Biaya Kirim Masih 0"
    TxtKirim.SetFocus
    Exit Sub
End If

RsTemp2.Find "namaBarang='" & Trim(CmbBarang) & "'", , adSearchForward, 1
If RsTemp2.EOF Then
    With RsTemp2
        .AddNew
        !NoKet = RsTemp2.RecordCount
        !namaBarang = Trim(CmbBarang)
        !KodeBarang = Trim(CmbBarang.Columns(0).Text)
        !Jumlah = Val(TxtJumlah)
        !HargaBeli = Val(TxtHarga)
        !BiayaKirim = Val(TxtKirim)
        .Update
    End With
    Grid.DataSource = RsTemp2
    Grid.Refresh
Else
    MsgBox "Barang Sudah Diinputkan."
    Exit Sub
End If
CmbBarang = ""
TxtJumlah = 0
TxtHarga = 0
TxtKirim = 0
CmbBarang.SetFocus

End Sub

Private Sub CmdSave_Click()
If RsTemp2.RecordCount = 0 Then
    MsgBox "Tidak Ada Barang Dalam List"
    Exit Sub
End If

SQL = "insert into BeliBarang values('" & Trim(TxtKwitansi) & "','" & FormatTgl(TxtTgl) & "','" & _
    Trim(CmbSupplier) & "','" & FormatTgl(TxtTglKirim) & "')"
DbCon.Execute SQL

RsTemp2.MoveFirst
While Not RsTemp2.EOF
    With RsTemp2
        SQL = "insert into dtlBeliBarang values('" & Trim(TxtKwitansi) & "','" & FormatTgl(TxtTgl) & _
            "','" & !NoKet & "','" & !KodeBarang & "'," & !Jumlah & "," & !HargaBeli & "," & _
            !BiayaKirim & ")"
        DbCon.Execute SQL
    End With
    RsTemp2.MoveNext
Wend
MsgBox "Data Saved"
Bersih
TxtKwitansi.SetFocus
Form_Load
End Sub

Private Sub Form_Load()
If RsTemp2.State Then RsTemp2.Close
AdoBarang.ConnectionString = ConDB
AdoSupplier.ConnectionString = ConDB
Bersih
TxtKwitansi = KodeAuto

With RsTemp2
    .Fields.Append "NoKet", adInteger, 4
    .Fields.Append "KodeBarang", adVarChar, 50
    .Fields.Append "NamaBarang", adVarChar, 50
    .Fields.Append "Jumlah", adInteger, 4
    .Fields.Append "HargaBeli", adDouble, 8
    .Fields.Append "BiayaKirim", adDouble, 8
    .Open
End With
End Sub

Sub Bersih()
CmbSupplier = ""
TxtTgl = Null
TxtTglKirim = Null
CmbBarang = ""
TxtJumlah = 0
TxtHarga = 0
TxtKirim = 0
End Sub

Private Sub TxtHarga_GotFocus()
CmbBarang_GotFocus
End Sub

Private Sub TxtJumlah_GotFocus()
CmbBarang_GotFocus
End Sub

Private Sub TxtKirim_GotFocus()
CmbBarang_GotFocus
End Sub

Private Sub vbButton1_Click()
Me.WindowState = vbMinimized
End Sub

Private Sub vbButton2_Click()
Unload Me
End Sub
Function KodeAuto()
'SQL = "Select No_Urut from ServiceMobil order by No_Urut"
'Set RSFind = DbCon.Execute(SQL)
'If Not RSFind.BOF Then
'   KodeAuto = RSFind!no_urut
'   Exit Function
'End If
SQL = "Select KodeTransaksi from BeliBarang order by KodeTransaksi Desc"
Set RSFind = DbCon.Execute(SQL)
If RSFind.BOF Then
    KodeAuto = "0000001"
Else
    KodeAuto = Format(CInt(Left(RSFind!KodeTransaksi, 7)) + 1, "0000000")
End If
End Function

Comments

Popular posts from this blog

Flowchart Penjualan Grosir / Eceran

Flowchart Proses Pembelian Barang