DATA
NAMA PERALATAN INVENTARIS BARANG PERUSAHAAN
PT.POS INDONESIA (Persero) MEDAN
PT.POS INDONESIA (Persero) MEDAN
Inventaris
|
||||||
Kode Peralatan
|
Nama Peralatan
|
Harga
|
Satuan
|
Jumlah Tersedia
|
Rusak
|
Kelompok Peralatan
|
100
|
Kursi
|
175000
|
1000
|
25
|
||
101
|
Meja
|
190000
|
1000
|
21
|
||
102
|
Whiteboard
|
150000
|
1500
|
19
|
Imports
System.Data.OleDb
Public Class Form1
Public DB As OleDbConnection
Public CMD As OleDbCommand
Public ADP As OleDbDataAdapter
Public DR As OleDbDataReader
Public DS As New DataSet
Dim Sql As String
Public Sub openDB()
Dim
LOKASI = "Provider =
Microsoft.Jet.OLEDB.4.c;Databases=c:\VB2\Inventaris1.mdb"
DB = New
OleDbConnection(LOKASI)
If
DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub
TampilRecordInventaris()
ADP = New
OleDbDataAdapter("SELECT * FROM Inventaris", DB)
DS = New
DataSet
ADP.Fill(DS, "Inventaris")
DataGridView1.DataSource = DS.Tables("Inventaris")
End Sub
Sub
ButtonTambah()
BtnTambah.Enabled = True
BtnSimpan.Enabled = False
BtnEdit.Enabled = False
BtnHapus.Enabled = False
BtnBatal.Enabled = False
BtnClose.Enabled = True
End Sub
Sub
ButtonEdit()
BtnTambah.Enabled = False
BtnSimpan.Enabled = False
BtnEdit.Enabled = True
BtnHapus.Enabled = True
BtnBatal.Enabled = True
BtnClose.Enabled = False
End Sub
Sub
ButtonSimpan()
BtnTambah.Enabled = False
BtnSimpan.Enabled = True
BtnEdit.Enabled = False
BtnHapus.Enabled = False
BtnBatal.Enabled = True
BtnClose.Enabled = False
End Sub
Sub
HapusText()
Kode.Text = ""
Nama.Text = ""
Harga.Text = ""
Call
ButtonTambah()
End Sub
Private Sub Form1_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
openDB()
Call
HapusText()
Call
TampilRecordInventaris()
End Sub
Private Sub BtnHapus_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnHapus.Click
Sql = "DELETE
FROM INVENTARIS Where Kode='" & Kode.Text & "'" & "'"
CMD = New
OleDbCommand(Sql, DB)
CMD.ExecuteNonQuery()
Call
BtnTambah_Click(sender, e)
Call
TampilRecordInventaris()
End Sub
Private Sub BtnClose_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnClose.Click
Me.Close()
End Sub
Private Sub BtnTambah_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnTambah.Click
Call
HapusText()
Kode.Focus()
End Sub
Private Sub Form1_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
Me.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
Dim
xkode As String
If
tombol = 13 Then
Sql = "SELECT
* FROM Inventaris Where Kode='" & Kode.Text & "'"
CMD = New
OleDbCommand(Sql, DB)
DR = CMD.ExecuteReader
DR.Read()
If
DR.HasRows = True Then
Nama.Text = DR.Item(1)
Call
ButtonEdit()
MsgBox("Data
Ditemukan !")
Else
xkode = Kode.Text
Call
HapusText()
Kode.Text = xkode
Call
ButtonSimpan()
End
If
Nama.Focus()
End If
End Sub
Private Sub BtnBatal_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnBatal.Click
Call
HapusText()
Kode.Focus()
End Sub
Private Sub BtnEdit_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnEdit.Click
Sql = "update
Inventaris set Nama='" & Nama.Text & "'" & _
"Where Kode='" & Kode.Text & "'"
CMD = New
OleDbCommand(Sql, DB)
CMD.ExecuteNonQuery()
Call BtnTambah_Click(sender, e)
Call
TampilRecordInventaris()
End Sub
Private Sub Kode_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Kode.TextChanged
If
Kode.Text = "100" Then
Nama.Text = "Kursi"
ElseIf
Kode.Text = "101" Then
Nama.Text = "Meja"
End If
End Sub
Private Sub BtnSimpan_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnSimpan.Click
Sql = "INSERT
INTO Inventaris(Kode,Nama,Harga,Satuan,Jumlah, Kelompok Peralatan)"
& "VALUES('" & Kode.Text
& "','" & Nama.Text & "','" & Harga.Text & "','" & Satuan.Text & "','" & Jumlah.Text & "','" & Rusak.Text & "','" & KelompokPeralatan.Text &
"' )"
CMD = New
OleDbCommand(Sql, DB)
CMD.ExecuteNonQuery()
Call
BtnTambah_Click(sender, e)
Call
TampilRecordInventaris()
End Sub
End Class