Yuk! Belajar Pemrograman Visual Basic dot Net Di Mesran.Net

Standar

SISTEM INFORMASI PEREKRUTAN KARYAWAN PADA PT.WIRASTAMA ABADI

FORM MENU DATA PELAMAR

Image

LISTING PROGRAM

Imports MySql.Data.MySqlClient

Public Class Form1

Public db As New MySql.Data.MySqlClient.MySqlConnection

Public sql As String

Public cmd As MySqlCommand

Public rs As MySqlDataReader

Sub opendb()

sql = “server=localhost;uid=root;pwd;database=pelamar”

Try

db.ConnectionString = sql

db.Open()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

Sub bersih()

kodepelamar.Text = “”

nama.Text = “”

alamat.Text = “”

pendidikan.Text = “”

RubahButton(True, False, False, False, True)

kodepelamar.Enabled = True

End Sub

Sub RubahButton(ByVal Btn1 As Boolean, ByVal Btn2 As Boolean, ByVal Btn3 As Boolean, ByVal Btn4 As Boolean, ByVal Btn5 As Boolean)

BtnBaru.Enabled = Btn1

BtnSimpan.Enabled = Btn2

BtnHapus.Enabled = Btn3

btnbatal.Enabled = Btn4

btnkeluar.Enabled = Btn5

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 Btnbaru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbaru.Click

Call bersih()

kodepelamar.Focus()

End Sub

Private Sub kodepelamar_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles kodepelamar.KeyPress

Dim tombol As Integer = Asc(e.KeyChar)

If tombol = 13 Then

Dim x As String

If kodepelamar.Text = “” Then

MsgBox(“Isi kode terlebih dahulu”)

Else

sql = “select * from pelamar where kode_pelamar='” & kodepelamar.Text & “‘”

cmd = New MySqlCommand(sql, db)

rs = cmd.ExecuteReader

Try

Call ShowDB()

Catch ex As Exception

x = kodepelamar.Text

bersih()

kodepelamar.Text = x

RubahButton(False, True, False, True, False)

btnsimpan.Text = “Simpan”

End Try

nama.Focus()

rs.Close()

End If

End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Call opendb()

Call bersih()

Call BuatTabel()

Call IsiTabel()

End Sub

Private Sub Btnbatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

Call bersih()

kodepelamar.Focus()

End Sub

Sub prosesdb(ByVal log As Integer)

Dim pesan As String = “”

Select Case log

Case 0

sql = “Insert into data pelamar(kode pelamar,nama,alamat,pendidikan)” & _

” values(‘” & kodepelamar.Text & _

“‘,'” & nama.Text & _

“‘,'” & alamat.Text & _

“‘,'” & pendidikan.Text & “‘)”

pesan = “Data Telah Tersimpan”

Case 1

sql = “update data pelamar set Nama='” & nama.Text & “‘, ” & _

“alamat='” & alamat.Text & “‘,” & _

“pendidikan='” & pendidikan.Text & “‘ ” & _

“where kode pelamar='” & kodepelamar.Text & “‘”

pesan = “Data Telah Terupdate”

Case 2

sql = “Delete from data pelamar where ='” & kodepelamar.Text & “‘”

pesan = “Data Telah Dihapus”

End Select

Try

cmd = New MySqlCommand(sql, db)

cmd.ExecuteNonQuery()

MsgBox(pesan, MsgBoxStyle.Information + MsgBoxStyle.OkOnly, “Konfirmasi”)

Call bersih()

Call IsiTabel()

Catch ex As Exception

MessageBox.Show(ex.Message)

End Try

End Sub

Sub ShowDB()

rs.Read()

kodepelamar.Text = rs(“kode pelamar”)

nama.Text = rs(“Nama”)

alamat.Text = rs(“jenjang”)

pendidikan.Text = rs(“jurusan”)

RubahButton(False, True, True, True, False)

btnsimpan.Text = “Edit”

kodepelamar.Enabled = False

End Sub

Sub BuatTabel()

Lv.Columns.Add(“kode pelamar”, 80, HorizontalAlignment.Center)

Lv.Columns.Add(“Nama”, 180, HorizontalAlignment.Left)

Lv.Columns.Add(“alamat”, 80, HorizontalAlignment.Left)

Lv.Columns.Add(“pendidikan”, 100, HorizontalAlignment.Left)

Lv.GridLines = True

Lv.FullRowSelect = True

Lv.View = View.Details

End Sub

Sub IsiTabel()

Lv.Items.Clear()

sql = “Select * from kode_pelamar”

cmd = New MySqlCommand(sql, db)

rs = cmd.ExecuteReader

Try

While rs.Read

Dim lst As New ListViewItem

lst.Text = rs(“kode pelamar”)

lst.SubItems.Add(rs(“Nama”))

lst.SubItems.Add(rs(“alamat”))

lst.SubItems.Add(rs(“pendidikan”))

Lv.Items.Add(lst)

End While

Catch ex As Exception

MsgBox(ex.Message)

End Try

rs.Close()

End Sub

Private Sub Btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click

Dim x As String

x = MsgBox(“Anda Yakin Akan dihapus”, MsgBoxStyle.Information + MsgBoxStyle.YesNo, “Hapus”)

If x = vbYes Then

Call prosesdb(2)

End If

End Sub

Private Sub BtnSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click

If btnsimpan.Text = “Simpan” Then prosesdb(0) Else prosesdb(1)

End Sub

End Class

FORM MENU

Image

LISTING PROGRAM

Public Class Form2

Private Sub DataPelamarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataPelamarToolStripMenuItem.Click

Form1.Show()

End Sub

Private Sub LapdataPelamarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LapdataPelamarToolStripMenuItem.Click

Dim laporan As New Rptpelamar

cetak.CrystalReportViewer1.ReportSource = laporan

cetak.Show()

End Sub

Private Sub KeluarProgramToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarProgramToolStripMenuItem.Click

End

End Sub

End Class

FORM  MENU CETAK

Image

HASILNYA

Image

DATABASENYA

Image

 

DEMIKIANLAH POSTINGAN SAYA NAMA:SUSANTI NPM: 1102086

Selamat Belajar VB Net

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s