This document contains code for three button click events - one each for insert, update, and delete functions for employee data in a database table.
The insert button code validates the data is not empty, inserts the data into the database table, displays a success message, and clears the form fields.
The update button code validates the data, updates the selected record in the database table based on the primary key, displays a success message, clears the form fields, and refreshes the displayed data.
The delete button code confirms deletion with the user, deletes the selected record from the database table based on the primary key, displays a success message, clears the form fields, and refreshes the displayed
This document contains code for three button click events - one each for insert, update, and delete functions for employee data in a database table.
The insert button code validates the data is not empty, inserts the data into the database table, displays a success message, and clears the form fields.
The update button code validates the data, updates the selected record in the database table based on the primary key, displays a success message, clears the form fields, and refreshes the displayed data.
The delete button code confirms deletion with the user, deletes the selected record from the database table based on the primary key, displays a success message, clears the form fields, and refreshes the displayed
This document contains code for three button click events - one each for insert, update, and delete functions for employee data in a database table.
The insert button code validates the data is not empty, inserts the data into the database table, displays a success message, and clears the form fields.
The update button code validates the data, updates the selected record in the database table based on the primary key, displays a success message, clears the form fields, and refreshes the displayed data.
The delete button code confirms deletion with the user, deletes the selected record from the database table based on the primary key, displays a success message, clears the form fields, and refreshes the displayed
Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ButtonX1.Click If txtnmkaryawan.Text = "" Or txtalamatkaryawan.Text = "" Then MsgBox("Data Masih Ada yang Kosong !", MsgBoxStyle.Critical, "Kesalahan") txtnmkaryawan.Focus() Else If txtkdkaryawan.Enabled = False Then koneksi.Close() buka() cmd.Connection = koneksi cmd.CommandType = CommandType.Text cmd.CommandText = "Insert into tbkaryawan (kdkaryawan,nmkaryawan,alamat,usernm,statuskrywn) values ('" & txtkdkaryawan.Text.Replace("'", "''") & "','" & txtnmkaryawan.Text.Replace("'", "''") & "','" & txtalamatkaryawan.Text.Replace("'", "''") & "','" & menuutama.ToolStripStatusLabel1.Text.Replace("'", "''") & "', '" & " NotAccess " & "')" cmd.ExecuteNonQuery() MsgBox("Sukses di Simpan !", MsgBoxStyle.Information, "Sukses") kosong()
End If End If End Sub
UPDATE
Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ButtonX1.Click If txtnmkaryawan.Text = "" Or txtalamatkaryawan.Text = "" Then MsgBox("Data Masih Ada yang Kosong !", MsgBoxStyle.Critical, "Kesalahan") txtnmkaryawan.Focus() Else koneksi.Close() buka() cmd.Connection = koneksi cmd.CommandType = CommandType.Text cmd.CommandText = "update tbkaryawan set nmkaryawan = '" & txtnmkaryawan.Text.Replace("'", "''") & "', alamat = '" & txtalamatkaryawan.Text.Replace("'", "''") & "', usernm='" & menuutama.ToolStripStatusLabel1.Text.Replace("'", "''") & "' where kdkaryawan = '" & txtkdkaryawan.Text.Replace("'", "''") & "'" cmd.ExecuteNonQuery() MsgBox("Sukses di Update !", MsgBoxStyle.Information, "Sukses") kosong() tampil() End If End Sub
HAPUS
Private Sub ButtonX3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ButtonX1.Click If txtkdkaryawan.Enabled = True Then Dim pesan As String pesan = MsgBox("Yakin hapus Data?", MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Peringatan") If pesan = vbYes Then koneksi.Close() buka() cmd.Connection = koneksi cmd.CommandType = CommandType.Text cmd.CommandText = "delete from tbkaryawan where kdkaryawan = '" & txtkdkaryawan.Text.Replace("'", "''") & "'" cmd.ExecuteNonQuery() MsgBox("Data di Hapus !", MsgBoxStyle.Information, "Sukses") kosong() tampil() End If End If End Sub
Imports Imports Partial Class Inherits Dim As New Dim As New Dim As New Dim As String Dim As Boolean Dim As New Protected Sub Byval As Object Byval As Handles Me If Not Then