Punya Account Blogger?
Posted by Sofyan SOX on Selasa, 25 Mei 2010 in
Assalamu ' alaikum semuanya ...

maaf nih uploadnya agak agak telat ...

maklum liat futsal dulu di MJR ... ...

okelah klo bgitu

kita liat Modulnya ::




Download Here  |  Modul  File Latihan




Jangan lupa yach bikin database dan tabelnya dulu ...

pake Visual data Manager yach





















baca aja modul diatas ....






















Jangan lupa tambahin componen yang dibutuhkan ...


'Selamat datang di studi kasus
'visual basic lab B bsi bogor

'dibawah ini adalah listing lengkapnya
 

'1. Ingat 5 prosedur sebelum 5 prosedur......
'hehehe   kaya lagu raihan ....

'kondisi edit atau tambah data

Dim edit As Boolean

'1.A  Membersihkan Teks

Sub kosong()
  tkode = ""
  tmerk = ""
  tjenis = ""
  tharga = ""
  tstok = ""
End Sub

'1.B Menonaktifkan Teks

Sub mati()
  tkode.Enabled = 0
  tmerk.Enabled = 0
  tjenis.Enabled = 0
  tharga.Enabled = 0
  tstok.Enabled = 0
End Sub

'1.C Mengaktifkan Teks

Sub hidup()
  tkode.Enabled = 1
  tmerk.Enabled = 1
  tjenis.Enabled = 1
  tharga.Enabled = 1
  tstok.Enabled = 1
End Sub

'1.D Menampilkan isi table

Sub tampil()
'jika error maka lanjutkan perjuanganmu
  On Error Resume Next
  With Dmotor.Recordset
    tkode.Text = !kdmotor
    tmerk.Text = !merk
    tjenis.Text = !jenis
    tharga.Text = !harga
    tstok.Text = !stok
  End With
End Sub

'1.E Mengisi Table sesuai Textbox

Sub simpan()
  With Dmotor.Recordset
    !kdmotor = tkode
    !merk = tmerk
    !jenis = tjenis
    !harga = Val(tharga)
    !stok = Val(tstok)
  End With
End Sub



'2. Kondisi Form ketika dijalankan

Private Sub Form_Activate()
   kosong
   mati
   cadd.SetFocus
End Sub

'koneksi ke database

Private Sub Form_Load()
   Dmotor.DatabaseName = App.Path & "\DbMotor.Mdb"
End Sub

'3. Ketika Tombol Add di klik
'   kursor terletak di kode Motor

Private Sub cadd_Click()
  Select Case cadd.Caption
   Case "&Add": cadd.Caption = "&Cancel"
     edit = 0
     hidup
     kosong
     tkode.SetFocus
   Case "&Cancel": cadd.Caption = "&Add"
     kosong
     mati
     cadd.SetFocus
  End Select
End Sub

'4. Pencarian berdasarkan kode motor

'cocokan teks di kode motor dengan tabel motor
'klo cocok, muncul pesan "Kode Motor Sudah Ada "
'klo kode motor belum ada......!!!!
'maka merk dan harga akan muncul

'sampel kode motor  " Y1001 "
'Merk motor diambil dari 1 karakter dari kiri
'Jenis Motor diambil dari karakter kedua dari kiri

'jika "Y" maka "Yamaha"
'jika "H" maka "Honda"
'jika "S" maka "Suzuki"

'jika "1" maka "Kopling"
'jika "2" maka "Bebek"
'jika "3" maka "Matic"


Private Sub tkode_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
     'cari di tabel
     Dmotor.Recordset.Index = "idxmotor"
     Dmotor.Recordset.Seek "=", tkode.Text
     'jika ketemu kode motornya
     If Dmotor.Recordset.NoMatch = False Then
        'Muncul pesan klo kode sudah ada
        MsgBox "Kode Motor sudah ada"
        tkode.Text = "": tkode.SetFocus
     Else
   
        'klo kode belum ada di tabel
       
        'munculkan Merk Motor
        Select Case Left(tkode.Text, 1)
          Case "y", "Y": tmerk.Text = "Yamaha"
          Case "h", "H": tmerk.Text = "Honda"
          Case Else: tmerk.Text = "Suzuki"
        End Select
       
        'munculkan jenis motor
        Select Case Mid(tkode.Text, 2, 1)
          Case "1": tjenis.Text = "Kopling"
          Case "2": tjenis.Text = "Bebek"
          Case Else: tjenis.Text = "Matic"
        End Select
       
        tharga.SetFocus
     End If
  End If
End Sub


Private Sub tharga_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    tstok.SetFocus
  End If
End Sub

Private Sub tstok_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    cupdate.SetFocus
  End If
End Sub

'5. Proses Penyimpanan Data

Private Sub cupdate_Click()

 If edit = 0 Then
  Dmotor.Recordset.AddNew
 Else
  Dmotor.Recordset.edit
 End If

    simpan
  Dmotor.Recordset.Update
    MsgBox "Data Tersimpan"
    kosong
    mati
End Sub

'6. Proses Edit Data

Private Sub cedit_Click()
  cari = InputBox("Masukan Kode ")
    Dmotor.Recordset.Index = "idxmotor"
    Dmotor.Recordset.Seek "=", cari
 
  If Dmotor.Recordset.NoMatch = False Then
     tampil
     hidup
     edit = 1
     tkode.SetFocus
     MsgBox "Data siap di edit, lalu tekan tombol update"
  End If
End Sub

'7. Hapus Record

Private Sub cdel_Click()
  cari = InputBox("Masukan Kode ")
    Dmotor.Recordset.Index = "idxmotor"
    Dmotor.Recordset.Seek "=", cari
 
  If Dmotor.Recordset.NoMatch = False Then
     tampil
     If MsgBox("Hapus?", vbOKCancel) = vbOK Then
        Dmotor.Recordset.Delete
        mati
        kosong
     End If
  End If
End Sub

'8. Pencarian Data

Private Sub cfind_Click()
  cari = InputBox("Masukan Kode ")
    Dmotor.Recordset.Index = "idxmotor"
    Dmotor.Recordset.Seek "=", cari
 
  If Dmotor.Recordset.NoMatch = False Then
     tampil
     hidup
  End If
End Sub

'9. Tombol Navigasi

Private Sub cawal_Click()
 On Error Resume Next
  Dmotor.Recordset.MoveFirst
  tampil
End Sub

Private Sub csebelum_Click()
 On Error Resume Next
  Dmotor.Recordset.MovePrevious
  tampil
End Sub

Private Sub csesudah_Click()
 On Error Resume Next
  Dmotor.Recordset.MoveNext
  tampil
End Sub

Private Sub cakhir_Click()
 On Error Resume Next
  Dmotor.Recordset.MoveLast
  tampil
End Sub


Studi Kasus Penjualan Motor -
1 Response to “Studi Kasus - part 1 ( Penjualan Motor )”:

Posting Komentar