Dim AMBILSTOK As
Boolean
Sub nomor()
adotransaksi.Refresh
If
adotransaksi.Recordset.RecordCount = 0 Then
NO =
Format(Date, "yymm") & "00001"
ElseIf
Mid(adotransaksi.Recordset!NOTRANSAKSI, 3, 4) <> Format(Date,
"yymm") Then
NO =
Format(Date, "yymm") & "00001"
Else
adotransaksi.Recordset.Sort
= "notransaksi ASC"
adotransaksi.Recordset.MoveLast
NO =
Val(Right(adotransaksi.Recordset!NOTRANSAKSI,
Len(adotransaksi.Recordset!NOTRANSAKSI) - 6)) + 1
End If
txtnotrans.Text
= "TR" + Format(Date, "yymm") + Right("00000"
& NO, 5)
End Sub
Sub
SIMPANTRANSAKSI()
With
adotransaksi.Recordset
adotransaksi.Refresh
.AddNew
!NOTRANSAKSI =
txtnotrans.Text
!TGLJUAL =
txttgl.Text
!TOTALBAYAR =
txttotal.Text
!KODEUSER =
txtkduser.Text
.Update
End With
End Sub
Sub SIMPANTEMP()
ADOTEMP.Refresh
With
ADOTEMP.Recordset
.AddNew
!kodebarang =
txtkobar.Text
!NMBRG =
txtnabar.Text
!HRG =
txtharga.Text
!QTY =
txtjmhjual.Text
!subttl =
txtsubtotal.Text
.Update
End With
End Sub
Sub
simpandetail()
Dim simpan, fak,
kdbrg As String
Dim jumlahjual
As Integer
Dim subttl As
Double
For a = 1 To
(GRID.Rows - 1)
fak =
txtnotrans.Text
kdbrg =
GRID.TextMatrix(a, 1) 'kdbrg berada di kolom 1
jumlahjual =
GRID.TextMatrix(a, 4) 'jmhjual berada di kolom 4
subttl =
GRID.TextMatrix(a, 5) 'subtotal berada di kolom 5
'variabel
fak,kdbrg,jmhjual,subttl utk data masukanke tabel detailjual
adodetail.Refresh
With
adodetail.Recordset
.AddNew
!NOTRANSAKSI =
fak
!jmhjual =
jumlahjual
!subtotal =
subttl
!kodebarang =
kdbrg
.Update
End With
Next a
End Sub
Sub tampilgrid()
'buka tabel
barang
ADOTEMP.RecordSource
= "select * from TEMP order by kodebarang"
'atur grid utk
tabel TEMP
Set
GRID.DataSource = ADOTEMP
GRID.ColWidth(0)
= 50
GRID.TextMatrix(0,
1) = "Kode Barang"
GRID.ColWidth(1)
= 1000
GRID.TextMatrix(0,
2) = "Nama Barang"
GRID.ColWidth(2)
= 1300
GRID.TextMatrix(0,
3) = "HARGA "
GRID.ColWidth(3)
= 1300
GRID.TextMatrix(0,
4) = "Jumlah Jual"
GRID.ColWidth(4)
= 1000
GRID.TextMatrix(0,
5) = "Subtotal"
GRID.ColWidth(5)
= 1000
End Sub
Private Sub
CMDBATAL_Click()
AMBILSTOK =
False
ADOTEMP.Refresh
ADOTEMP.Recordset.Delete
End Sub
Private Sub
cmdinput_Click()
Call nomor
txttgl =
Format(Date, "DD/MM/YYYY")
AMBILSTOK = True
txtkobar.SetFocus
End Sub
Private Sub
CMDSIMPAN_Click()
Call
SIMPANTRANSAKSI
Call simpandetail
Call HAPUSTEMP
End Sub
Sub HAPUSTEMP()
ADOTEMP.Refresh
If
ADOTEMP.Recordset.RecordCount <> 0 Then
Do While Not
ADOTEMP.Recordset.EOF
ADOTEMP.Recordset.Delete
ADOTEMP.Recordset.MoveFirst
Loop
End If
ADOTEMP.Refresh
GRID.Refresh
End Sub
Private Sub
Form_Activate()
Call HAPUSTEMP
End Sub
Private Sub
Form_Load()
AMBILSTOK = True
Call HAPUSTEMP
ADOTEMP.Refresh
GRID.Refresh
End Sub
Private Sub
txtjmhjual_KeyPress(KeyAscii As Integer)
If KeyAscii = 13
Then
adobarang.Refresh
adobarang.Recordset.Find
"KODEBARANG='" & txtkobar.Text & "'"
If
Val(txtjmhjual.Text) > txtstok.Text Then
MsgBox
"stok kurang"
txtjmhjual.SetFocus
Exit Sub
Else
txtsubtotal.Text
= Val(txtjmhjual) * Val(txtharga)
Call ubahstok
Call SIMPANTEMP
ADOTEMP.Refresh
GRID.Refresh
ttl = 0
For a = 1 To
(GRID.Rows - 1)
x =
Val(GRID.TextMatrix(a, 5))
ttl = ttl + x
Next a
txttotal.Text =
ttl
t =
MsgBox("beli lagi?", vbQuestion + vbYesNo, "Konfirmasi")
If t = vbYes
Then
txtkobar =
""
txtkobar.SetFocus
txtnabar =
""
txtharga =
""
txtjmhjual =
""
txtsubtotal =
""
Else
Me.Refresh
GRID.Refresh
txtubay.SetFocus
End If
End If
End If
End Sub
Sub ubahstok()
adobarang.Refresh
With
adobarang.Recordset
.Find
"KODEBARANG='" & txtkobar.Text & "'"
If AMBILSTOK =
True Then
!stok = !stok -
Val(txtjmhjual.Text)
.Update
ElseIf AMBILSTOK
= False Then
!stok = !stok +
Val(txtjmhjual.Text)
.Update
End If
End With
End Sub
Private Sub
txtkobar_KeyPress(KeyAscii As Integer)
KeyAscii =
Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13
Then
adobarang.Refresh
With adobarang.Recordset
.Find
"KODEBARANG='" & txtkobar.Text & "'"
If .EOF Then
MsgBox
"KODE BARANG TIDAK ADA"
txtkobar.SetFocus
Exit Sub
Else
txtnabar =
!NAMABARANG
txtharga =
adobarang.Recordset!HARGA
txtstok =
adobarang.Recordset!stok
txtjmhjual.SetFocus
End If
End With
End If
End Sub