18 Apr 2011


Sub bersih( )
txtkocus.Text = " "
txtnacus.Text = " "
txtalamat.Text = " "
txttelp.Text = " "
opt1.Value = False
opt2.Value = False
cmdsimpan.Caption = "&SIMPAN"
End Sub

Sub aktif( )
txtkocus.Enabled = True
txtnacus.Enabled = True
txtalamat.Enabled = True
txttelp.Enabled = True
opt1.Enabled = True
opt2.Enabled = True
cmdedit.Enabled = True
cmdsimpan.Enabled = True
cmdhapus.Enabled = True
cmdbatal.Enabled = True
End Sub

Sub tidak_aktif( )
txtkocus.Enabled = False
txtnacus.Enabled = False
txtalamat.Enabled = False
txttelp.Enabled = False
opt1.Enabled = False
opt2.Enabled = False
cmdedit.Enabled = False
cmdsimpan.Enabled = False
cmdhapus.Enabled = False
cmdbatal.Enabled = False
End Sub

Sub tampil( )
txtkocus.Text = adocust.Recordset.Fields("kode_cust")
txtnacus.Text = adocust.Recordset.Fields("nama_cust")
txtalamat.Text = adocust.Recordset.Fields("alamat")
If adocust.Recordset.Fields("jenis_kel") = "Laki-laki" Then
opt1.Value = 1
opt2.Value = 0
ElseIf adocust.Recordset.Fields("jenis_kel") = "Perempuan" Then
opt2.Value = 1
opt1.Value = 0
End If
txttelp.Text = adocust.Recordset.Fields("telp")
End Sub
Sub caridata( )
adocust.Recordset.Find "kode_cust=' " + txtkocus.Text + " ' ", , adSearchForward, 1
  If Not adocust.Recordset.EOF Then
  MsgBox "Kode Customer Telah Terdaftar..!!", vbCritical, "Konfirmasi"
  tampil
  tidak_aktif
  cmdedit.Enabled = True
  cmdhapus.Enabled = True
  cmdbatal.Enabled = True
  Else
  tanya = MsgBox("Kode Customer Tersebut Tidak Ditemukan. Apakah Ingin Input Data Baru? Tekan Yes Untuk Mengisi Data Baru", vbYesNo, "Tidak ada")
      If tanya = vbYes Then
      txtkocus.Enabled = False
      Else
      txtkocus.Text = " "
      txtkocus.Enabled = True
      txtkocus.SetFocus
      End If
End If
End Sub

Private Sub cmdcari_Click( )
pesan = InputBox("Masukkan Kode Customer", "Cari Data Customer")
With adocust.Recordset
.Find "kode_cust=' " + pesan + " ' ", , adSearchForward, 1
  If Not .EOF Then
 tampil
 cmdedit.Enabled = True
 cmdhapus.Enabled = True
 Else
    MsgBox "Maaf" & Chr(13) & "Data Customer Tidak Ada", vbInformation + vbOKOnly, "info"
    cmdtambah.Enabled = True
    End If
End With
End Sub

Private Sub cmdhapus_Click( )
If adocust.Recordset.RecordCount = 0 Then
   MsgBox "TIDAK ADA DATA TERSIMPAN", 48, "PESAN"
Else
  If MsgBox("Yakin Akan Hapus Data ?", vbYesNo + vbQuestion, "Info") = vbYes Then
    adocust.Recordset.Delete
    adocust.Recordset.MoveFirst
End If
End If
bersih
Form_Activate
Private Sub cmdedit_Click( )
cmdsimpan.Caption = "&UPDATE"
aktif
txtkocus.Enabled = False
cmdedit.Enabled = False
cmdtambah.Enabled = False
cmdhapus.Enabled = False
txtnacus.SetFocus
End Sub

Private Sub cmdkeluar_Click( )
Unload me
End Sub

Private Sub cmdtambah_Click( )
aktif
bersih
txtkocus.Enabled = True
txtkocus.SetFocus
cmdtambah.Enabled = False
cmdedit.Enabled = False
cmdhapus.Enabled = False
End Sub

Private Sub cmdsimpan_Click( )
If cmdsimpan.Caption = "&SIMPAN" Then
adocust.Recordset.AddNew
adocust.Recordset.Fields("kode_cust") = txtkocus.Text
adocust.Recordset.Fields("nama_cust") = txtnacus.Text
adocust.Recordset.Fields("alamat") = txtalamat.Text
  If opt1.Value = True Then
  adocust.Recordset.Fields("jenis_kel") = "Laki-laki"
  Else
  If opt2.Value = True Then
  adocust.Recordset.Fields("jenis_kel") = "Perempuan"
  End If
  End If
adocust.Recordset.Fields("telp") = txttelp.Text
adocust.Recordset.Update
bersih
Else
If cmdsimpan.Caption = "&UPDATE" Then
adocust.Recordset.Fields("kode_cust") = txtkocus.Text
adocust.Recordset.Fields("nama_cust") = txtnacus.Text
adocust.Recordset.Fields("alamat") = txtalamat.Text
  If opt1.Value = True Then
  adocust.Recordset.Fields("jenis_kel") = "Laki-laki"
  Else
  If opt2.Value = True Then
  adocust.Recordset.Fields("jenis_kel") = "Perempuan"
  End If
  End If
adocust.Recordset.Fields("telp") = txttelp.Text
adocust.Recordset.Update
bersih
End If
End If
Form_Activate
tidak_aktif
End Sub

Private Sub cmdbatal_Click( )
bersih
tidak_aktif
cmdtambah.Enabled = True
cmdtambah.SetFocus
End Sub

Private Sub Form_Activate( )
adocust.RecordSource = "select * from customer"
tidak_aktif
txtkocus.MaxLength = 6
cmdtambah.Enabled = True
cmdtambah.SetFocus
End Sub

Private Sub Timer1_Timer( )
lbtgl.Caption = Now
End Sub

Private Sub cmdback_Click( )
On Error Resume Next
tidak_aktif
cmdtambah.Enabled = True
adocust.Recordset.MovePrevious
If adocust.Recordset.BOF Then
MsgBox "SUDAH DIAWAL RECORD", , "INFO"
adocust.Recordset.MoveFirst
End If
End Sub

Private Sub cmdlast_Click( )
On Error Resume Next
If adocust.Recordset.EOF Then
MsgBox "SUDAH DIAKHIR RECORD", , "INFO"
End If
adocust.Recordset.MoveLast
tidak_aktif
cmdtambah.Enabled = True
End Sub

Private Sub cmdtop_Click( )
adocust.Recordset.MoveFirst
If adocust.Recordset.BOF Then
MsgBox "SUDAH DIAWAL RECORD", , "INFO"
End If
cmdtambah.Enabled = True
cmdcari.Enabled = True
End Sub

Private Sub cmdnext_Click( )
tidak_aktif
cmdtambah.Enabled = True
adocust.Recordset.MoveNext
If adocust.Recordset.EOF Then
MsgBox "SUDAH DIAKHIR RECORD", , "INFO"
adocust.Recordset.MoveLast
End If
End Sub

Private Sub txtkocus_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
If (Len(txtkocus.Text)) < 6 Then
  MsgBox "Kode Customer harus 6 karakter", vbOKOnly, "Pesan"
  txtkocus.Text = " "
  txtkocus.SetFocus
Else
caridata
End If
End If
End Sub

Private Sub txtnacus_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
opt1.Enabled = True
opt1.SetFocus
opt2.Enabled = True
End If
End Sub

Download Versi Lengkapnya DISINI

Tagged:

0 komentar:

Posting Komentar