Tampilan Menu Utama Bagian Production Head Division
167 Tabel 4.40 Lanjutan Listing Program Data Barang
Listing Program Keterangan
Try con.Open
con.Close Catch
ex As
Exception MsgBox
Connection Error + ex.Message
End Try
End Sub
Sub tampil
Dim strSQL
As String
= SELECT FROM tabel_barang
Dim Da
As New
SqlDataAdapterstrSQL, con Dim
Dt As
New DataTable
Dim Bs
As New
BindingSource Da.FillDt
Bs.DataSource = Dt DataGridView1.DataSource = Bs
End Sub
Private Sub
Button2_Click ByVal
sender As
System.Object, ByVal
e As
System.EventArgs Handles
Button2.Click sintak menyimpan data ke database
Dim strSQL
As String
= INSERT INTO tabel_barang
values + TextBox1.Text +
, + DateTimePicker1.Text +
, +
TextBox2.Text + Try
Dim save
As New
SqlCommandstrSQL, con con.Open
save.ExecuteNonQuery MsgBox
Data Berhasil Disimpan ,
MsgBoxStyle.Information + MsgBoxStyle.OkOnly con.Close
Catch ex
As Exception
MsgBox Maaf Anda Gagal
+ ex.Message End
Try tampil
End Sub
Perintah Untuk Menyimpan Data Ke
Database
Private Sub
Button3_Click ByVal
sender As
System.Object, ByVal
e As
System.EventArgs Handles
Button3.Click Dim
nmTabel As
String =
tabel_barang Dim
strSQL As
String =
SELECT FROM tabel_barang WHERE kode LIKE
+ TextBox1.Text + Dim
Da As
New SqlDataAdapterstrSQL, con
Dim Dt
As New
DataTable Dim
Bs As
New BindingSource
Da.FillDt Bs.DataSource = Dt
DataGridView1.DataSource = Bs End
Sub Perintah Untuk
Mengedit Data Barang
168 Tabel 4.41 Lanjutan Listing Program Data Barang
Listing Program Keterangan
Private Sub
Button4_Click ByVal
sender As
System.Object, ByVal
e As
System.EventArgs Handles
Button4.Click Dim
ib As
Integer Dim
sql As
String ib = DataGridView1.CurrentRow.Index
sql = delete from tabel_barang where kode =
DataGridView1.Item0, ib.Value Try
Dim del
As New
SqlCommandsql, con con.Open
del.ExecuteNonQuery con.Close
Catch ex
As Exception
MsgBox data gagal dihapus
+ ex.Message End
Try tampil
End Sub
Perintah Untuk Menghapus Data
Barang