Anda di halaman 1dari 35

Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Langkah-Langkah Install Software XAMPP

1. Dobel klik file XAMPP, kemudian akan muncul jendela “installer language” seperti di bawah
ini:

2. Selanjutnya pilih bahasa. Pilih yang Bahasa Inggris (English). Klik OK.
3. Kadang pada proses ini muncul pesan error. Jika ada, abaikan saja dan lanjutkan dengan klik
OK dan YES.

4. Berikutnya akan muncul jendela yang isinya meminta Anda menutup semua aplikasi yang
sedang berjalan. Jika semua aplikasi sudah ditutup, maka klik tombol Next.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


5. Selanjutnya Anda akan diminta untuk memilih aplikasi yang mau diinstal. Centang saja
semua pilihan dan klik tombol Next.

6. Kemudian Anda akan diminta untuk menentukan lokasi folder penyimpanan file-file dan
folder XAMPP. Secara default akan diarahkan ke lokasic:\xampp. Namun jika Anda ingin
menyimpannya di folder lain bisa klik browse dan tentukan secara manual folder yang ingin
digunakan. Jika sudah selesai, lanjutkan dan klik tombol Install.

7. Tunggu beberapa menit hingga proses intalasi selesai. Jika sudah muncul jendela seperti di
bawah ini, klik tombol Finish untuk menyelesaikannya.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


8. Berikutnya, akan muncul jendela dialog seperti gambar di bawah ini yang menanyakan Anda
apakah mau langsung menjalankan aplikasi XAMPP atau tidak. Jika ya, maka klik YES.

9. Setelah terbuka, silahkan klik tombol Start pada kolom Action sehingga tombol tersebut
berubah menjadi Stop. Dengan mengklik tombol tersebut, artinya itulah aplikasi yang
dijalankan. Biasanya jika saya menggunakan XAMPP, yang saya start hanyalah aplikasi
Apache dan MySQL, karena saya tidak memerlukan aplikasi seperti Filezilla, dan lain-lain.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Langkah-Langkah Install Visual Studio 2010

1. Klik “Install Microsoft Visual Studio 2010”

2. Klik “Next”

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


3. Kemudian Pilih “I have read and accept the licence terms” lalu klik “Next”

4. Kemudian Anda akan diminta untuk menentukan lokasi folder penyimpanan dari software
Visual Studio 2010. Secara default akan diarahkan ke lokasi c:\Program Files\Microsoft Visual
Studio 10.0\. Namun jika Anda ingin menyimpannya di folder lain bisa klik browse dan
tentukan secara manual folder yang ingin digunakan. Jika sudah selesai, pilih Select feature
to install “Full” kemudian klik “Next”.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


5. Setelah itu tunggu beberapa menit sampai semua terinstall.

6. Visual Studio 2010 Ultimate berhasil diinstal lalu klik “Finish”.

7. Sesudah menginstal Visual Studio 2010, sekarang kita buat sebuah database nya melalui
“cmd” atau bisa tekan “windows+R” dan juga jangan lupa untuk mengaktifkan XAMPP.
Kemudian isi:
“cd c:\xampp\mysql\bin” > Enter
“mysql -u root” > Enter
“use data_pegawai1;” > Enter

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


8. Selanjutkan kita buat tablenya. Gambar di bawah ini adalah Table Pegawai.

9. Gambar di bawah ini adalah Table Bagian.

10. Gambar di bawah ini adalah Table Jabatan.

11. Gambar di bawah ini adalah Table Login.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


12. Gambar di bawah ini adalah Table Gaji.

13. Agar bisa terkoneksi antara VB.Net dengan MySQL, kita perlu menginstal Driver
ODBC versi 3.15 atau yang terbaru lalu Klik “Next”.

14. Klik “Next”.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


15. Klik “Instal”.

16. Tunggu Progressnya, Kalau muncul seperti yang dibawah Pilih Yes.

17. Aplikasi mysql connector berhasil di Instal lalu Klik “Finish”.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


18. Sesudah membuat database nya. Sekarang kita buka Software Visual Studio 2010. Berikut
tampilan awal Visual Studio 2010.

19. Selanjutnya klik File – New Project atau bisa Ketik “Ctrl+N” untuk membuat aplikasi.

20. Isikan Name “Data_Pegawai_Baru” kemudian klik “Ok”.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


21. Setelah itu kita buat Form “Pegawai” yang berisikan 10 buah Label, 7 buah TextBox, 2 buah
ComboBox, 6 Buah Button dan 1 buah DataGridView.

Coding untuk Form Pegawai:

Imports MySql.Data.MySqlClient
Public Class Pegawai
Sub aturDGV()
Try
DataGridView1.Columns(0).Width = 100
DataGridView1.Columns(1).Width = 100
DataGridView1.Columns(2).Width = 100
DataGridView1.Columns(3).Width = 100
DataGridView1.Columns(4).Width = 100
DataGridView1.Columns(5).Width = 100
DataGridView1.Columns(6).Width = 100
DataGridView1.Columns(7).Width = 100
DataGridView1.Columns(8).Width = 100

DataGridView1.Columns(0).HeaderText = "iD_PEGAWAI"
DataGridView1.Columns(1).HeaderText = "NIP"
DataGridView1.Columns(2).HeaderText = "NAMA_PEGAWAI"
DataGridView1.Columns(3).HeaderText = "KODE_JABATAN"
DataGridView1.Columns(4).HeaderText = "KODE_BAGIAN"
DataGridView1.Columns(5).HeaderText = "Alamat"
DataGridView1.Columns(6).HeaderText = "JENIS_KELAMIN"
DataGridView1.Columns(7).HeaderText = "STATUS"
DataGridView1.Columns(8).HeaderText = "JUMLAH_ANAK"
Catch ex As Exception
End Try
End Sub

Sub tampildata_pegawai_baru()
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


ComboBox1.ResetText()
ComboBox2.ResetText()
TextBox7.ResetText()
Call koneksi()
da = New MySqlDataAdapter("select * from pegawai", conn)
ds = New DataSet
da.Fill(ds, "pegawai")
DataGridView1.DataSource = ds.Tables("pegawai")
End Sub

Dim DATABARU As Boolean


Private Sub isi(ByVal x As Integer)
TextBox1.Text = DataGridView1.Rows(x).Cells(0).Value
TextBox2.Text = DataGridView1.Rows(x).Cells(1).Value
TextBox3.Text = DataGridView1.Rows(x).Cells(2).Value
TextBox4.Text = DataGridView1.Rows(x).Cells(3).Value
TextBox5.Text = DataGridView1.Rows(x).Cells(4).Value
TextBox6.Text = DataGridView1.Rows(x).Cells(5).Value
ComboBox1.Text = DataGridView1.Rows(x).Cells(6).Value
ComboBox2.Text = DataGridView1.Rows(x).Cells(7).Value
TextBox7.Text = DataGridView1.Rows(x).Cells(8).Value
End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
isi(e.RowIndex)
DATABARU = False
End Sub

Private Sub Pegawai_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
DATABARU = False
Call aturDGV()
Call tampildata_pegawai_baru()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Call koneksi()
Try
Dim str As String
str = "insert into pegawai values('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text
& "','" & TextBox6.Text & "','" & ComboBox1.Text & "','" & ComboBox2.Text & "','" &
TextBox7.Text & "')"
cmd = New MySqlCommand(str, conn)
cmd.ExecuteNonQuery()
MessageBox.Show(" Insert Data Pegawai Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Insert Data Pegawai Gagal Dimasukkan")

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Call koneksi()
Try
Dim edit As String
edit = "update Pegawai set NIP ='" & TextBox2.Text & "',NAMA_PEGAWAI ='" &
TextBox3.Text & "',KODE_JABATAN ='" & TextBox4.Text & "',KODE_BAGIAN ='" &
TextBox5.Text & "',ALAMAT ='" & TextBox6.Text & "',JENIS_KELAMIN ='" & ComboBox1.Text
& "',STATUS ='" & ComboBox2.Text & "',JUMLAH_ANAK='" & TextBox7.Text & "' where
ID_PEGAWAI ='" & TextBox1.Text & "'"
cmd = New MySqlCommand(edit, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Update Data Pegawai Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Update Data Pegawai Gagal Dimasukkan")
End Try
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Call koneksi()
Try
Dim hapus As String
hapus = "delete from pegawai where pegawai.id_pegawai='" & TextBox1.Text &
"'"
cmd = New MySqlCommand(hapus, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Hapus Data Pegawai Berhasil")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Hapus Data Pegawai Gagal")
End Try
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Me.Hide()
Menu_Utama.Show()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Dim cari As String
cari = InputBox("Masukkan Id Yang Dicari")
If cari = "" Then
Exit Sub
End If

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Call koneksi()
Dim RS As MySqlDataReader
Dim aa As String
aa = "SELECT * FROM pegawai where Id_Pegawai='" & cari & "' "
cmd = New MySqlCommand(aa, conn)
RS = cmd.ExecuteReader()
If RS.Read Then
TextBox1.Text = RS("ID_PEGAWAI")
TextBox2.Text = RS("NIP")
TextBox3.Text = RS("NAMA_PEGAWAI")
TextBox4.Text = RS("KODE_JABATAN")
TextBox5.Text = RS("KODE_BAGIAN")
TextBox6.Text = RS("ALAMAT")
ComboBox1.Text = RS("JENIS_KELAMIN")
ComboBox2.Text = RS("STATUS")
TextBox7.Text = RS("JUMLAH_ANAK")
Else
MsgBox("Data Tidak Ada", vbInformation)
End If
RS.Close()
cmd.Dispose()
conn.Close()
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
ComboBox1.Enabled = False
ComboBox2.Enabled = False
TextBox7.Enabled = False
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
ComboBox1.Enabled = True
ComboBox2.Enabled = True
TextBox7.Enabled = True

TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
ComboBox1.ResetText()
ComboBox2.ResetText()
TextBox7.ResetText()
End Sub

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
If ComboBox2.Text = "BELUM MENIKAH" Then
TextBox7.Text = 0
ElseIf ComboBox2.Text = "SUDAH MENIKAH" Then
TextBox7.Text = ""
End If
End Sub
End Class

22. Setelah itu kita buat Form “Bagian” yang berisikan 5 buah Label, 4 buah TextBox, 6 Buah
Button dan 1 buah DataGridView.

Coding untuk Form Bagian:

Imports MySql.Data.MySqlClient
Public Class Bagian
Sub aturDGV()
Try
DataGridView1.Columns(0).Width = 100
DataGridView1.Columns(1).Width = 100
DataGridView1.Columns(2).Width = 100
DataGridView1.Columns(3).Width = 100

DataGridView1.Columns(0).HeaderText = "ID_BAGIAN"
DataGridView1.Columns(1).HeaderText = "KODE_BAGIAN"
DataGridView1.Columns(2).HeaderText = "ID_PEGAWAI"
DataGridView1.Columns(3).HeaderText = "NAMA_BAGIAN"
Catch ex As Exception
End Try
End Sub

Sub tampildata_pegawai_baru()
TextBox1.ResetText()
TextBox2.ResetText()

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


TextBox3.ResetText()
TextBox4.ResetText()
Call koneksi()
da = New MySqlDataAdapter("select * from bagian", conn)
ds = New DataSet
da.Fill(ds, "bagian")
DataGridView1.DataSource = ds.Tables("bagian")
End Sub

Dim DATABARU As Boolean


Private Sub isi(ByVal x As Integer)
TextBox1.Text = DataGridView1.Rows(x).Cells(0).Value
TextBox2.Text = DataGridView1.Rows(x).Cells(1).Value
TextBox3.Text = DataGridView1.Rows(x).Cells(2).Value
TextBox4.Text = DataGridView1.Rows(x).Cells(3).Value
End Sub

Private Sub Bagian_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
DATABARU = False
Call aturDGV()
Call tampildata_pegawai_baru()
End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
isi(e.RowIndex)
DATABARU = False
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Call koneksi()
Try
Dim str As String
str = "insert into bagian values('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
cmd = New MySqlCommand(str, conn)
cmd.ExecuteNonQuery()
MessageBox.Show(" Insert Data Bagian Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Insert Data Bagian Gagal Dimasukkan")
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Call koneksi()
Try
Dim edit As String

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


edit = "update Bagian set KODE_BAGIAN ='" & TextBox2.Text & "',ID_PEGAWAI ='" &
TextBox3.Text & "',NAMA_BAGIAN ='" & TextBox4.Text & "' where ID_BAGIAN ='" &
TextBox1.Text & "'"
cmd = New MySqlCommand(edit, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Update Data Bagian Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Update Data Bagian Gagal Dimasukkan")
End Try
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Call koneksi()
Try
Dim hapus As String
hapus = "delete from bagian where bagian.id_bagian='" & TextBox1.Text &
"'"
cmd = New MySqlCommand(hapus, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Hapus Data Bagian Berhasil")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Hapus Data Bagian Gagal")
End Try
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Dim cari As String
cari = InputBox("Masukkan Id Yang Dicari")
If cari = "" Then
Exit Sub
End If

Call koneksi()
Dim RS As MySqlDataReader
Dim aa As String
aa = "SELECT * FROM bagian where Id_Bagian='" & cari & "' "
cmd = New MySqlCommand(aa, conn)
RS = cmd.ExecuteReader()
If RS.Read Then
TextBox1.Text = RS("ID_BAGIAN")
TextBox2.Text = RS("KODE_BAGIAN")
TextBox3.Text = RS("ID_PEGAWAI")
TextBox4.Text = RS("NAMA_BAGIAN")
Else
MsgBox("Data Tidak Ada", vbInformation)
End If
RS.Close()

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


cmd.Dispose()
conn.Close()
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True

TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Me.Hide()
Menu_Utama.Show()
End Sub
End Class

23. Setelah itu kita buat Form “Jabatan” yang berisikan 5 buah Label, 4 buah TextBox, 6 Buah
Button dan 1 buah DataGridView.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :

Coding untuk Form Jabatan:

Imports MySql.Data.MySqlClient
Public Class Jabatan
Sub aturDGV()
Try
DataGridView1.Columns(0).Width = 100
DataGridView1.Columns(1).Width = 100
DataGridView1.Columns(2).Width = 100
DataGridView1.Columns(3).Width = 100

DataGridView1.Columns(0).HeaderText = "ID_JABATAN"
DataGridView1.Columns(1).HeaderText = "KODE_JABATAN"
DataGridView1.Columns(2).HeaderText = "ID_PEGAWAI"
DataGridView1.Columns(3).HeaderText = "NAMA_JABATAN"
Catch ex As Exception
End Try
End Sub

Sub tampildata_pegawai_baru()
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
Call koneksi()
da = New MySqlDataAdapter("select * from jabatan", conn)
ds = New DataSet
da.Fill(ds, "jabatan")
DataGridView1.DataSource = ds.Tables("jabatan")
End Sub

Dim DATABARU As Boolean


Private Sub isi(ByVal x As Integer)
TextBox1.Text = DataGridView1.Rows(x).Cells(0).Value
TextBox2.Text = DataGridView1.Rows(x).Cells(1).Value
TextBox3.Text = DataGridView1.Rows(x).Cells(2).Value
TextBox4.Text = DataGridView1.Rows(x).Cells(3).Value
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Call koneksi()
Try
Dim str As String
str = "insert into jabatan values('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
cmd = New MySqlCommand(str, conn)
cmd.ExecuteNonQuery()
MessageBox.Show(" Insert Data Jabatan Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


MessageBox.Show("Insert Data Jabatan Gagal Dimasukkan")
End Try
End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
isi(e.RowIndex)
DATABARU = False
End Sub

Private Sub Jabatan_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
DATABARU = False
Call aturDGV()
Call tampildata_pegawai_baru()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Call koneksi()
Try
Dim edit As String
edit = "update Jabatan set KODE_JABATAN ='" & TextBox2.Text &
"',ID_PEGAWAI ='" & TextBox3.Text & "',NAMA_JABATAN ='" & TextBox4.Text & "' where
ID_JABATAN ='" & TextBox1.Text & "'"
cmd = New MySqlCommand(edit, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Update Data Jabatan Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Update Data Jabatan Gagal Dimasukkan")
End Try
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Call koneksi()
Try
Dim hapus As String
hapus = "delete from jabatan where jabatan.id_jabatan='" & TextBox1.Text &
"'"
cmd = New MySqlCommand(hapus, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Hapus Data Jabatan Berhasil")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Hapus Data Jabatan Gagal")
End Try
End Sub

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Dim cari As String
cari = InputBox("Masukkan Id Yang Dicari")
If cari = "" Then
Exit Sub
End If

Call koneksi()
Dim RS As MySqlDataReader
Dim aa As String
aa = "SELECT * FROM jabatan where Id_Jabatan='" & cari & "' "
cmd = New MySqlCommand(aa, conn)
RS = cmd.ExecuteReader()
If RS.Read Then
TextBox1.Text = RS("ID_JABATAN")
TextBox2.Text = RS("KODE_JABATAN")
TextBox3.Text = RS("ID_PEGAWAI")
TextBox4.Text = RS("NAMA_JABATAN")
Else
MsgBox("Data Tidak Ada", vbInformation)
End If
RS.Close()
cmd.Dispose()
conn.Close()
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
TextBox4.Enabled = True

TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
TextBox4.ResetText()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Me.Hide()
Menu_Utama.Show()
End Sub
End Class

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


24. Setelah itu kita buat Form “Login” yang berisikan 3 buah Label, 2 buah TextBox dan 2 Buah
Button.

Coding untuk Form Login:

Public Class Login

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Me.Close()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If TextBox1.Text = "sensei" And TextBox2.Text = "sensei" Then
Menu_Utama.Show()
Me.Hide()
Else
MsgBox("Username atau Password Anda Salah")
End If
End Sub
End Class

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


25. Setelah itu kita buat Form “Gaji” yang berisikan 10 buah Label, 8 buah TextBox,7 Buah
Button dan 1 buah DataGridView.

Coding untuk Form Gaji:

Imports MySql.Data.MySqlClient
Public Class Gaji
Sub aturDGV()
Try
DataGridView1.Columns(0).Width = 100
DataGridView1.Columns(1).Width = 100
DataGridView1.Columns(2).Width = 100
DataGridView1.Columns(3).Width = 100
DataGridView1.Columns(4).Width = 100
DataGridView1.Columns(5).Width = 100
DataGridView1.Columns(6).Width = 100
DataGridView1.Columns(7).Width = 100
DataGridView1.Columns(8).Width = 100

DataGridView1.Columns(0).HeaderText = "ID_GAJI"
DataGridView1.Columns(1).HeaderText = "ID_PEGAWAI"
DataGridView1.Columns(2).HeaderText = "GAJI_POKOK"
DataGridView1.Columns(3).HeaderText = "STATUS"
DataGridView1.Columns(4).HeaderText = "JUMLAH_ANAK"
DataGridView1.Columns(5).HeaderText = "PAJAK"
DataGridView1.Columns(6).HeaderText = "TUNJANGAN_KELUARGA"
DataGridView1.Columns(7).HeaderText = "TUNJANGAN_ANAK"
DataGridView1.Columns(8).HeaderText = "TOTAL_GAJI"
Catch ex As Exception
End Try
End Sub

Sub tampildata_pegawai_baru()
TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


ComboBox1.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
TextBox7.ResetText()
TextBox8.ResetText()
Call koneksi()
da = New MySqlDataAdapter("select * from gaji", conn)
ds = New DataSet
da.Fill(ds, "gaji")
DataGridView1.DataSource = ds.Tables("gaji")
End Sub

Dim DATABARU As Boolean


Private Sub isi(ByVal x As Integer)
TextBox1.Text = DataGridView1.Rows(x).Cells(0).Value
TextBox2.Text = DataGridView1.Rows(x).Cells(1).Value
TextBox3.Text = DataGridView1.Rows(x).Cells(2).Value
ComboBox1.Text = DataGridView1.Rows(x).Cells(3).Value
TextBox4.Text = DataGridView1.Rows(x).Cells(4).Value
TextBox5.Text = DataGridView1.Rows(x).Cells(5).Value
TextBox6.Text = DataGridView1.Rows(x).Cells(6).Value
TextBox7.Text = DataGridView1.Rows(x).Cells(7).Value
TextBox8.Text = DataGridView1.Rows(x).Cells(8).Value
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button7.Click
Call koneksi()
Try
Dim str As String
str = "insert into gaji values('" & TextBox1.Text & "','" & TextBox2.Text
& "','" & TextBox3.Text & "','" & ComboBox1.Text & "','" & TextBox4.Text & "','" &
TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text
& "')"
cmd = New MySqlCommand(str, conn)
cmd.ExecuteNonQuery()
MessageBox.Show(" Insert Data Gaji Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Insert Data Gaji Gagal Dimasukkan")
End Try
End Sub

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
isi(e.RowIndex)
DATABARU = False
End Sub

Private Sub Gaji_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
DATABARU = False

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Call aturDGV()
Call tampildata_pegawai_baru()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Call koneksi()
Try
Dim edit As String
edit = "update Gaji set ID_PEGAWAI ='" & TextBox2.Text & "',GAJI_POKOK ='"
& TextBox3.Text & "',STATUS ='" & ComboBox1.Text & "',JUMLAH_ANAK ='" & TextBox4.Text
& "',PAJAK ='" & TextBox5.Text & "',TUNJANGAN_KELUARGA ='" & TextBox6.Text &
"',TUNJANGAN_ANAK ='" & TextBox7.Text & "',TOTAL_GAJI='" & TextBox8.Text & "' where
ID_GAJI ='" & TextBox1.Text & "'"
cmd = New MySqlCommand(edit, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Update Data Gaji Berhasil Dimasukkan")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Update Data Gaji Gagal Dimasukkan")
End Try

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Call koneksi()
Try
Dim hapus As String
hapus = "delete from gaji where gaji.id_gaji='" & TextBox1.Text & "'"
cmd = New MySqlCommand(hapus, conn)
cmd.ExecuteNonQuery()
MessageBox.Show("Hapus Data Gaji Berhasil")
TextBox1.Text = TextBox1.Text + 1
Call aturDGV()
Call tampildata_pegawai_baru()
Catch ex As Exception
MessageBox.Show("Hapus Data Gaji Gagal")
End Try

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
Dim cari As String
cari = InputBox("Masukkan Id Yang Dicari")
If cari = "" Then
Exit Sub
End If

Call koneksi()
Dim RS As MySqlDataReader
Dim aa As String

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


aa = "SELECT * FROM gaji where Id_Gaji='" & cari & "' "
cmd = New MySqlCommand(aa, conn)
RS = cmd.ExecuteReader()
If RS.Read Then
TextBox1.Text = RS("ID_GAJI")
TextBox2.Text = RS("ID_PEGAWAI")
TextBox3.Text = RS("GAJI_POKOK")
ComboBox1.Text = RS("STATUS")
TextBox4.Text = RS("JUMLAH_ANAK")
TextBox5.Text = RS("PAJAK")
TextBox6.Text = RS("TUNJANGAN_KELUARGA")
TextBox7.Text = RS("TUNJANGAN_ANAK")
TextBox8.Text = RS("TOTAL_GAJI")
Else
MsgBox("Data Tidak Ada", vbInformation)
End If
RS.Close()
cmd.Dispose()
conn.Close()
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
ComboBox1.Enabled = False
TextBox4.Enabled = False
TextBox5.Enabled = False
TextBox6.Enabled = False
TextBox7.Enabled = False
TextBox8.Enabled = False

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
ComboBox1.Enabled = True
TextBox4.Enabled = True
TextBox5.Enabled = True
TextBox6.Enabled = True
TextBox7.Enabled = True
TextBox8.Enabled = True

TextBox1.ResetText()
TextBox2.ResetText()
TextBox3.ResetText()
ComboBox1.ResetText()
TextBox4.ResetText()
TextBox5.ResetText()
TextBox6.ResetText()
TextBox7.ResetText()
TextBox8.ResetText()
End Sub

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Me.Hide()
Menu_Utama.Show()
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
If TextBox3.Text Then
TextBox5.Text = 10 / 100 * TextBox3.Text
End If
If TextBox4.Text = "1" Then
TextBox7.Text = 5 / 100 * TextBox3.Text
ElseIf TextBox4.Text = "2" Then
TextBox7.Text = 10 / 100 * TextBox3.Text
ElseIf TextBox4.Text = "0" Then
TextBox7.Text = 0
Else
TextBox7.Text = 10 / 100 * TextBox3.Text
End If
If ComboBox1.Text = "SUDAH MENIKAH" Then
TextBox6.Text = 15 / 100 * Val(TextBox3.Text)
Else
ComboBox1.Text = "BELUM MENIKAH"
TextBox6.Text = 0
TextBox7.Text = 0
End If
TextBox8.Text = Val(TextBox3.Text) + Val(TextBox6.Text) + Val(TextBox7.Text) -
Val(TextBox5.Text)

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text = "BELUM MENIKAH" Then
TextBox4.Text = 0
ElseIf ComboBox1.Text = "SUDAH MENIKAH" Then
TextBox4.Text = ""
End If
End Sub
End Class

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


26. Setelah itu kita buat Form “Menu Utama” yang berisikan 5 Buah Button.

Coding untuk Form Menu Utama:

Imports MySql.Data.MySqlClient
Public Class Menu_Utama
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim pesan = MessageBox.Show("Masuk Form Pegawai ?", "Menampilkan Form",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If pesan = Windows.Forms.DialogResult.Yes Then
Pegawai.Show()
Me.Hide()
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Dim pesan = MessageBox.Show("Masuk Form Jabatan ?", "Menampilkan Form",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If pesan = Windows.Forms.DialogResult.Yes Then
Jabatan.Show()
Me.Hide()
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
Dim pesan = MessageBox.Show("Masuk Form Bagian ?", "Menampilkan Form",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If pesan = Windows.Forms.DialogResult.Yes Then
Bagian.Show()

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Me.Hide()
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
Dim pesan = MessageBox.Show("Masuk Form Gaji ?", "Menampilkan Form",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If pesan = Windows.Forms.DialogResult.Yes Then
Gaji.Show()
Me.Hide()
End If
End Sub
End Class

27. Tambahkan ekstensi tambahan(Klik 2 kali pada My Project pada kolom Solution Explorer)
kemudian pilih “References” lalu klik “Add”.

28. Pilih “.NET” – “MySql.data” – Ok.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


29. Setelah itu kita buat module nya. Dengan cara klik Project – Add Module - Add.

30. Selanjutnya kita buat coding untuk Module. Berikut adalah Coding Module:
Imports MySql.Data.MySqlClient
Module Module1
Public conn As MySqlConnection
Public cmd As MySqlCommand
Public rd As MySqlDataReader
Public da As MySqlDataAdapter
Public ds As DataSet
Public dt As DataTable
Public str As String
Public edit As String
Sub koneksi()
Try
Dim str As String = "Server=localhost;user
id=root;database=Data_Pegawai1"
conn = New MySqlConnection(str)

If conn.State = ConnectionState.Closed Then


conn.Open()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Module

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


Langkah-langkah Membuat Report

1. Buat Form Baru (PROJECT – Add Windows Form – Add.

2. Klik pada ToolBox – Reporting – ReportViewer – Drag dan Drop Report Viewer.

3. Klik pada pojok ReportViewer – Design a New Report – New – Database – Next.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


4. Pilih DataSet – Next.

5. Klik New Connection.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


6. Pilih MySQL Database – OK.

7. Isi Kolom tersebut dengan benar seperti database di MySql kita.

8. Klik “Next”.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


9. Centang Tables – Finish.

10. Klik “Next”.

11. Klik “Next”.

Halaman :
Pertemuan ke : Paraf :

Materi : …………………………………….
Ketua Kelas :
…………………………………………………………………

LEMBAR KERJA PRAKTIKUM :


12. Pilih “Next” – Finish.

13. Hasil Report. Untuk membuat Hasil Report lainnya bisa mengikuti langkah-langkah diatas.

Halaman :