Praktikum 5
Program Aplikasi Bisnis
1. Tambahkan tabel berikut, pada database stockgudang :
2. Buat form CariBarang dengan tampilan sbb :
3. Desainlah Form Input Barang_Masuk seperti di bawah ini :
Imam Gunawan, M. Kom
Praktikum 5
Program Aplikasi Bisnis
Imam Gunawan, M. Kom
4. Buat koding program sebagai berikut : Private Sub cmdbatal_Click() bersihdata cmdtambah.SetFocus cmdsimpan.Enabled = False cmdbatal.Enabled = False End Sub Private Sub cmdcari_Click() caricst.Show txtnoseri.Enabled = True aktifdata End Sub Private Sub cmdkeluar_Click(Index As Integer) Unload Me End Sub Private Sub cmdkoreksi_Click() perintah = "update barangkeluar set tglkeluar='" & tglkeluar.Value & "',kodecst='" & txtkodecst.Text & "',noseri='" & txtnoseri.Text & "' where invoice='" & txtinvoice.Text & "'" varkon.Execute perintah tampildata cmdkoreksi.Enabled = False cmdtambah.Enabled = True cmdtambah.SetFocus bersihdata cmdsimpan.Enabled = False End Sub Private Sub cmdsimpan_Click() varkon.Execute "insert into barangkeluar(invoice,tglkeluar,noseri,kodecst,jml) values " &"('" & txtinvoice.Text & "','" & Format(tglkeluar.Value, "yyyy-mm-dd") & "'," & "'" & txtnoseri.Text & "','" & txtkodecst.Text & "','" & txtjmlh.Text & "')" tampildata cmdsimpan.Enabled = False Dim Pesan As Byte pesan = MsgBox("Masih ada data Yang Sama??", vbYesNo + vbExclamation, "Pesan") If pesan = vbYes Then txtnoseri.Enabled = True txtnoseri.Text = "" txtnoseri.SetFocus cmdbatal.Enabled = True Else bersihdata cmdtambah.Enabled = True cmdtambah.SetFocus cmdsimpan.Enabled = False cmdbatal.Enabled = False End If End Sub
Praktikum 5
Program Aplikasi Bisnis
Imam Gunawan, M. Kom
Sub bersihdata() txtinvoice.Text = "" txtkodecst.Text = "" txtnamadealer.Text = "" txtnoseri.Text = "" txtkodebrg.Text = "" txtnamabrg.Text = "" txtsatuan.Text = "" txthrgjual.Text = "" txtjmlh.Text = "" End Sub Sub aktifdata() txtinvoice.Enabled = True txtnoseri.Enabled = True txtkodecst.Enabled = True tglkeluar.Enabled = True End Sub Sub tidakaktifdata() txtinvoice.Enabled = False tglkeluar.Enabled = False txtnoseri.Enabled = False txtkodecst.Enabled = False End Sub Private Sub cmdtambah_Click() tampildata bersihdata aktifdata txtinvoice.SetFocus cmdbatal.Enabled = True End Sub Private Sub Command1_Click() perintah = "delete from barangkeluar where noseri='" & txtnoseri.Text & "'" varkon.Execute perintah tampildata bersihdata End Sub Private Sub Form_Activate() Set vardat = varkon.Execute("select customer.kodecst,customer.namadealer,barangmasuk.noseri,barang.typebrg,barang.nam a,barang.satuan,barang.hrgjual,barangkeluar.invoice,barangkeluar.tglkeluar " &_ "from barang,customer,barangmasuk,barangkeluar where barangmasuk.noseri=barangkeluar.noseri and barangkeluar.invoice='" & txtinvoice.Text & "' and barangkeluar.tglkeluar='" & Format(tglkeluar.Value, "yyyy-mm-dd") & "' order by barangkeluar.noseri") Set DataGrid1.DataSource = vardat tglkeluar.Value = Now() Set DataGrid1.DataSource = vardat cmdtambah.SetFocus tampildata tidakaktifdata cmdsimpan.Enabled = True cmdbatal.Enabled = False txtjmlh.Text = 1 End Sub
Praktikum 5
Program Aplikasi Bisnis
Imam Gunawan, M. Kom
Sub tampildata() perintah = "select * from barangkeluar" Set vardat = varkon.Execute(perintah) Set DataGrid1.DataSource = vardat End Sub Private Sub Form_Load() panggil End Sub Private Sub TxtCari_Change() Dim rcs As String Select Case Combo1.ListIndex Case 0: rcs = "select * from TxtCari.Text & Case 1: rcs = "select * from TxtCari.Text & End Select Set vardat = varkon.Execute(rcs) Set DataGrid1.DataSource = vardat End Sub
barangkeluar where invoice like '" & "%" & "' order by invoice" barangkeluar where noseri like '" & "%" & "' order by noseri"
Private Sub txtinvoice_Change() perintah = " select * from barangkeluar where invoice='" & txtinvoice.Text & "'" Set vardat = varkon.Execute(perintah) If vardat.RecordCount > 0 Then MsgBox " No Invoice ini sudah Ada...." txtkodecst.Text = vardat!kodecst tidakaktifdata cmdcari.Enabled = False txtkodecst.Enabled = False Else txtkodecst.Text = "" txtnamadealer.Text = "" cmdcari.Enabled = True End If txtjmlh.Text = 1 tampildata End Sub Private Sub txtinvoice_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnoseri.SetFocus End If End Sub Private Sub txtjumlah_Change() cmdsimpan.Enabled = True End Sub
Private Sub txtjml_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then cmdsimpan.Enabled = True cmdsimpan.SetFocus End If End Sub
Praktikum 5
Program Aplikasi Bisnis
Imam Gunawan, M. Kom
Private Sub Txtkodebrg_Change() Set vardat = varkon.Execute("select * from barang where typebrg='" & txtkodebrg.Text & "'") If vardat.RecordCount > 0 Then txtnamabrg.Text = vardat!nama txtsatuan.Text = vardat!satuan txthrgjual.Text = vardat!hrgjual End If Set vardat = varkon.Execute("select * from barangkeluar where noseri ='" & txtnoseri.Text & "'") If vardat.RecordCount > 0 Then txtkodecst.Text = vardat!kodecst End If Set vardat = varkon.Execute("select * from barangkeluar where noseri ='" & txtnoseri.Text & "'") If vardat.RecordCount > 0 Then txtinvoice.Text = vardat!invoice End If End Sub
Private Sub txtkodecst_Change() If Len(txtkodecst.Text) = 5 Then Set vardat = varkon.Execute("select * from customer where kodecst='" & txtkodecst.Text & "'") If vardat.RecordCount > 0 Then txtnamadealer.Text = vardat!namadealer Set DataGrid1.DataSource = vardat End If End If End Sub Private Sub txtkodecst_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnoseri.SetFocus End If End Sub Private Sub txtnoseri_Change() Set vardat = varkon.Execute("select * from barangmasuk where noseri ='" & txtnoseri.Text & "'") If vardat.RecordCount > 0 Then txtkodebrg.Text = vardat!typebrg Set DataGrid1.DataSource = vardat End If txtjmlh.Text = 1 cmdsimpan.Enabled = True tampildata End Sub Private Sub txtnoseri_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then perintah = " select * from barangkeluar where noseri='" & txtnoseri.Text & "'" Set vardat = varkon.Execute(perintah) If vardat.RecordCount > 0 Then MsgBox ("No Seri barang ini telah keluar sebelumnya... ") tglkeluar.Value = vardat!tglkeluar txtnoseri.SetFocus End If Set vardat = varkon.Execute("select * from barangmasuk where noseri ='" & txtnoseri.Text & "'")
Praktikum 5
Program Aplikasi Bisnis
If vardat.RecordCount = 0 Then MsgBox "Maaf No Seri Ini belum Pernah Masuk...." txtnoseri.Text = "" txtkodebrg.Text = "" txtnamabrg.Text = "" txtsatuan.Text = "" txthrgjual.Text = "" txtjmlh.Text = "" txtnoseri.SetFocus End If cmdsimpan.Enabled = True cmdcari.SetFocus End If End Sub
Imam Gunawan, M. Kom