Kamis, 21 November 2013

BSI CENGKARENG: VB1 PASCA UTS (Dosen: BRD_NHY Assisten: Liah Hastuti)

MATERI REVISI FORM CUSTOMER:
Materi ini khusus untuk MK VB1 Semester 3 BSI Cengkareng Jurusan Manajemen Informatika.
Silahkan latihan di rumah dengan mengerjakan materi ini. Form ini merupakan form master yang kedua setelah yang pertama FORM BARANG.



Form Customer
Untuk from customer, tambahkan 1 komponen baru (CTRL+T) dan tambahkan (Microsoft tabbed dialog control 6.0).
Setelah ditambahkan, silahkan setting tab (SSTAB yang sudah didrag), ganti Tabs di PROPERTIES menjadi 2.
(Karena hanya 2 tab yang dibutuhkan)
Berikut adalah tab pertama form customer






Form customer tab ke 2:

Listing:
Private Sub add_Click()
aktif
bersih
tkode_customer.SetFocus
save.Enabled = True
cancel.Enabled = True
add.Enabled = False
End Sub

Private Sub akhir_Click()
data_customer.Recordset.MoveLast
tampil
End Sub

Private Sub awal_Click()
data_customer.Recordset.MoveFirst
tampil
End Sub

Private Sub cancel_Click()
x = MsgBox("Yakin untuk membatalkan penginputan?", vbYesNo, "INFO")
If x = vbYes Then
Call nonaktif
Call bersih
Form_Load
End If
End Sub

Sub bersih()
tkode_customer.Text = ""
tnama_customer.Text = ""
tnomer.Text = ""
talamat.Text = ""
End Sub

Sub aktif()
tkode_customer.Enabled = True
tnama_customer.Enabled = True
tnomer.Enabled = True
talamat.Enabled = True
add.Enabled = True
tcari.Enabled = True
End Sub

Sub nonaktif()
tkode_customer.Enabled = False
tnama_customer.Enabled = False
tnomer.Enabled = False
talamat.Enabled = False
save.Enabled = False
edit.Enabled = False
hapus.Enabled = False
End Sub
Private Sub edit_Click()
data_customer.Recordset.edit
aktif
tkode_customer.Enabled = False
tnama_customer.SetFocus
edit.Enabled = False
save.Enabled = True
hapus.Enabled = False
cancel.Enabled = True
add.Enabled = False
Call tampil
End Sub

Private Sub exit_Click()
a = MsgBox("Anda yakin akan keluar?", vbQuestion + vbYesNo, "INFO")
If a = vbYes Then
F_MENU.Show
F_CUSTOMER.Visible = False
End If
End Sub


Sub tampil()
With data_customer.Recordset
tkode_customer.Text = !kode_customer
tnama_customer.Text = !nama_customer
tnomer.Text = !telepon
talamat.Text = !alamat
End With
End Sub

Private Sub find_Click()
data_customer.Recordset.Index = "kode_customer"
 data_customer.Recordset.Seek "=", tcari
 If data_customer.Recordset.NoMatch Then
 MsgBox "DATA TIDAK DITEMUKAN", vbOKOnly, "INFORMASI"
 data_customer.Recordset.MoveFirst
 tcari.Text = ""
 tcari.SetFocus
 Else
 tampil
 tkode_customer.Enabled = False
 tnama_customer.Enabled = False
 talamat.Enabled = False
 tnomer.Enabled = False
 edit.Enabled = True
 hapus.Enabled = True
 add.Enabled = False
 End If
End Sub

Private Sub Form_Load()
nonaktif
bersih
add.Enabled = True
edit.Enabled = False
hapus.Enabled = False
save.Enabled = False
cancel.Enabled = False
End Sub

Private Sub Form_Unload(cancel As Integer)
Dim keluar As String
keluar = MsgBox("Anda akan keluar sistem?", vbQuestion + vbYesNo, "Message")
Select Case keluar
Case vbYes
End
Case Else: cancel = 1: End Select
End Sub

Private Sub hapus_Click()
data_customer.Recordset.Delete
data_customer.Recordset.MoveFirst
Call tampil
edit.Enabled = False
End Sub

Private Sub maju_Click()
data_customer.Recordset.MovePrevious
If data_customer.Recordset.BOF Then
MsgBox "Data sudah di awal record", vbInformation, "info"
data_customer.Recordset.MoveFirst
End If
Call tampil
End Sub

Private Sub mundur_Click()
data_customer.Recordset.MoveNext
If data_customer.Recordset.EOF Then
MsgBox "Data sudah di akhir record", vbInformation, "info"
data_customer.Recordset.MoveLast
End If
Call tampil
End Sub

Private Sub save_Click()
With data_customer.Recordset
.Index = "kode_customer"
.Seek "=", tkode_customer.Text
If .NoMatch Then
.AddNew
.Fields!kode_customer = tkode_customer.Text
.Fields!nama_customer = tnama_customer.Text
.Fields!telepon = tnomer.Text
.Fields!alamat = talamat.Text
.Update
MsgBox "data tersimpan!", vbInformation, "info"
Else
.edit
.Fields!nama_customer = tnama_customer.Text
.Fields!telepon = tnomer.Text
.Fields!alamat = talamat.Text
.Update
MsgBox "data diperbarui!", vbInformation, "info"
End If
bersih
nonaktif
add.Enabled = True
save.Enabled = False
cancel.Enabled = False
End With
End Sub

Private Sub Timer1_Timer()
tanggal.Caption = Date
jam.Caption = Time
tanggal.Caption = Format(Now, "dddd, dd - mm - yyyy")
End Sub

Private Sub tkode_customer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
tnama_customer.SetFocus
End If
End Sub

Private Sub tnama_customer_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
tnomer.SetFocus
End If
End Sub

Private Sub tnomer_KeyPress(KeyAscii As Integer)
If ((KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57) Then
    KeyAscii = 0
End If
End Sub

Tidak ada komentar:

Posting Komentar