Selasa, 24 Januari 2012

form barang baru





Private Sub b1_Click()
If b1.Caption = "Tambah" Then
    b1.Caption = "Simpan"
    Adodc1.Recordset.AddNew
    Call aktif
    b2.Enabled = False
    b3.Enabled = False
    b4.Caption = "Batal"
ElseIf b1.Caption = "Simpan" Then
    If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
        Call msgSimpan
    Else
        Adodc1.Recordset.Update
        Adodc1.Refresh
        Call nonaktif
        b1.Caption = "Tambah"
        b4.Caption = "Keluar"
    End If
End If
End Sub

Private Sub b2_Click()
If b2.Caption = "Edit" Then
    Call aktif
    b2.Caption = "Simpan"
    b4.Caption = "Batal"
    b1.Enabled = False
    b3.Enabled = False
ElseIf b2.Caption = "Simpan" Then
    If Adodc1.Recordset.RecordCount = 0 Then
        Call msgKosong
    Else
        Adodc1.Recordset.Update
        Adodc1.Refresh
        b2.Caption = "Edit"
        b4.Caption = "Keluar"
        Call nonaktif
    End If
End If
End Sub

Private Sub b3_Click()
If Adodc1.Recordset.RecordCount = 0 Then
    Call msgKosong
Else
pesan = MsgBox("Yakin data ini akan anda hapus?", vbYesNo, "Konfirmasi")
    If pesan = vbYes Then
        Adodc1.Recordset.Delete
        Adodc1.Refresh
    End If
End If
End Sub

Private Sub b4_Click()
If b4.Caption = "Keluar" Then
    Unload Me
    frmUtama.Show
    frmUtama.Enabled = True
ElseIf b4.Caption = "Batal" Then
    Adodc1.Refresh
    Call nonaktif
    b1.Caption = "Tambah"
    b2.Caption = "Edit"
    b3.Caption = "Hapus"
    b4.Caption = "Keluar"
'    b1.Enabled = True
'    b2.Enabled = True
'    b3.Enabled = True
End If
End Sub

Private Sub c1_Click()
If Adodc1.Recordset.RecordCount = 0 Then
    Call msgKosong
Else
    Adodc1.Recordset.MoveFirst
End If
End Sub

Private Sub c2_Click()
If Adodc1.Recordset.RecordCount = 0 Then
    Call msgKosong
Else
    Adodc1.Recordset.MoveNext
    If Adodc1.Recordset.EOF Then
        Adodc1.Recordset.MoveFirst
    End If
End If
End Sub

Private Sub c3_Click()
If Adodc1.Recordset.RecordCount = 0 Then
    Call msgKosong
Else
    Adodc1.Recordset.MovePrevious
    If Adodc1.Recordset.BOF Then
        Adodc1.Recordset.MoveLast
    End If
End If
End Sub

Private Sub c4_Click()
If Adodc1.Recordset.RecordCount = 0 Then
    Call msgKosong
Else
    Adodc1.Recordset.MoveLast
End If
End Sub

Private Sub Form_Load()
Dim u As String
Adodc1.Visible = False
Call nonaktif
End Sub

Private Sub aktif()
Text1.Locked = False
Text2.Locked = False
Text3.Locked = False
End Sub

Private Sub nonaktif()
Text1.Locked = True
Text2.Locked = True
Text3.Locked = True
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
'If Not (KeyAscii >= ("0") And KeyAscii <= ("9") Or KeyAscii = vbKeyBack) Then
'    MsgBox "Hanya bisa diinput dengan angka!", vbInformation, "Info"
'End If
'    KeyAscii = 0
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
'If Not (KeyAscii >= ("0") And KeyAscii <= ("9") Or KeyAscii = vbKeyBack) Then
'    MsgBox "Hanya bisa diinput dengan angka!", vbInformation, "Info"
'    KeyAscii = 0
'End If
End Sub

Private Sub Text4_Change()
Dim u As String
u = "select * from barang where nama_brg like'%" & Text4.Text & "%'"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = u
Adodc1.Refresh
End Sub

Tidak ada komentar:

Posting Komentar