Dim isi As Boolean
Sub tampildata()
If Adodc1.Recordset.RecordCount > 0 Then
txtkode.Text =
Adodc1.Recordset.Fields("kdbrg")
txtnama.Text =
Adodc1.Recordset.Fields("nmbrg")
txtharga.Text =
Adodc1.Recordset.Fields("harga")
txtstok.Text = Adodc1.Recordset.Fields("stok")
If
Adodc1.Recordset.RecordCount = 0 Then txtstok.Text = 0
End If
End Sub
Sub aktif()
txtkode.Enabled = True
txtnama.Enabled = True
txtharga.Enabled = True
txtstok.Enabled = True
End Sub
Sub bersih()
txtkode.Text = ""
txtnama.Text = ""
txtharga.Text = ""
txtstok.Text = ""
End Sub
Sub awal()
Adodc1.RecordSource = "select*from tb_barang"
Adodc1.Refresh
DataGrid1.Refresh
tampildata
bersih
txtkode.Enabled = False
txtnama.Enabled = False
txtharga.Enabled = False
txtstok.Enabled = False
txtnabar.Enabled = False
cmdadd.Enabled = True
cmdsave.Enabled = False
cmdedit.Enabled = False
cmddelete.Enabled = False
cmdcancel.Enabled = False
End Sub
Private Sub cmdadd_Click()
bersih
aktif
txtkode.SetFocus
cmddelete.Enabled = False
cmdedit.Enabled = False
cmdcancel.Enabled = True
cmdadd.Enabled = False
cmdsave.Enabled = True
End Sub
Private Sub cmdback_Click()
With Adodc1.Recordset
If .RecordCount
> 0 Then
.MovePrevious
If .BOF Then
.MoveFirst
MsgBox "Sudah di Data Pertama",
vbInformation, "Awal"
End If
tampildata
End If
End With
End Sub
Private Sub cmdcancel_Click()
awal
End Sub
Private Sub cmddelete_Click()
If Adodc1.Recordset.RecordCount > 0 Then
If
MsgBox("Yakin Data" & txtkode.Text & "Akan
Dihapus???", 36, "Hapus") = 6 Then
Adodc1.Recordset.Delete
awal
Else
Exit Sub
End If
End If
DataGrid1.Refresh
bersih
cmdedit.Enabled = False
cmddelete.Enabled = False
cmdcancel.Enabled = False
cmdsave.Enabled = False
cmdadd.Enabled = True
End Sub
Private Sub cmdedit_Click()
aktif
txtkode.Enabled = False
isi = False
cmdedit.Enabled = False
cmddelete.Enabled = False
cmdadd.Enabled = False
cmdcancel.Enabled = True
cmdsave.Enabled = True
End Sub
Private Sub cmdend_Click()
With Adodc1.Recordset
If .RecordCount
> 0 Then
.MoveLast
tampildata
MsgBox
"Ini Data Terakhir", vbInformation, "Akhir"
End If
End With
End Sub
Private Sub cmdnext_Click()
With Adodc1.Recordset
If .RecordCount
> 0 Then
.MoveNext
If .EOF Then
.MoveLast
MsgBox
"Sudah Di Data Terakhir", vbInformation, "Akhir"
End If
tampildata
End If
End With
End Sub
Private Sub cmdnext2_Click()
Form2.Show
Form1.Hide
End Sub
Private Sub cmdnext3_Click()
Form3.Show
Form1.Hide
End Sub
Private Sub cmdsave_Click()
With Adodc1.Recordset
If isi = True Then
.AddNew
.Fields("kdbrg") = txtkode.Text
.Fields("nmbrg") = txtnama.Text
.Fields("harga") = txtharga.Text
.Fields("stok") = txtstok.Text
.Update
Else
.Fields("kdbrg") = txtkode.Text
.Fields("nmbrg") = txtnama.Text
.Fields("harga") = txtharga.Text
.Fields("stok") = txtstok.Text
.Update
End If
End With
Adodc1.RecordSource = "select*from tb_barang"
Adodc1.Refresh
awal
End Sub
Private Sub cmdtop_Click()
With Adodc1.Recordset
If .RecordCount
> 0 Then
.MoveFirst
tampildata
MsgBox
"Ini Data Pertama", vbInformation, "Awal"
End If
End With
End Sub
Private Sub Command11_Click()
x = MsgBox("Yakin Akan Keluar???", vbQuestion +
vbYesNo, "Pesan")
If x = vbYes Then
End
End If
End Sub
Private Sub dbcari_Click()
Adodc1.Refresh
With Adodc1.Recordset
.Find
"kdbrg='" & txtkobar.Text & "'"
If .EOF Then
MsgBox
"Kode" + txtkobar.Text + "Tidak Ada", vbInformation,
"Info"
txtkobar.Text
= ""
txtkobar.SetFocus
Else
txtnabar.Text
= .Fields("nmbrg")
End If
End With
cmddelete.Enabled = True
cmdedit.Enabled = True
cmdcancel.Enabled = True
cmdadd.Enabled = False
cmdsave.Enabled = False
End Sub
Private Sub Form_Activate()
awal
isi = True
txtkode.MaxLength = 5
txtkobar.MaxLength = 5
txtstok.MaxLength = 2
End Sub
Private Sub txtkobar_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
End Sub
Private Sub txtkode_KeyPress(KeyAscii As Integer)
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If KeyAscii = 13 Then
Adodc1.RecordSource = "select*from tb_barang where
kdbrg='" & txtkode.Text & "'"
Adodc1.Refresh
With Adodc1.Recordset
If .RecordCount
<= 0 Then
isi = True:
Call aktif
txtnama.SetFocus
DataGrid1.Refresh
cmdsave.Enabled = True
cmdcancel.Enabled = True
Else
MsgBox
"Kode " & txtkode.Text & " Sudah Ada", vbQuestion,
"Tampil"
tampildata
cmddelete.Enabled = True
cmdadd.Enabled
= True
cmdedit.Enabled = True
cmdsave.Enabled = False
End If
End With
End If
End Sub
Tidak ada komentar:
Posting Komentar