0% found this document useful (0 votes)
37 views18 pages

Visual 1 Kode

Uploaded by

Dellsi Nanik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views18 pages

Visual 1 Kode

Uploaded by

Dellsi Nanik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

FORM BARANG

Private Sub tampil()

On Error Resume Next

tkode.Text = Adodc1.Recordset!kdbrg

tnama.Text = Adodc1.Recordset!nmbrg

tharga.Text = Adodc1.Recordset!harga

tsatuan.Text = Adodc1.Recordset!satuan

cmdsimpan.Caption = "&Update"

cmdkeluar.Caption = "&Batal"

On Error GoTo 0

End Sub

Public Sub kosong()

tkode.Text = ""

tnama.Text = ""

tharga.Text = ""

tsatuan.Text = ""

Call kodebrg

cmdkeluar.Caption = "&Exit"

cmdsimpan.Caption = "&Save"

End Sub

Private Sub kodebrg()

Dim kdbrg As Integer

If Adodc1.Recordset.RecordCount = 0 Then

tkode.Text = "B000"

Else

Adodc1.Recordset.MoveLast

kdbrg = Right(Adodc1.Recordset![kdbrg], 3) + 1
tkode.Text = Format(kdbrg, "B000")

End If

End Sub

Private Sub cmdbaru_Click()

Call kosong

Me.tkode.SetFocus

End Sub

Private Sub cmdedit_Click()

Call tampil

End Sub

Private Sub cmdhapus_Click()

If tnama.Text = "" Or tharga.Text = "" Or tsatuan.Text = "" Then

MsgBox "Tidak ada data", vbInformation, "Informasi"

tnama.SetFocus

Else

konfirmasi = MsgBox("Anda yakin hapus data??", vbYesNo + vbInformation, "Konfirmasi")

If konfirmasi = vbYes Then

Adodc1.Recordset.Delete

Call kosong

MsgBox "Data berhasil dihapus", vbInformation, "Info hapus data"

tnama.SetFocus

End If

End If
End Sub

Private Sub cmdkeluar_Click()

If cmdkeluar.Caption = "&Batal" Then

Adodc1.Recordset.Cancel

Call kosong

cmdbaru.SetFocus

Else

konfirmasi = MsgBox("Yakin anda ingin keluar???", vbYesNo + vbInformation, "Informasi")

If konfirmasi = vbYes Then

FormBarang.Hide

MenuUtama.Show

Else

cmdbaru.SetFocus

End If

End If

End Sub

Private Sub cmdsimpan_Click()

With Adodc1.Recordset

.Find "kdbrg='" & tkode.Text & "'", , adSearchForward

If tkode.Text = "" Or tnama = "" Or tharga = "" Or tsatuan = "" Then

MsgBox "Data barang belum lengkap", vbInformation, "Informasi"

tnama.SetFocus

Else

If cmdsimpan.Caption = "&Save" Then

If Not .EOF Then

MsgBox "Kode barang yang anda inputkan sudah ada", vbCritical, "Dobel Input"
.Requery

Call kosong

tnama.SetFocus

Else

.AddNew

.Fields(0) = tkode.Text

.Fields(1) = tnama.Text

.Fields(2) = tharga.Text

.Fields(3) = tsatuan.Text

.Save

MsgBox "Data berhasil disimpan", vbInformation, "Konfirmasi"

Call kosong

tnama.SetFocus

End If

Else

.Fields(0) = tkode.Text

.Fields(1) = tnama.Text

.Fields(2) = tharga.Text

.Fields(3) = tsatuan.Text

.Update

MsgBox "Data berhasil diupdate", vbInformation, "Konfirmasi"

Call kosong

tnama.SetFocus

End If

End If

End With

End Sub
Private Sub Form_Load()

Call kodebrg

End Sub

Private Sub nfirst_Click()

Adodc1.Recordset.MoveFirst

Call tampil

End Sub

Private Sub nlast_Click()

Adodc1.Recordset.MoveLast

Call tampil

End Sub

Private Sub nnext_Click()

Adodc1.Recordset.MoveNext

If Adodc1.Recordset.EOF Then

MsgBox "record akhir", vbInformation, "Last record"

Adodc1.Recordset.MoveLast

End If

Call tampil

End Sub

Private Sub nprev_Click()

Adodc1.Recordset.MovePrevious

If Adodc1.Recordset.BOF Then

MsgBox "Record pertama", vbInformation, "First record"

Adodc1.Recordset.MoveFirst
Adodc1.Recordset.MoveLast

End If

Call tampil

End Sub

FORM CUSTOMER

Private Sub Form_Load()

Call kosong

fcari.Visible = False

gridcust.Visible = False

End Sub

Private Sub tampil()

On Error Resume Next

tkode.Text = Addcus.Recordset!kscust

tnama.Text = Addcus.Recordset!nmcust

ttelepeon = Addcus.Recordset!tlpn

talamat = Addcus.Recordset!alamat

cmdsimpan.Caption = "&Update"

cmdkeluar.Caption = "&Exit"

On Error GoTo 0

End Sub

Public Sub kosong()

tkode.Text = ""

tnama.Text = ""

ttelepon.Text = ""

talamat.Text = ""
Call kodecust

cmdkeluar.Caption = "&Exit"

cmdsimpan.Caption = "&Save"

End Sub

Private Sub kodecust()

Dim kdcst As Integer

If Addcus.Recordset.RecordCount = 0 Then

tkode.Text = "K001"

Else

Addcus.Recordset.MoveLast

kdcst = Right(Addcus.Recordset![kdcust], 3) + 1

tkode.Text = Format(kdcst, "K000")

End If

End Sub

Private Sub cmdbaru_Click()

Call kosong

tnama.SetFocus

End Sub

Private Sub cmdcari_Click()

With Addcus

.CommandType = adCmdText

.RecordSource = "select*from pembeli where nmcust like'%" & tpencarian.Text & "%'"

.Refresh

End With

End Sub
Private Sub cmdedit_Click()

Call tampil

End Sub

Private Sub cmdfcari_Click()

fcari.Visible = True

gridcust.Visible = True

finput.Visible = False

End Sub

Private Sub cmdfinput_Click()

fcari.Visible = False

gridcust.Visible = False

finput.Visible = True

End Sub

Private Sub cmdhapus_Click()

If tkode.Text = "" Or tnama = "" Or ttelepon = "" Or talamat = "" Then

MsgBox "Tidak ada data", vbInformation, "konfirmasi"

tnama.SetFocus

Else

konfirmasi = MsgBox("Yakin hapus data??", vbYesNo + vbInformation, "konfirmasi")

If konfirmasi = vbYes Then

Addcus.Recordset.Delete

Call kosong
MsgBox "Data berhasil dihapus", vbInformation, "Info hapus data"

tnama.SetFocus

Addcus.Refresh

Else

tnama.SetFocus

End If

End If

End Sub

Private Sub cmdkeluar_Click()

If cmdkeluar.Caption = "&Keluar" Then

Addcus.Recordset.Cancel

Call kosong

cmdbaru.SetFocus

Else

konfirmasi = MsgBox("Yakin anda ingin keluar??", vbYesNo + vbInformation, "Informasi")

If konfimasi = vbYes Then

FormCustomer.Hide

MenuUtama.Show

Else

cmdbaru.SetFocus

End If

End If

End Sub

Private Sub cmdsimpan_Click()

With Addcus.Recordset
.Find "Kdcust='" & tkode.Text & "'", , adSearchForward

If tkode.Text = "" Or tnama = "" Or ttelepon = "" Or talamat = "" Then

MsgBox "Data customer belum lengkap", vbInformation, "Informasi"

tnama.SetFocus

Else

If cmdsimpan.Caption = "&Save" Then

If Not .EOF Then

MsgBox "Kode customer yang anda inputkan sudah ada", vbCritical, "Dobel Input"

.Requery

Call kosong

tnama.SetFocus

Else

.AddNew

.Fields(0) = tkode.Text

.Fields(1) = tnama.Text

.Fields(2) = ttelepon.Text

.Fields(3) = talamat.Text

.Save

MsgBox "Data berhasil disimpan", vbInformation, "konfirmasi"

Call kosong

tnama.SetFocus

End If

Else

.AddNew

.Fields(0) = tkode.Text

.Fields(1) = tnama.Text

.Fields(2) = ttelepon.Text

.Fields(3) = talamat.Text
.Update

MsgBox "Data berhasil di update", vbInformation, "konfirmasi"

Call kosong

tnama.SetFocus

End If

End If

End With

End Sub

Private Sub nfirst_Click()

Addcus.Recordset.MoveFirst

Call tampil

End Sub

Private Sub nlast_Click()

Addcus.Recordset.MoveLast

Call tampil

End Sub

Private Sub nnext_Click()

Addcus.Recordset.MoveNext

If Addcus.Recordset.EOF Then

MsgBox "Record akhir", vbInformation, "Last record"

Addcus.Recordset.MoveLast

End If

Call tampil
End Sub

Private Sub nprev_Click()

Addcus.Recordset.MovePrevious

If Addcus.Recordset.BOF Then

MsgBox "Record pertama", vbInformation, "First record"

Addcus.Recordset.MoveFirst

End If

Call tampil

End Sub

End Sub

FORM TRANSAKSI

Public hargasat As Currency

Public totalbrg As Currency

Private Sub kosong()

cmbkdcust.Text = "Pili--"

tnama.Text = ""

talamat.Text = ""

ttelepon.Text = ""

cmbkdbarang.Text = "Pilih--"

tbarang.Text = ""

tharga.Text = ""

tjumlah.Text = ""
ttotal.Text = ""

tbayar.Text = ""

tkembali.Text = ""

Call nomortrans

cmbkdcust.Enabled = True

cmbkdbarang.Enabled = True

End Sub

Private Sub nomortrans()

Dim trans As Integer

ttanggal.Text = Format(Date, "dd-mm-yyyy")

If Addtransaksi.Recordset.RecordCount = 0 Then

tnotrans.Text = "TR001"

Else

Addtransaksi.Recordset.MoveLast

trans = Right(Addtransaksi.Recordset![notrans], 3) + 1

tnotrans.Text = Format(trans, "TR000")

End If

End Sub

Private Sub listcust()

With Addcus

.CommandType = adCmdText

.RecordSource = "select*from pembeli"

.Refresh

Do Until .Recordset.EOF

cmbkdcust.AddItem .Recordset!kdcust

.Recordset.MoveNext

Loop

End With
End Sub

Private Sub listbarang()

With Addbarang

.CommandType = adCmdText

.RecordSource = "select*from barang "

.Refresh

Do Until .Recordset.EOF

cmbkdbarang.AddItem .Recordset!kdbarang

.Recordset.MoveNext

Loop

End With

End Sub

Private Sub cmbkdbarang_Click()

With Addcus

.CommandType = adCmdText

.RecordSource = "select*from barang where kdbarang='" & cmbkdbarang.Text & "'"

.Refresh

If .Recordset.EOF And .Recordset.BOF Then

MsgBox "Kode Barang tidak ada", vbCritical, "Error"

cmbkdbarang.Tex = ""

Me.cmbkdbarang.SetFocus

Else

cmbkdbarang.Text = .Recordset!kdbarang

tbarang.Text = .Recordset!nmbarang

hargasat = .Recordset!harga

tharga.Text = "Rp " & Format(Val(hargasat), "#,##0")


Me.tjumlah.Enabled = True

Me.tjumlah.SetFocus

End If

End With

End Sub

Private Sub cmbkdcust_Click()

With Addcus

.CommandType = adCmdText

.RecordSource = "select*from pembeli where kdcust='" & cmbkdcust.Text & "'"

.Refresh

If .Recordset.EOF And .Recordset.BOF Then

MsgBox "Kode customer tidak ada", vbCritical, "Error"

cmbkdcust.Text = ""

Me.cmbkdcust.SetFocus

Else

cmbkdcust.Text = .Recordset!kdcust

tnama.Text = .Recordset!nmcust

talamat.Text = .Recordset!alamat

ttelepon.Text = .Recordset!telpon

End If

End With

End Sub

Private Sub cmdbaru_Click()

Call kosong

cmdkeluar.Caption = "&Batal"
End Sub

Private Sub cmdkeluar_Click()

If cmdkeluar.Caption = "& Batal" Then

Addtransaksi.Recordset.Cancel

Call kosong

Call disable

cmdkeluar.Caption = "&Exit"

cmdbaru.SetFocus

Else

if MsgBox("yakin anda ingin keluar??",vbYesNo + vbDefaultButton2 + vbQuestion,"Konfirmas

End Sub

Private Sub cmdsimpan_Click()

With Addtransaksi.Recordset

If tnotrans.Text = "" Or ttanggal = "" Or cmbkdcust = "" Or cmbkdbarang = "" Or tayar = "" Then

MsgBox "Data transaksi belum lengkap", vbInformation, "Informasi"

cmdbaru.SetFocus

Else

.AddNew

.Fields(0) = Me.tnotrans.Text

.Fields(1) = Me.ttanggal.Text

.Fields(2) = Me.cmbkdcust.Text

.Fields(3) = Me.cmbkdbarang.Text

.Fields(4) = Me.tjumlah.Text
.Fields(5) = Me.totalbrg

.Save

MsgBox "Data erhasil disimpan", vbInformation, "sukses"

Call kosong

Call disable

End If

End With

End Sub

Private Sub Form_Load()

Call kosong

Call listcust

Call listbarang

cmdkeluar.Caption = "&Batal"

End Sub

Private Sub tbayar_KeyPress(keyascii As Integer)

Dim kembalian As Currency

If keyascii = 13 Then

kembalian = Val(tbayar.Text) - Val(totalbrg)

tkembali.Text = "Rp" & Format(Val(kembalian), "#,##0")

Me.cmdsimpan.SetFocus

End If

End Sub

Private Sub tjumlah_Keypress(keyascii As Integer)

If keyascii = 13 Then

totalbrg = Val(hargasat) * Val(tjumlah.Text)

ttotal.Text = "Rp" & Format(Val(totalbrg), "#,##0")

Me.tbayar.Enabled = True
Me.tbayar.SetFocus

End If

End Sub

Private Sub Timer1_Timer()

Timer1.Enabled = True

Timer1.Interval = 300

End Sub

You might also like