0% found this document useful (0 votes)
11 views16 pages

KODING

This code defines methods for a form that allows viewing and editing employee leave records. It includes methods to load and display employee data from a database, clear form fields, lock/unlock fields, add/update/delete records, and search by employee ID. The form contains text boxes and other controls to display employee information including leave details across two periods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views16 pages

KODING

This code defines methods for a form that allows viewing and editing employee leave records. It includes methods to load and display employee data from a database, clear form fields, lock/unlock fields, add/update/delete records, and search by employee ID. The form contains text boxes and other controls to display employee information including leave details across two periods.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Imports System.Data.

OleDb
Public Class Data_Cuti
Sub kuncitext()
txtnama.Enabled = False
txtjabatan.Enabled = False
txtunitcabang.Enabled = False
dtpmasakerja.Enabled = False
txtlamakerja.Enabled = False
txtsemester1.Enabled = False
txtperiode1.Enabled = False
txtambilcuti1.Enabled = False
txtizin1.Enabled = False
txtsts1.Enabled = False
txtsisacuti1.Enabled = False
txtsemester2.Enabled = False
txtperiode2.Enabled = False
txtambilcuti2.Enabled = False
txtizin2.Enabled = False
txtsts2.Enabled = False
txtsisacuti2.Enabled = False
txttotalsisacuti.Enabled = False
End Sub
Sub clear()
txtnik.Text = ""
txtjabatan.Text = ""
txtunitcabang.Text = ""
txtnama.Text = ""
dtpmasakerja.Text = ""
txtlamakerja.Text = ""
txtsemester1.Text = ""
txtperiode1.Text = ""
txtambilcuti1.Text = ""
txtizin1.Text = ""
txtsts1.Text = ""
txtsisacuti1.Text = ""
txtsemester2.Text = ""
txtperiode2.Text = ""
txtambilcuti2.Text = ""
txtizin2.Text = ""
txtsts2.Text = ""
txtsisacuti2.Text = ""
txttotalsisacuti.Text = ""
Txtcari.Text = ""
End Sub
Sub tampil()
Call Koneksi()
DA = New OleDbDataAdapter("Select * from datacuti", Cn)
Ds = New DataSet
DA.Fill(Ds, "datacuti")
dgvdatacuti.DataSource = Ds.Tables("datacuti")
End Sub
Sub bukakuncitext()
txtsemester1.Enabled = True
txtperiode1.Enabled = True
txtambilcuti1.Enabled = True
txtizin1.Enabled = True
txtsts1.Enabled = True
txtsisacuti1.Enabled = True
txtsemester2.Enabled = True
txtperiode2.Enabled = True
txtambilcuti2.Enabled = True
txtizin2.Enabled = True
txtsts2.Enabled = True
txtsisacuti2.Enabled = True
txttotalsisacuti.Enabled = True
End Sub
Sub btkunci()
btsimpan.Enabled = False
btnew.Enabled = False
btupdate.Enabled = False
btdelete.Enabled = False
btedit.Enabled = False
btcancel.Enabled = False
End Sub
Sub simpan()
If txtnik.Text = "" Or txtjabatan.Text = "" Then
MsgBox("Data Belum Lengkap", MsgBoxStyle.Information, "Info")
Else
Call Koneksi() : Cn.Open()
Dim simpan As String = "INSERT INTO datacuti values ('" &
txtnik.Text & "','" &
txtnama.Text & "','" &
txtjabatan.Text & "','" &
txtunitcabang.Text & "','" &
dtpmasakerja.Value & "','" &
txtlamakerja.Text & "','" &
txtsemester1.Text & "','" &
txtperiode1.Text & "','" &
txtsisacuti1.Text & "','" &
txtizin1.Text & "','" &
txtsts1.Text & "','" &
txtsisacuti1.Text & "','" &
txtsemester2.Text & "','" &
txtperiode2.Text & "','" &
txtsisacuti2.Text & "','" &
txtizin2.Text & "','" &
txtsts2.Text & "','" &
txtsisacuti2.Text & "','" &
txttotalsisacuti.Text & "')"
CMD = New OleDbCommand(simpan, Cn)
CMD.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan", MsgBoxStyle.Information, "Sukses")
Cn.Dispose()
Cn.Close()
End If
End Sub
Sub tampiltexboxtbkaryawan()
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * from identitaskader where nik='" & txtnik.Text &
"'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
txtnik.Text = RD.Item("nik")
txtjabatan.Text = RD.Item("jabatan")
txtunitcabang.Text = RD.Item("unit_cabang")
txtnama.Text = RD.Item("nama_lengkap")
dtpmasakerja.Value = RD.Item("tgl_masuk")
txtlamakerja.Text = RD.Item("masakerja")
btnew.Enabled = True
btcancel.Enabled = True
Else
btnew.Enabled = False
btcancel.Enabled = False
MsgBox("Data Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End Sub
Sub tampiltexbox()
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * from datacuti where nik='" & Txtcari.Text & "'",
Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
txtnik.Text = RD.Item("nik")
txtjabatan.Text = RD.Item("jabatan")
txtunitcabang.Text = RD.Item("unit_cabang")
txtnama.Text = RD.Item("nama_kader")
dtpmasakerja.Value = RD.Item("tgl_masuk")
txtlamakerja.Text = RD.Item("masa_kerja")
txtsemester1.Text = RD.Item("semester1")
txtperiode1.Text = RD.Item("periode1")
txtambilcuti1.Text = RD.Item("total_cuti1")
txtizin1.Text = RD.Item("total_izin1")
txtsts1.Text = RD.Item("total_sts1")
txtsisacuti1.Text = RD.Item("sisa_cuti1")
txtsemester2.Text = RD.Item("semester2")
txtperiode2.Text = RD.Item("periode2")
txtambilcuti2.Text = RD.Item("total_cuti2")
txtizin2.Text = RD.Item("total_izin2")
txtsts2.Text = RD.Item("total_sts2")
txtsisacuti2.Text = RD.Item("sisa_cuti2")
txttotalsisacuti.Text = RD.Item("total_sisacuti")
Else
MsgBox("Data Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End Sub
Sub tbupdate()
If txtnik.Text = "" Or txtnama.Text = "" Or txtnama.Text = "" Or txtjabatan.Text
= "" Then
MsgBox("Data Belum Lengkap", MsgBoxStyle.Information, "Info")
Else
Call Koneksi() : Cn.Open()
Dim simpan As String = "UPDATE datacuti SET total_cuti1 = '" &
txtambilcuti1.Text & "', total_izin1 = '" &
txtizin1.Text & "', total_sts1= '" &
txtsts1.Text & "', sisa_cuti1 = '" &
txtsisacuti1.Text & "', total_cuti2 = '" &
txtambilcuti2.Text & "', total_izin2= '" &
txtizin2.Text & "',total_sts2 = '" &
txtsts2.Text & "', sisa_cuti2 = '" &
txtsisacuti2.Text & "', total_sisacuti= '" &
txttotalsisacuti.Text & "' " & _
"WHERE nik = '" & txtnik.Text & "'"
CMD = New OleDbCommand(simpan, Cn)
CMD.ExecuteNonQuery()
MsgBox("Data Berhasil Diperbaharui", MsgBoxStyle.Information, "Sukses")
Cn.Dispose()
Cn.Close()
End If
End Sub
Sub bthapus()
If MsgBox("Yakin akan menghapus data?", MsgBoxStyle.YesNo, _
"Konfirmasi") = MsgBoxResult.No Then Exit Sub

Dim myCommand As New OleDbCommand


Dim sql As String

Try
Call Koneksi() : Cn.Open()
sql = "DELETE FROM datacuti WHERE nik = " & _
"'" & dgvdatacuti.CurrentRow.Cells(0).Value & "'"

myCommand.Connection = Cn
myCommand.CommandText = sql
myCommand.ExecuteNonQuery()
MsgBox("Data terhapus")
Cn.Close()
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
Cn.Dispose()
End Try
Call clear()
End Sub
Private Sub bttambah_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles bttambah.Click
Call tampiltexboxtbkaryawan()
dgvdatacuti.Enabled = True
End Sub
Private Sub btsimpan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btsimpan.Click
simpan()
Call tampil()
txtnik.Enabled = True
bttambah.Enabled = True
Txtcari.Enabled = True
btsimpan.Enabled = False
btcancel.Enabled = False
btcari.Enabled = True
Call clear()
kuncitext()
dgvdatacuti.Enabled = True
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btcari.Click
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * From datacuti Where nik Like '%" & Txtcari.Text
& "%'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
Call Koneksi()
DA = New OleDbDataAdapter("select * From datacuti Where nik Like '%" &
Txtcari.Text & "%'", Cn)
Ds = New DataSet
DA.Fill(Ds, "Ketemu Data")
dgvdatacuti.DataSource = Ds.Tables("Ketemu Data")
dgvdatacuti.ReadOnly = True
Else
MsgBox("NIK Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End Sub
Private Sub Data_Cuti_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Call Koneksi() : Cn.Open()
DA = New OleDbDataAdapter("Select*From datacuti", Cn)
Ds = New DataSet
Ds.Clear()
DA.Fill(Ds, "datacuti")
dgvdatacuti.DataSource = (Ds.Tables("datacuti"))
Cn.Close()
Cn.Dispose()
Call kuncitext()
Call btkunci()
tampil()
End Sub
Private Sub dgvdatacuti_CellMouseDoubleClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles
dgvdatacuti.CellMouseDoubleClick
txtnik.Text = dgvdatacuti.CurrentRow.Cells(0).Value
txtnama.Text = dgvdatacuti.CurrentRow.Cells(1).Value
txtjabatan.Text = dgvdatacuti.CurrentRow.Cells(2).Value
txtunitcabang.Text = dgvdatacuti.CurrentRow.Cells(3).Value
dtpmasakerja.Value = dgvdatacuti.CurrentRow.Cells(4).Value
txtlamakerja.Text = dgvdatacuti.CurrentRow.Cells(5).Value
txtsemester1.Text = dgvdatacuti.CurrentRow.Cells(6).Value
txtperiode1.Text = dgvdatacuti.CurrentRow.Cells(7).Value
txtambilcuti1.Text = dgvdatacuti.CurrentRow.Cells(8).Value
txtizin1.Text = dgvdatacuti.CurrentRow.Cells(9).Value
txtsts1.Text = dgvdatacuti.CurrentRow.Cells(10).Value
txtsisacuti1.Text = dgvdatacuti.CurrentRow.Cells(11).Value
txtsemester2.Text = dgvdatacuti.CurrentRow.Cells(12).Value
txtperiode2.Text = dgvdatacuti.CurrentRow.Cells(13).Value
txtambilcuti2.Text = dgvdatacuti.CurrentRow.Cells(14).Value
txtizin2.Text = dgvdatacuti.CurrentRow.Cells(15).Value
txtsts2.Text = dgvdatacuti.CurrentRow.Cells(16).Value
txtsisacuti2.Text = dgvdatacuti.CurrentRow.Cells(17).Value
txttotalsisacuti.Text = dgvdatacuti.CurrentRow.Cells(18).Value
txtnik.Enabled = False
bttambah.Enabled = False
btedit.Enabled = True
btcancel.Enabled = True
btdelete.Enabled = True
End Sub
Private Sub btupdate_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btupdate.Click
Call tbupdate()
Call tampil()
End Sub
Private Sub txtambilcuti1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtambilcuti1.TextChanged
txtsisacuti1.Text = Val(txtsemester1.Text) - Val(txtambilcuti1.Text) -
Val(txtizin1.Text) - Val(txtsts1.Text)
End Sub
Private Sub txtsisacuti1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtsisacuti1.TextChanged
txtsisacuti1.Text = Val(txtsemester1.Text) - Val(txtambilcuti1.Text) -
Val(txtizin1.Text) - Val(txtsts1.Text)
End Sub
Private Sub txtizin1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtizin1.TextChanged
txtsisacuti1.Text = Val(txtambilcuti1.Text) + Val(txtizin1.Text) +
Val(txtsts1.Text) + Val(txtambilcuti1.Text)
End Sub
Private Sub txtsts1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtsts1.TextChanged
txtsisacuti1.Text = Val(txtsemester1.Text) - Val(txtambilcuti1.Text) -
Val(txtizin1.Text) - Val(txtsts1.Text)
End Sub
Private Sub txtambilcuti2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtambilcuti2.TextChanged
txtsisacuti2.Text = Val(txtsemester2.Text) - Val(txtambilcuti2.Text) -
Val(txtizin2.Text) - Val(txtsts2.Text)
End Sub
Private Sub txtsisacuti2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtsisacuti2.TextChanged
txtsisacuti2.Text = Val(txtsemester2.Text) - Val(txtambilcuti2.Text) -
Val(txtizin2.Text) - Val(txtsts2.Text)
End Sub
Private Sub txtizin2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtizin2.TextChanged
txtsisacuti2.Text = Val(txtambilcuti2.Text) + Val(txtizin2.Text) +
Val(txtsts2.Text) + Val(txtambilcuti2.Text)
End Sub
Private Sub txtsts2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txtsts2.TextChanged
txtsisacuti2.Text = Val(txtsemester2.Text) - Val(txtambilcuti2.Text) -
Val(txtizin2.Text) - Val(txtsts2.Text)
End Sub
Private Sub txttotalsisacuti_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles txttotalsisacuti.TextChanged
txttotalsisacuti.Text = Val(txtsisacuti1.Text) + Val(txtsisacuti2.Text)
End Sub
Private Sub btnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btnew.Click
Call bukakuncitext()
txtnik.Enabled = False
Txtcari.Enabled = False
btcari.Enabled = False
btsimpan.Enabled = True
dgvdatacuti.Enabled = False
btnew.Enabled = False
End Sub
Private Sub btcancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btcancel.Click
btnew.Enabled = False
Call kuncitext()
txtnik.Enabled = True
Txtcari.Enabled = True
btcari.Enabled = True
btsimpan.Enabled = False
dgvdatacuti.Enabled = True
Call clear()
txtnik.Focus()
btupdate.Enabled = False
btedit.Enabled = False
btdelete.Enabled = False
bttambah.Enabled = True
Call tampil()
End Sub
Private Sub btedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles btedit.Click
txtsemester1.Enabled = False
txtperiode1.Enabled = True
txtambilcuti1.Enabled = True
txtizin1.Enabled = True
txtsts1.Enabled = True
txtsisacuti1.Enabled = True
txtsemester2.Enabled = False
txtperiode2.Enabled = True
txtambilcuti2.Enabled = True
txtizin2.Enabled = True
txtsts2.Enabled = True
txtsisacuti2.Enabled = True
txttotalsisacuti.Enabled = True
btedit.Enabled = False
btupdate.Enabled = True
End Sub
Private Sub btdelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btdelete.Click
Call bthapus()
clear()
btkunci()
tampil()
txtnik.Enabled = True
bttambah.Enabled = True
txtnik.Focus()
End Sub
Private Sub Txtcari_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles Txtcari.KeyPress
If e.KeyChar = Chr(13) Then
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * from datacuti where nama_kader ='" &
Txtcari.Text & "'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
DA = New OleDbDataAdapter("select * From datacuti Where nama_kader Like
'%" & Txtcari.Text & "%'", Cn)
Ds = New DataSet
DA.Fill(Ds, "Ketemu Data")
dgvdatacuti.DataSource = Ds.Tables("Ketemu Data")
dgvdatacuti.ReadOnly = True
tampil()
Else
MsgBox("Data Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End If
End Sub
Private Sub Txtcari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Txtcari.TextChanged
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * From datacuti Where nama_kader Like '%" &
Txtcari.Text & "%'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
Call Koneksi()
DA = New OleDbDataAdapter("select * From datacuti Where nama_kader Like '%" &
Txtcari.Text & "%'", Cn)
Ds = New DataSet
DA.Fill(Ds, "Ketemu Data")
dgvdatacuti.DataSource = Ds.Tables("Ketemu Data")
dgvdatacuti.ReadOnly = True
Else
End If
End Sub
End Class
Koding new Data_Cuti_

Imports System.Data.OleDb
Public Class Data_Cuti_Kader
Sub kuncitext()
txtnama.Enabled = False
txtjabatan.Enabled = False
txtunitcabang.Enabled = False
dtpmasakerja.Enabled = False
txtlamakerja.Enabled = False
txtsemester1.Enabled = False
txtperiode1.Enabled = False
txtambilcuti1.Enabled = False
txtizin1.Enabled = False
txtsts1.Enabled = False
txtsisacuti1.Enabled = False
txtsemester2.Enabled = False
txtperiode2.Enabled = False
txtambilcuti2.Enabled = False
txtizin2.Enabled = False
txtsts2.Enabled = False
txtsisacuti2.Enabled = False
txttotalsisacuti.Enabled = False
End Sub
Sub clear()
txtnik.Text = ""
txtjabatan.Text = ""
txtunitcabang.Text = ""
txtnama.Text = ""
dtpmasakerja.Text = ""
txtlamakerja.Text = ""
txtsemester1.Text = ""
txtperiode1.Text = ""
txtambilcuti1.Text = ""
txtizin1.Text = ""
txtsts1.Text = ""
txtsisacuti1.Text = ""
txtsemester2.Text = ""
txtperiode2.Text = ""
txtambilcuti2.Text = ""
txtizin2.Text = ""
txtsts2.Text = ""
txtsisacuti2.Text = ""
txttotalsisacuti.Text = ""
txtcaridata.Text = ""
End Sub
Sub tampil()
Call Koneksi()
DA = New OleDbDataAdapter("Select * from datacuti", Cn)
Ds = New DataSet
DA.Fill(Ds, "datacuti")
dgvdatacuti.DataSource = Ds.Tables("datacuti")
End Sub
Sub bukakuncitext()
txtsemester1.Enabled = True
txtperiode1.Enabled = True
txtambilcuti1.Enabled = True
txtizin1.Enabled = True
txtsts1.Enabled = True
txtsisacuti1.Enabled = True
txtsemester2.Enabled = True
txtperiode2.Enabled = True
txtambilcuti2.Enabled = True
txtizin2.Enabled = True
txtsts2.Enabled = True
txtsisacuti2.Enabled = True
txttotalsisacuti.Enabled = True
End Sub
Sub btkunci()
btsimpan.Enabled = False
btfind.Enabled = False
btubah.Enabled = False
btdelete.Enabled = False
btedit.Enabled = False
btcancel.Enabled = False
End Sub
Sub simpan()
If txtnik.Text = "" Or txtjabatan.Text = "" Then
MsgBox("Data Belum Lengkap", MsgBoxStyle.Information, "Info")
Else
Call Koneksi() : Cn.Open()
Dim simpan As String = "INSERT INTO datacuti values ('" &
txtnik.Text & "','" &
txtnama.Text & "','" &
txtjabatan.Text & "','" &
txtunitcabang.Text & "','" &
dtpmasakerja.Value & "','" &
txtlamakerja.Text & "','" &
txtsemester1.Text & "','" &
txtperiode1.Text & "','" &
txtsisacuti1.Text & "','" &
txtizin1.Text & "','" &
txtsts1.Text & "','" &
txtsisacuti1.Text & "','" &
txtsemester2.Text & "','" &
txtperiode2.Text & "','" &
txtsisacuti2.Text & "','" &
txtizin2.Text & "','" &
txtsts2.Text & "','" &
txtsisacuti2.Text & "','" &
txttotalsisacuti.Text & "')"
CMD = New OleDbCommand(simpan, Cn)
CMD.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan", MsgBoxStyle.Information, "Sukses")
Cn.Dispose()
Cn.Close()
End If
End Sub
Sub tampiltexboxtbkaryawan()
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * from identitaskader where nik='" & txtnik.Text &
"'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
txtnik.Text = RD.Item("nik")
txtjabatan.Text = RD.Item("jabatan")
txtunitcabang.Text = RD.Item("unit_cabang")
txtnama.Text = RD.Item("nama_lengkap")
dtpmasakerja.Value = RD.Item("tgl_masuk")
txtlamakerja.Text = RD.Item("masakerja")
btfind.Enabled = True
btcancel.Enabled = True
Else
btfind.Enabled = False
btcancel.Enabled = False
MsgBox("Data Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End Sub
Sub tampiltexbox()
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * from datacuti where nik='" & Txtcari.Text & "'",
Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
txtnik.Text = RD.Item("nik")
txtjabatan.Text = RD.Item("jabatan")
txtunitcabang.Text = RD.Item("unit_cabang")
txtnama.Text = RD.Item("nama_kader")
dtpmasakerja.Value = RD.Item("tgl_masuk")
txtlamakerja.Text = RD.Item("masa_kerja")
txtsemester1.Text = RD.Item("semester1")
txtperiode1.Text = RD.Item("periode1")
txtambilcuti1.Text = RD.Item("total_cuti1")
txtizin1.Text = RD.Item("total_izin1")
txtsts1.Text = RD.Item("total_sts1")
txtsisacuti1.Text = RD.Item("sisa_cuti1")
txtsemester2.Text = RD.Item("semester2")
txtperiode2.Text = RD.Item("periode2")
txtambilcuti2.Text = RD.Item("total_cuti2")
txtizin2.Text = RD.Item("total_izin2")
txtsts2.Text = RD.Item("total_sts2")
txtsisacuti2.Text = RD.Item("sisa_cuti2")
txttotalsisacuti.Text = RD.Item("total_sisacuti")
Else
MsgBox("Data Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End Sub
Sub tbupdate()
If txtnik.Text = "" Or txtnama.Text = "" Or txtnama.Text = "" Or txtjabatan.Text
= "" Then
MsgBox("Data Belum Lengkap", MsgBoxStyle.Information, "Info")
Else
Call Koneksi() : Cn.Open()
Dim simpan As String = "UPDATE datacuti SET total_cuti1 = '" &
txtambilcuti1.Text & "', total_izin1 = '" &
txtizin1.Text & "', total_sts1= '" &
txtsts1.Text & "', sisa_cuti1 = '" &
txtsisacuti1.Text & "', total_cuti2 = '" &
txtambilcuti2.Text & "', total_izin2= '" &
txtizin2.Text & "',total_sts2 = '" &
txtsts2.Text & "', sisa_cuti2 = '" &
txtsisacuti2.Text & "', total_sisacuti= '" &
txttotalsisacuti.Text & "' " & _
"WHERE nik = '" & txtnik.Text & "'"
CMD = New OleDbCommand(simpan, Cn)
CMD.ExecuteNonQuery()
MsgBox("Data Berhasil Diperbaharui", MsgBoxStyle.Information, "Sukses")
Cn.Dispose()
Cn.Close()
End If
End Sub
Sub bthapus()
If MsgBox("Yakin akan menghapus data?", MsgBoxStyle.YesNo, _
"Konfirmasi") = MsgBoxResult.No Then Exit Sub

Dim myCommand As New OleDbCommand


Dim sql As String

Try
Call Koneksi() : Cn.Open()
sql = "DELETE FROM datacuti WHERE nik = " & _
"'" & dgvdatacuti.CurrentRow.Cells(0).Value & "'"

myCommand.Connection = Cn
myCommand.CommandText = sql
myCommand.ExecuteNonQuery()
MsgBox("Data terhapus")
Cn.Close()
Catch myerror As OleDbException
MessageBox.Show("Error: " & myerror.Message)
Finally
Cn.Dispose()
End Try
Call clear()
End Sub
Private Sub bttambah_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Call tampiltexboxtbkaryawan()
dgvdatacuti.Enabled = True
End Sub
Private Sub btsimpan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
simpan()
Call tampil()
txtnik.Enabled = True
bttambah.Enabled = True
txtcari.Enabled = True
btsimpan.Enabled = False
btcancel.Enabled = False
btcari.Enabled = True
Call clear()
kuncitext()
dgvdatacuti.Enabled = True
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * From datacuti Where nik Like '%" & txtcari.Text
& "%'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
Call Koneksi()
DA = New OleDbDataAdapter("select * From datacuti Where nik Like '%" &
txtcari.Text & "%'", Cn)
Ds = New DataSet
DA.Fill(Ds, "Ketemu Data")
dgvdatacuti.DataSource = Ds.Tables("Ketemu Data")
dgvdatacuti.ReadOnly = True
Else
MsgBox("NIK Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End Sub
Private Sub Data_Cuti_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Call Koneksi() : Cn.Open()
DA = New OleDbDataAdapter("Select*From datacuti", Cn)
Ds = New DataSet
Ds.Clear()
DA.Fill(Ds, "datacuti")
dgvdatacuti.DataSource = (Ds.Tables("datacuti"))
Cn.Close()
Cn.Dispose()
Call kuncitext()
Call btkunci()
btfind.Enabled = True
tampil()
End Sub
Private Sub dgvdatacuti_CellMouseDoubleClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellMouseEventArgs)
txtnik.Text = dgvdatacuti.CurrentRow.Cells(0).Value
txtnama.Text = dgvdatacuti.CurrentRow.Cells(1).Value
txtjabatan.Text = dgvdatacuti.CurrentRow.Cells(2).Value
txtunitcabang.Text = dgvdatacuti.CurrentRow.Cells(3).Value
dtpmasakerja.Value = dgvdatacuti.CurrentRow.Cells(4).Value
txtlamakerja.Text = dgvdatacuti.CurrentRow.Cells(5).Value
txtsemester1.Text = dgvdatacuti.CurrentRow.Cells(6).Value
txtperiode1.Text = dgvdatacuti.CurrentRow.Cells(7).Value
txtambilcuti1.Text = dgvdatacuti.CurrentRow.Cells(8).Value
txtizin1.Text = dgvdatacuti.CurrentRow.Cells(9).Value
txtsts1.Text = dgvdatacuti.CurrentRow.Cells(10).Value
txtsisacuti1.Text = dgvdatacuti.CurrentRow.Cells(11).Value
txtsemester2.Text = dgvdatacuti.CurrentRow.Cells(12).Value
txtperiode2.Text = dgvdatacuti.CurrentRow.Cells(13).Value
txtambilcuti2.Text = dgvdatacuti.CurrentRow.Cells(14).Value
txtizin2.Text = dgvdatacuti.CurrentRow.Cells(15).Value
txtsts2.Text = dgvdatacuti.CurrentRow.Cells(16).Value
txtsisacuti2.Text = dgvdatacuti.CurrentRow.Cells(17).Value
txttotalsisacuti.Text = dgvdatacuti.CurrentRow.Cells(18).Value
txtnik.Enabled = False
bttambah.Enabled = False
btedit.Enabled = True
btcancel.Enabled = True
btdelete.Enabled = True
End Sub
Private Sub btubah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Call tbupdate()
Call tampil()
End Sub
Private Sub txtambilcuti1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti1.Text = Val(txtsemester1.Text) - Val(txtambilcuti1.Text) -
Val(txtizin1.Text) - Val(txtsts1.Text)
End Sub
Private Sub txtsisacuti1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti1.Text = Val(txtsemester1.Text) - Val(txtambilcuti1.Text) -
Val(txtizin1.Text) - Val(txtsts1.Text)
End Sub
Private Sub txtizin1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti1.Text = Val(txtambilcuti1.Text) + Val(txtizin1.Text) +
Val(txtsts1.Text) + Val(txtambilcuti1.Text)
End Sub
Private Sub txtsts1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti1.Text = Val(txtsemester1.Text) - Val(txtambilcuti1.Text) -
Val(txtizin1.Text) - Val(txtsts1.Text)
End Sub
Private Sub txtambilcuti2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti2.Text = Val(txtsemester2.Text) - Val(txtambilcuti2.Text) -
Val(txtizin2.Text) - Val(txtsts2.Text)
End Sub
Private Sub txtsisacuti2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti2.Text = Val(txtsemester2.Text) - Val(txtambilcuti2.Text) -
Val(txtizin2.Text) - Val(txtsts2.Text)
End Sub
Private Sub txtizin2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti2.Text = Val(txtambilcuti2.Text) + Val(txtizin2.Text) +
Val(txtsts2.Text) + Val(txtambilcuti2.Text)
End Sub
Private Sub txtsts2_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txtsisacuti2.Text = Val(txtsemester2.Text) - Val(txtambilcuti2.Text) -
Val(txtizin2.Text) - Val(txtsts2.Text)
End Sub
Private Sub txttotalsisacuti_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs)
txttotalsisacuti.Text = Val(txtsisacuti1.Text) + Val(txtsisacuti2.Text)
End Sub
Private Sub btfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Call bukakuncitext()
txtnik.Enabled = False
txtcari.Enabled = False
btcari.Enabled = False
btsimpan.Enabled = True
dgvdatacuti.Enabled = False
btfind.Enabled = False
End Sub
Private Sub btcancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
btfind.Enabled = False
Call kuncitext()
txtnik.Enabled = True
txtcari.Enabled = True
btcari.Enabled = True
btsimpan.Enabled = False
dgvdatacuti.Enabled = True
Call clear()
txtnik.Focus()
btubah.Enabled = False
btedit.Enabled = False
btdelete.Enabled = False
bttambah.Enabled = True
Call tampil()
End Sub
Private Sub btedit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
txtsemester1.Enabled = False
txtperiode1.Enabled = True
txtambilcuti1.Enabled = True
txtizin1.Enabled = True
txtsts1.Enabled = True
txtsisacuti1.Enabled = True
txtsemester2.Enabled = False
txtperiode2.Enabled = True
txtambilcuti2.Enabled = True
txtizin2.Enabled = True
txtsts2.Enabled = True
txtsisacuti2.Enabled = True
txttotalsisacuti.Enabled = True
btedit.Enabled = False
btubah.Enabled = True
End Sub
Private Sub btdelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)
Call bthapus()
clear()
btkunci()
tampil()
txtnik.Enabled = True
bttambah.Enabled = True
txtnik.Focus()
End Sub
Private Sub Txtcari_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles Txtcari.KeyPress
If e.KeyChar = Chr(13) Then
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * from datacuti where nama_kader ='" &
Txtcari.Text & "'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
DA = New OleDbDataAdapter("select * From datacuti Where nama_kader Like
'%" & Txtcari.Text & "%'", Cn)
Ds = New DataSet
DA.Fill(Ds, "Ketemu Data")
dgvdatacuti.DataSource = Ds.Tables("Ketemu Data")
dgvdatacuti.ReadOnly = True
tampil()
Else
MsgBox("Data Tidak Ada", MsgBoxStyle.Information, "Info")
End If
End If
End Sub
Private Sub Txtcari_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Txtcari.TextChanged
Call Koneksi() : Cn.Open()
CMD = New OleDbCommand("select * From datacuti Where nama_kader Like '%" &
Txtcari.Text & "%'", Cn)
RD = CMD.ExecuteReader
RD.Read()
If RD.HasRows Then
Call Koneksi()
DA = New OleDbDataAdapter("select * From datacuti Where nama_kader Like '%" &
Txtcari.Text & "%'", Cn)
Ds = New DataSet
DA.Fill(Ds, "Ketemu Data")
dgvdatacuti.DataSource = Ds.Tables("Ketemu Data")
dgvdatacuti.ReadOnly = True
Else
End If
End Sub
End Class

You might also like