Dim baris As Integer
Sub kosong()
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
Text13.Text = ""
End Sub
Sub no()
Dim no As String
If rs_keluar.BOF Then
Text1.Text = "TR-1903100"
Exit Sub
Else
rs_keluar.Requery
If Not (rs_keluar.EOF Or rs_keluar.BOF) Then
rs_keluar.MoveLast
End If
no = rs_keluar!KODE_PENGELUARAN
no = Val(Right(no, 3))
no = no + 1
End If
If Val(no) < 10 Then
no = "TR-190310" & no
Text1.Text = no
ElseIf Val(no) < 100 Then
no = "TR-19031" & no
Text1.Text = no
ElseIf Val(no) < 1000 Then
no = "TR-1903" & no
Text1.Text = no
ElseIf Val(no) < 10000 Then
no = "TR-190" & no
Text1.Text = no
Else
End If
End Sub
Sub jual()
'baris = 1
With GridPenjualan
.Col = 0
.Row = 0
.Text = "Kode Barang"
.ColWidth(0) = 2000
.Col = 1
.Row = 0
.Text = "Nama Barang"
.ColWidth(1) = 2000
.Col = 2
.Row = 0
.Text = "Harga Barang"
.ColWidth(2) = 2000
.Col = 3
.Row = 0
.Text = "Jumlah Beli"
.ColWidth(3) = 2000
.Col = 4
.Row = 0
.Text = "Bayar"
.ColWidth(4) = 2000
End With
End Sub
Private Sub Form_Activate()
Call jual
Text2.Text = Date
End Sub
Private Sub Form_Load()
opendb
End Sub
Private Sub OsenVistaButton1_Click()
On Error Resume Next
If Val(Text9.Text) > Val(Text8.Text) Then
MsgBox "Stok Tidak Mencukupi!!!", vbCritical, "Error!"
Else
With GridPenjualan
.Rows = baris + 1
.TextMatrix(baris, 0) = Text5.Text
.TextMatrix(baris, 1) = Text6.Text
.TextMatrix(baris, 2) = Text7.Text
.TextMatrix(baris, 3) = Text9.Text
.TextMatrix(baris, 4) = Text10.Text
End With
Text11.Text = Val(Text10.Text) + Val(Text11.Text)
baris = baris + 1
End If
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
End Sub
Private Sub Text13_Change()
Text12.Text = Val(Text13.Text) - Val(Text11.Text)
End Sub
Private Sub Text9_Change()
Text10.Text = Val(Text7.Text) * Val(Text9.Text)
End Sub
Private Sub XPButton1_Click()
frmtampilpelanggan.Show
End Sub
Private Sub XPButton2_Click()
frmtampilbarang.Show
End Sub
Private Sub XPButton3_Click()
Call no
baris = 1
XPButton3.Enabled = False
XPButton4.Enabled = True
XPButton5.Enabled = True
End Sub
Private Sub XPButton4_Click()
sqlInsert = ""
sqlInsert = "insert into keluar" _
& " (KODE_PENGELUARAN,TGL_KELUAR,KODE_CUST) " _
& " values('" & Text1.Text & "','" _
& Format(Text2.Text, "yyyy/dd/mm") & "','" _
& Text3.Text & "')"
conn.Execute sqlInsert, , adCmdText
rs_keluar.Requery
For i = 1 To baris - 1
sqlInsert = ""
sqlInsert = "insert into DET_KELUAR " _
& " (KODE_PENGELUARAN,KODE_BARANG," _
& " JUMLAH_KELUAR,BAYAR) " _
& " values('" & Text1.Text & "','" _
& GridPenjualan.TextMatrix(i, 0) & "','" _
& GridPenjualan.TextMatrix(i, 3) & "','" _
& GridPenjualan.TextMatrix(i, 4) & "')"
conn.Execute sqlInsert, , adCmdText
sqlUpdate = ""
sqlUpdate = "update BARANG SET " _
& "STOCK=STOCK- " _
& Val(GridPenjualan.TextMatrix(i, 3)) & "" _
& " where KODE_BARANG='" _
& GridPenjualan.TextMatrix(i, 0) & "'"
conn.Execute sqlUpdate, , adCmdText
Next i
MsgBox "data telah berhasil disimpan!", vbInformation, "informasi"
FmPreviewPenjualan.Show
FmPreviewPenjualan.Text1.Text = Text1.Text
baris = 1
GridPenjualan.Clear
GridPenjualan.Rows = 2
Call jual
Call kosong
XPButton4.Enabled = False
XPButton3.Enabled = True
XPButton5.Enabled = False
End Sub
Private Sub XPButton5_Click()
If MsgBox("yakin nih mau dihapus??", vbExclamation + vbYesNo, "Hapus") = vbYes Then
With GridPenjualan
.RemoveItem (.Row)
End With
End If
Text11.Text = Val(Text11.Text) - Val(Text10.Text)
baris = baris - 1
End Sub
Private Sub XPButton7_Click()
Nom = 1
Sw = 1
FmPreviewPenjualan.Show
Call CetakLayar
End Sub
Tidak ada komentar:
Posting Komentar