0% found this document useful (0 votes)
12 views2 pages

Koding Simpan

The document contains code for various button click events in a Windows Forms application for performing CRUD (create, read, update, delete) operations on a database table. Specifically it includes code: 1) For a "Simpan" (Save) button that adds a new record to the table and updates the database. 2) For a "Hapus" (Delete) button that deletes a selected record from the table and updates the database after user confirmation. 3) For a "Batal" (Cancel) button that clears all text boxes. 4) For a "Keluar" (Exit) button that closes the form after user confirmation. 5) To establish a connection

Uploaded by

Kuyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views2 pages

Koding Simpan

The document contains code for various button click events in a Windows Forms application for performing CRUD (create, read, update, delete) operations on a database table. Specifically it includes code: 1) For a "Simpan" (Save) button that adds a new record to the table and updates the database. 2) For a "Hapus" (Delete) button that deletes a selected record from the table and updates the database after user confirmation. 3) For a "Batal" (Cancel) button that clears all text boxes. 4) For a "Keluar" (Exit) button that closes the form after user confirmation. 5) To establish a connection

Uploaded by

Kuyah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Koding Simpan :

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


System.EventArgs) Handles Button1.Click
cari()
If ketemu = False Then
cm.AddNew()
cm.Position = dt.Rows.Count
dt.Rows(cm.Position).Item("kode") = Me.TextBox1.Text
dt.Rows(cm.Position).Item("username") = Me.TextBox2.Text
dt.Rows(cm.Position).Item("pass") = Me.TextBox3.Text
dt.Rows(cm.Position).Item("jabatan") = Me.TextBox4.Text
da.Update(dt)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
Else
Dim simpan As Integer
simpan = MessageBox.Show("Data tidak ada, replace?", "pesan simpan",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If simpan = DialogResult.No Then
Exit Sub
End If
End If
End Sub

Koding Hapus :

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


System.EventArgs) Handles Button2.Click
cari()
If ketemu = False Then
MessageBox.Show("Data tidak ada, replace?", "pesan hapus",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim hapus As Integer
hapus = MessageBox.Show("Data Yakin di hapus?", "pesan hapus",
MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If hapus = DialogResult.Yes Then
cm.RemoveAt(cm.Position)
da.Update(dt)
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Focus()
cm.Position = cm.Count
End If
End Sub

Koding Batal :

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


System.EventArgs) Handles Button3.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox1.Focus()
End Sub

Koding Keluar :

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


System.EventArgs) Handles Button4.Click
If MessageBox.Show("Anda Ingin Keluar?", "Pesan", MessageBoxButtons.YesNo)
= Windows.Forms.DialogResult.Yes Then
Me.Close()
End If
End Sub

Koding Connection :

Dim cn As New OleDbConnection("provider=microsoft.jet.Oledb.4.0;Data Source=D:/TA


Azka/projek penggajian/projek penggajian/projek
penggajian/bin/x86/Debug/perpus2.mdb")
Dim da As New OleDbDataAdapter("select*from pegawai", cn)
Dim cb As New OleDbCommandBuilder(da)
Dim dt As New DataTable("pegawai")
Dim cm As CurrencyManager = Me.BindingContext(dt)
Dim n As Integer
Dim ketemu As Boolean

You might also like