Anda di halaman 1dari 12

Ket :

Kode Barang = Combo1

Text1 = Nama Barang Text3 = Tanggal

Text2 = Harga Text 4 = Kode Transaksi

Text5 = Jumlah Beli

Text6 = Total Bayar

Text7 = Jumlah Bayar

Text8 = Kembalian Text9 = Terbilang

Label4 = Satuan

Private Sub Combo1_Click()

Set brg = dbase.OpenRecordset("select * from tbbarang where kode='" & Combo1 & "'")

Text1 = brg.Fields(1)

Text2 = brg.Fields(3)

Label4 = brg.Fields(2)

End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If Text1 = "" Then

Combo1.SetFocus

Else

edit

End If

End If

End Sub

Private Sub Command1_Click()

Unload Me

Me.Show

End Sub

Sub simpandata()

Dim al As Double

Dim byr

For z = 1 To LV1.ListItems.Count

Set brg = dbase.OpenRecordset("select * from tbbarang where kode= '" &


LV1.ListItems(z).SubItems(3) & "'")

al = brg!jumlah

byr = al - LV1.ListItems(z).SubItems(5)
dbase.Execute "insert into tbjual values ( '" & LV1.ListItems(z).SubItems(2) & "', '" &
LV1.ListItems(z).SubItems(1) & "'," & _

" '" & Text6 & "')"

dbase.Execute "insert into tbdetjual values('" & LV1.ListItems(z).SubItems(2) & "','" &
LV1.ListItems(z).SubItems(1) & " ', " & _

" '" & LV1.ListItems(z).SubItems(3) & "','" & LV1.ListItems(z).SubItems(5) & "')"

'update data barang

dbase.Execute "update tbbarang set jumlah = '" & byr & "' where kode = '" &
LV1.ListItems(z).SubItems(3) & "' "

Next z

End Sub

Private Sub Command2_Click()

simpandata

Command3.Enabled = True

Command3.SetFocus

End Sub

Private Sub Command3_Click()

cetakdata

Command1.SetFocus

End Sub

Private Sub Command4_Click()

Unload Me
End Sub

Private Sub Form_Activate()

Combo1.SetFocus

End Sub

Private Sub Form_Load()

koneksi

Me.Caption = "Transaksi Penjualan Barang"

tengah Me

Text3 = Format(Date, "dd/mm/yyyy")

Otomasi

pilihbrg

vedit = False

End Sub

Sub Otomasi()

Dim NO

Set trs = dbase.OpenRecordset("select Kode from Tbjual")

If trs.EOF Then

Text4 = "TRS" + "00001"

Else

trs.MoveLast

If Mid(Trim(trs.Fields(0)), 4, 8) Then

NO = Trim(trs.Fields(0))

NO = Right(NO, 5)

NO = Val(NO) + 1
NO = Str(NO)

NO = Trim(NO)

NO = Left("00000", 5 - Len(NO)) + NO

Text4 = "TRS" + NO

Else

Text4 = "TRS" + "00001"

End If

End If

End Sub

Sub pilihbrg()

Do While Not brg.BOF And Not brg.EOF

If Not brg.EOF Then

Combo1.AddItem brg.Fields(0)

brg.MoveNext

End If

Loop

End Sub

Private Sub Text2_Change()

On Error Resume Next

Text2 = FormatNumber$(Text2, 0)

End Sub

Sub hitung()

pesan = MsgBox("Apakah ada lagi data yang akan ditambahkan", vbYesNo + vbQuestion, "Konfirmasi
")

If pesan = vbYes Then

'Combo1.SetFocus
Text7.Text = Text5 * Text2

Text6 = Val(Text6) + Str(Text7)

isigrid

kosong

Else

Text8.SetFocus

Text7.Text = Text5 * Text2

Text6 = Val(Text6) + Str(Text7)

isigrid

End If

End Sub

Sub valid()

Set brg = dbase.OpenRecordset("select kode, jumlah from tbbarang where kode = '" & Combo1 & "'
")

Dim a As Double

Dim cek As Double

a = brg!jumlah

cek = a - Text5

If (cek < 0) Then

MsgBox "Jumlah barang Kurang (Tidak Cukup)..." & Chr$(13) & "jumlah barang = " & a & "",
vbInformation + vbOKOnly, "...:: Info Stok Kurang :::..."

Text5 = ""

Combo1.SetFocus

Else

hitung

End If

End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

If Not IsNumeric(Text5) Then

MsgBox "Harus Diisi angka", , "Konfirmasi"

Text5 = ""

Text5.SetFocus

Else

'hitung

valid

End If

End If

End Sub

Sub isigrid()

Set butir = LV1.ListItems.Add(, , LV1.ListItems.Count + 1 & ".")

With butir

.SubItems(1) = Text3.Text

.SubItems(2) = Text4.Text

.SubItems(3) = Combo1.Text

.SubItems(4) = Text1.Text

.SubItems(5) = Text5.Text

.SubItems(6) = Text7.Text

End With

End Sub

Private Sub Text6_Change()

On Error Resume Next


If Text6 <> "" Then

Text9 = Num2Word(Text6) + " Rupiah"

Else

Text9 = ""

End If

End Sub

'Private Sub Text7_Change()

'On Error Resume Next

'Text7 = FormatNumber$(Text7, 0)

'End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Text8 = Val(Text7) - Val(Text6)

Command2.Enabled = True

Command2.SetFocus

End If

End Sub

Sub kosong()

Combo1 = ""

Text1 = ""

Text2 = ""

Text5 = ""

Text7 = ""

Combo1.SetFocus
End Sub

Sub edit()

For i = 1 To LV1.ListItems.Count

If Combo1.Text = LV1.ListItems(i).SubItems(3) Then

MsgBox "Data Barang Sudah Diinput", vbExclamation, "Ooops..."

Combo1 = ""

Combo1.SetFocus

Exit Sub

Else

End If

Next

Text5.SetFocus

End Sub

Sub cetakdata()

Dim mno, mhal, mbaris As Integer

Dim i, n As Integer

Dim mgrs, mgrss As String

Printer.Print "";

Printer.Print "";

Printer.Font = "Verdana"

Printer.ForeColor = &H0&

Printer.FontSize = 6

Printer.FontBold = False

Printer.CurrentX = 0

Printer.CurrentY = 0

mno = 0
mhal = 0

i=1

Do While i <= LV1.ListItems.Count

mbaris = 1

mhal = mhal + 1

Printer.Print ; " "

Printer.Print ; " "

Printer.Print ; " "

Printer.Print Tab(4); 'Form8.Caption;

Printer.FontBold = False

Printer.FontSize = 7

Printer.Print Tab(5); "Penjualan Barang"

Printer.Print ; " "

Printer.Print Tab(5); "Tanggal";

Printer.Print Tab(25); ":"; Text3.Text;

Printer.Print Tab(5); "No Bukti";

Printer.Print Tab(25); ":"; Text4.Text;

Printer.FontBold = False

Printer.Print ; " "

Printer.Print ; " "

mgrs = String$(65, "=")

mgrss = String$(80, "-")

Printer.Print Tab(5); mgrss

Printer.FontBold = False

Printer.Print Tab(5); "Kode Barang";

Printer.Print Tab(25); "Nama Barang";

Printer.Print Tab(55); "Jlh Beli";


Printer.Print Tab(65); "Jumlah";

'Printer.Print Tab(65); "Jumlah";

Printer.FontBold = False

Printer.Print Tab(5); mgrss

mbaris = 0

Do While i <= LV1.ListItems.Count And mbaris < 60

Set itm = LV1.ListItems.Item(i)

mno = mno + 1

Printer.Print Tab(5); itm.SubItems(3);

Printer.Print Tab(25); itm.SubItems(4);

Printer.Print Tab(55); itm.SubItems(5);

Printer.Print Tab(65); itm.SubItems(6);

mbaris = mbaris + 1

i=i+1

Loop

Printer.Print Tab(5); mgrss

'Printer.Print ; " "

'Printer.FontSize = 8

'Printer.FontBold = fale

'Printer.Print Tab(4); mgrss

'Printer.Print ; " "

'Printer.FontSize = 8

'Printer.FontBold = False

'Printer.Print Tab(5); mgrss

Printer.Print Tab(25); "Total Bayar";


Printer.Print Tab(55); Text6.Text;

Printer.Print ; " "

Printer.Print ; " "

Printer.Print Tab(5); "Tanggal Cetak ";

Printer.FontBold = False

Printer.FontItalic = True

Printer.Print Tab(25); ":"; Format(Now, "dd/mm/yyyy");

If mbaris >= 30 Then

Printer.NewPage

End If

Loop

Printer.EndDoc

End Sub