Imports
System.Data.OleDb
Public Class KARYAWAN
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.0;Data Source=C:\VB6\DATABASE141.mdb"
DB = New
OleDbConnection(LOKASI)
If
DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub
RecordKARYAWAN()
ADP = New
OleDbDataAdapter("SELECT * FROM KARYAWAN",
DB)
DS = New
DataSet
ADP.Fill(DS, "KARYAWAN")
DataGridView1.DataSource = DS.Tables("KARYAWAN")
End Sub
Sub
butoonbaru()
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
Button6.Enabled = True
End Sub
Sub
butoonedit()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = True
Button4.Enabled = True
Button5.Enabled = True
Button6.Enabled = False
End Sub
Sub
butoonsimpan()
Button1.Enabled = False
Button2.Enabled = True
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = True
Button6.Enabled = False
End Sub
Sub
hapustext()
TextBox1.Text = ""
TextBox2.Text = ""
Call
butoonbaru()
End Sub
Private Sub KARYAWAN_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call
OPENDB()
Call
RecordKARYAWAN()
Call
hapustext()
ComboBox1.Items.Add("JENIS KELAMIN")
End Sub
Private Sub Button6_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub TextBox1_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
Dim
tombol As Integer
= Asc(e.KeyChar)
Dim
xkode As String
If
tombol = 13 Then
SQL = "SELECT
* FROM KARYAWAN Where NIK='" & TextBox1.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If
DR.HasRows = True Then
TextBox2.Text = DR.Item(2)
TextBox3.Text = DR.Item(3)
TextBox4.Text = DR.Item(5)
Call
butoonedit()
MsgBox("DATA
DITEMUKAN!")
Else
xkode = TextBox1.Text
Call
hapustext()
TextBox1.Text = xkode
Call
butoonsimpan()
End
If
TextBox2.Focus()
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub Button5_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Call
hapustext()
TextBox1.Focus()
End Sub
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Call
hapustext()
TextBox1.Focus()
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
SQL = "INSERT
INTO KARYAWAN (NIK, NAMA, JABATAN, JENIS KELAMIN, BAGIAN)" & _
"Values
('" & TextBox1.Text & "','"
& _
TextBox2.Text
& "','" & _
TextBox3.Text
& "','" & _
ComboBox1.Text
& "','" & _
TextBox4.Text
& "')"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
Button1_Click(sender, e)
Call
RecordKARYAWAN()
End Sub
Private Sub Button3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
SQL = "UPDATE
KARYAWAN SET NAMA='" & TextBox2.Text & "'," & _
"JABATAN='" & TextBox3.Text & "'," & _
"JENIS KELAMIN='" & ComboBox1.Text
& "'," & _
"BAGIAN='" & TextBox4.Text & "' " & _
"Where NIK='" & TextBox1.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
Button1_Click(sender, e)
Call
RecordKARYAWAN()
Call
hapustext()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As
System.EventArgs) Handles
ComboBox1.SelectedIndexChanged
If
ComboBox1.Text = "JENIS KELAMIN" Then
ComboBox1.Items.Add("LAKI-LAKI")
ComboBox1.Items.Add("PEREMPUAN")
ComboBox1.Items.Add("WARIA")
End If
End Sub
Private Sub Button4_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
SQL = "DELETE
FROM KARYAWAN Where NIK='" & TextBox1.Text & "'"
CMD = New
OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call
Button1_Click(sender, e)
Call
RecordKARYAWAN()
End Sub
End Class
PROGRAM SELETAH DI JALAN KAN
Tidak ada komentar:
Posting Komentar