Untuk memasukkan image ke Button bisa dilihat pada artikel memasukkan image ke button pada VB Net
Untuk listing Program VB Net Untuk FORM KARYAWAN (Sistem Informasi Penggajian)
Imports System.Data.OleDb
Public Class frmPegawai
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=E:\0Program Visual II\DB\SMART.mdb"
DB = New OleDbConnection(LOKASI)
If DB.State = ConnectionState.Closed Then
DB.Open()
End If
End Sub
Sub RecordPegawai()
ADP = New OleDbDataAdapter("SELECT * FROM Karyawan", DB)
DS = New DataSet
ADP.Fill(DS, "Karyawan")
DataGridView1.DataSource = DS.Tables("Karyawan")
End Sub
Sub TombolBaru()
btnBaru.Enabled = True
btnSimpan.Enabled = False
btnEdit.Enabled = False
btnHapus.Enabled = False
btnBatal.Enabled = False
btnKeluar.Enabled = True
End Sub
Sub TombolEdit()
btnBaru.Enabled = False
btnSimpan.Enabled = False
btnEdit.Enabled = True
btnHapus.Enabled = True
btnBatal.Enabled = True
btnKeluar.Enabled = False
End Sub
Sub TombolSimpan()
btnBaru.Enabled = False
btnSimpan.Enabled = True
btnEdit.Enabled = False
btnHapus.Enabled = False
btnBatal.Enabled = True
btnKeluar.Enabled = False
End Sub
Sub HapusForm()
NIK.Text = ""
jkelamin.Text = ""
Kdjabatan.Text = ""
Kdbagian.Text = ""
Jabatan.Text = ""
Bagian.Text = ""
Nama.Text = ""
Call TombolBaru()
End Sub
Private Sub frmPegawai_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call HapusForm()
Call OPENDB()
Call RecordPegawai()
Call TampilKDBagian()
Call TampilKDJabatan()
End Sub
Sub TampilKDBagian()
Kdbagian.Items.Clear()
SQL = "SELECT * FROM Bagian"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
While DR.Read
Kdbagian.Items.Add(DR("KdBagian"))
End While
DR.Close()
End Sub
Sub TampilKDJabatan()
Kdjabatan.Items.Clear()
SQL = "SELECT * FROM Jabatan"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
While DR.Read
Kdjabatan.Items.Add(DR("KdJabatan"))
End While
DR.Close()
End Sub
Private Sub btnBaru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaru.Click
Call HapusForm()
NIK.Focus()
End Sub
Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
SQL = "INSERT INTO Karyawan(NIK, Nama, Bagian, Jabatan, JenisKelamin)" & _
"Values ('" & NIK.Text & "','" & _
Nama.Text & "','" & _
Kdbagian.Text & "','" & _
Kdjabatan.Text & "','" & _
JKelamin.Text & "')"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call RecordPegawai()
End Sub
Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click
SQL = "DELETE FROM Karyawan Where NIK='" & NIK.Text & "'"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call RecordPegawai()
End Sub
Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBatal.Click
Call btnBaru_Click(sender, e)
End Sub
Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKeluar.Click
Me.Close()
End Sub
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
SQL = "UPDATE Karyawan SET Nama='" & Nama.Text & "', " & _
" Bagian='" & Kdbagian.Text & "', " & _
" Jabatan='" & Kdjabatan.Text & "', " & _
" JenisKelamin='" & JKelamin.Text & "' " & _
" Where NIK='" & NIK.Text & "'"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call RecordPegawai()
End Sub
Private Sub NIK_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles NIK.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
Dim xkode As String
Dim xkdBagian As String = ""
Dim xkdJabatan As String = ""
If tombol = 13 Then
SQL = "SELECT * FROM Karyawan Where NIK='" & NIK.Text & "'"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows = True Then
Nama.Text = DR("Nama")
JKelamin.Text = DR("JenisKelamin")
xkdBagian = DR("Bagian")
xkdJabatan = DR("Jabatan")
Call TombolEdit()
Else
xkode = NIK.Text
Call HapusForm()
NIK.Text = xkode
Call TombolSimpan()
End If
DR.Close()
Kdbagian.Text = xkdBagian
Kdjabatan.Text = xkdJabatan
Nama.Focus()
End If
End Sub
Private Sub NIK_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NIK.TextChanged
End Sub
Private Sub Kdjabatan_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kdjabatan.SelectedIndexChanged
SQL = "SELECT * FROM Jabatan where KDJabatan='" & Kdjabatan.Text & "'"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
If DR.HasRows Then
DR.Read()
Jabatan.Text = DR("NmJabatan")
End If
DR.Close()
End Sub
Private Sub Kdbagian_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Kdbagian.SelectedIndexChanged
SQL = "SELECT * FROM Bagian where Kdbagian='" & Kdbagian.Text & "'"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
If DR.HasRows Then
DR.Read()
Bagian.Text = DR("NmBagian")
End If
DR.Close()
End Sub
End Class
Hasil dari Program VB Net Untuk FORM KARYAWAN (Sistem Informasi Penggajian) ketika dijalankan akan terlihat seperti berikut ini :
Silahkan lihat Program VB Net Untuk FORM BAGIAN (Sistem Informasi Penggajian) berikut.
Created By : Tutorial Program VB Net
ane kagak ngarti sama koding yang "','"
ReplyDeletemohon pencerahannya ,,, :D
:D hahahah yayaya ntar di ajarin lagi :)
ReplyDelete