Home » » Program VB Net Untuk FORM PENGGAJIAN KARYAWAN (Sistem Informasi Penggajian)

Program VB Net Untuk FORM PENGGAJIAN KARYAWAN (Sistem Informasi Penggajian)

Written By Mesran on Sunday, 7 July 2013 | 11:53


Berikut merupakan program Program VB Net Untuk FORM PENGGAJIAN KARYAWAN (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 PENGGAJIAN KARYAWAN (Sistem Informasi Penggajian)


Imports System.Data.OleDb
Public Class frmpenggajian
    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 RecordGaji()
        ADP = New OleDbDataAdapter("SELECT * FROM Penggajian", DB)
        DS = New DataSet
        ADP.Fill(DS, "Penggajian")
        DataGridView1.DataSource = DS.Tables("Penggajian")
    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()
        NoSlip.Text = ""
        NIK.Text = ""
        Tanggal.Value = Now
        Gaji.Text = "0"
        Total.Text = "0"
        Tunjangan.Text = "0"
        Jabatan.Text = ""
        Bagian.Text = ""
        Nama.Text = ""
        Call TombolBaru()
    End Sub
    Private Sub btnBaru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBaru.Click
        Call HapusForm()
        NoSlip.Focus()
    End Sub

    Private Sub frmpenggajian_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call HapusForm()
        Call OPENDB()
        Call RecordGaji()

        Call TampilNIK()
    End Sub

    Sub TampilNIK()
        NIK.Items.Clear()
        SQL = "SELECT NIK FROM Karyawan"
        CMD = New OleDbCommand(SQL, DB)
        DR = CMD.ExecuteReader
        While DR.Read
            NIK.Items.Add(DR("NIK"))
        End While
        DR.Close()
    End Sub

    Private Sub NIK_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NIK.SelectedIndexChanged
        CariNIK()
    End Sub

    Sub CariNIK()
        Dim xkode As String = ""
        Dim xkdBagian As String = ""
        Dim xkdJabatan As String = ""
        SQL = "SELECT a.Nama, b.NmJabatan, b.Gaji, c.NmBagian " & _
                        " FROM Karyawan a, Jabatan b, Bagian c " & _
                        " Where a.Bagian = c.KdBagian and a.Jabatan=b.Kdjabatan and NIK='" & NIK.Text & "'"
        CMD = New OleDbCommand(SQL, DB)
        DR = CMD.ExecuteReader
        DR.Read()
        If DR.HasRows = True Then
            Nama.Text = DR("Nama")
            Bagian.Text = DR("NmBagian")
            Jabatan.Text = DR("NmJabatan")
            Gaji.Text = DR("Gaji")
            Call prosesGaji()
        End If
        DR.Close()
    End Sub
    Sub prosesGaji()
        Tunjangan.Text = 0.25 * Gaji.Text
        Total.Text = CDbl(Tunjangan.Text) + CDbl(Gaji.Text)
    End Sub

    Private Sub NoSlip_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles NoSlip.KeyPress
        Dim tombol As Integer = Asc(e.KeyChar)
        Dim xnik As String = ""
        Dim xkode As String = ""
        If tombol = 13 Then
            SQL = "SELECT * FROM Penggajian where NoSlip='" & NoSlip.Text & "'"
            CMD = New OleDbCommand(SQL, DB)
            DR = CMD.ExecuteReader
            DR.Read()
            If DR.HasRows = True Then
                Tanggal.Value = Format(DR("Tanggal"), "dd-MM-yyyy")
                xnik = DR("NIK")
                Gaji.Text = DR("Gaji")
                Total.Text = DR("Total")
                Tunjangan.Text = DR("Tunjangan")
                Call TombolEdit()
            Else
                xkode = NoSlip.Text
                Call HapusForm()
                NoSlip.Text = xkode
                Call TombolSimpan()
            End If
            DR.Close()
            NIK.Text = xnik
            NIK.Focus()
        End If
    End Sub

    Private Sub NoSlip_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NoSlip.TextChanged

    End Sub

    Private Sub btnHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHapus.Click
        SQL = "DELETE FROM Penggajian Where NoSlip='" & NoSlip.Text & "'"
        CMD = New OleDbCommand(SQL, DB)
        CMD.ExecuteNonQuery()
        Call btnBaru_Click(sender, e)
        Call RecordGaji()
    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 Penggajian SET NIK='" & NIK.Text & "', " & _
                            " Gaji='" & Gaji.Text & "', " & _
                            " Tanggal='" & Format(Tanggal.Value, "dd-MM-yyyy") & "', " & _
                            " Total='" & Total.Text & "', " & _
                            " Tunjangan='" & Tunjangan.Text & "' " & _
                            " Where NoSlip='" & NoSlip.Text & "'"

        CMD = New OleDbCommand(SQL, DB)
        CMD.ExecuteNonQuery()
        Call btnBaru_Click(sender, e)
        Call RecordGaji()
    End Sub

    Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSimpan.Click
        SQL = "INSERT INTO Penggajian(NoSlip, NIK, Tanggal, Gaji, Tunjangan, Total)" & _
                      "Values ('" & NoSlip.Text & "','" & _
                                    NIK.Text & "','" & _
                                    Format(Tanggal.Value, "dd-MM-yyyy") & "','" & _
                                    Gaji.Text & "','" & _
                                    Tunjangan.Text & "','" & _
                                    Total.Text & "')"
        CMD = New OleDbCommand(SQL, DB)
        CMD.ExecuteNonQuery()
        Call btnBaru_Click(sender, e)
        Call RecordGaji()
    End Sub
End Class


Hasil dari Program VB Net Untuk FORM PENGGAJIAN (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



0 comments:

Post a Comment

Terima kasih apabila sudah memberikan komentar yang baik dan sopan :)