Program VB Net Untuk FORM BAGIAN (Sistem Informasi Penggajian) |
Untuk memasukkan image ke Button bisa dilihat pada artikel memasukkan image ke button pada VB Net
Untuk listing Program VB Net Untuk FORM BAGIAN (Sistem Informasi Penggajian)
Imports System.Data.OleDb
Public Class frmBagian
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 Recordbagian()
ADP = New OleDbDataAdapter("SELECT * FROM bagian", DB)
DS = New DataSet
ADP.Fill(DS, "bagian")
DataGridView1.DataSource = DS.Tables("bagian")
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()
KdBagian.Text = ""
Nama.Text = ""
Call TombolBaru()
End Sub
Private Sub frmBagian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call OPENDB()
Call HapusForm()
Call Recordbagian()
End Sub
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
SQL = "UPDATE bagian SET Nmbagian='" & Nama.Text & "' " & _
" Where Kdbagian='" & KdBagian.Text & "'"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call BtnBaru_Click(sender, e)
Call Recordbagian()
End Sub
Private Sub btnBaru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaru.Click
Call HapusForm()
KdBagian.Focus()
End Sub
Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
SQL = "INSERT INTO bagian (Kdbagian, Nmbagian)" & _
"Values ('" & KdBagian.Text & "','" & _
Nama.Text & "')"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call Recordbagian()
End Sub
Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click
SQL = "DELETE FROM bagian Where Kdbagian='" & KdBagian.Text & "'"
CMD = New OleDbCommand(SQL, DB)
CMD.ExecuteNonQuery()
Call btnBaru_Click(sender, e)
Call Recordbagian()
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 KdBagian_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles KdBagian.KeyPress
Dim tombol As Integer = Asc(e.KeyChar)
Dim xkode As String
If tombol = 13 Then
SQL = "SELECT * FROM bagian Where Kdbagian='" & KdBagian.Text & "'"
CMD = New OleDbCommand(SQL, DB)
DR = CMD.ExecuteReader
DR.Read()
If DR.HasRows = True Then
Nama.Text = DR.Item(1)
Call TombolEdit()
MsgBox("Data Ini Sudah Tersimpan Pada Tabel Bagian !")
Else
xkode = KdBagian.Text
Call HapusForm()
KdBagian.Text = xkode
Call TombolSimpan()
End If
DR.Close()
Nama.Focus()
End If
End Sub
Private Sub KdBagian_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KdBagian.TextChanged
End Sub
End Class
Hasil dari Program VB Net Untuk FORM BAGIAN (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
pak,,,saya rampok ilmu yang bapak bagikan ini ya..
ReplyDeletehehhehe... makasih y pak... :)
jangan main rampok aja lah :p
ReplyDeletepak maaf saya awam soal vb...ini database menggunakan mysql kan?knp microsoft jet OLEDB 4.0 saya gak ada yah ?
ReplyDeleteilmu yang bermanfaat sekali ini . . .
ReplyDeleteterimakasih sudah berbagi . . .