Tugas Kelompok
02 Mei 2017
kali ini kita akan membuat desain form beserta codingnya dengan menggunkan Visual Studio
1. Form Menu
Berikut codingnya:
-Form Menu
Public Class form_menu
Private Sub KeluarToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles KeluarToolStripMenuItem.Click
Close()
End Sub
Private Sub DataBarangToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DataBarangToolStripMenuItem.Click
form_barang.MdiParent = Me
form_barang.Show()
form_supplier.Hide()
End Sub
Private Sub DataSupplierToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DataSupplierToolStripMenuItem.Click
form_supplier.MdiParent = Me
form_supplier.Show()
form_pembelian.Hide()
End Sub
Private Sub DataPembelianToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles DataPembelianToolStripMenuItem.Click
form_pembelian.MdiParent = Me
form_pembelian.Show()
form_barang.Hide()
End Sub
End Class
2. Form Barang
Berikut codingnya:
-Form Barang
- #
Save
Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
buka_koneksi()
Sql = "insert into barang values ('" & kdbrg.Text & "', '" & nmbrg.Text & "', '" & jnsbrg.Text & "', '" & harga.Text & "', '" & jumlah.Text & "', '" & kadaluarsa.Text & "')"
comSQL = New SqlCommand(Sql, conn)
Try
comSQL.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan")
Catch ex As Exception
MsgBox("Data Gagal Disimpan
!!!")
End Try
Call updatedata()
Call bersih()
tutup_koneksi()
End Sub
-
#Edit
Private Sub btnedit_Click(sender As Object, e As EventArgs) Handles btnedit.Click
buka_koneksi()
Sql = "UPDATE barang SET nmbrg='" & nmbrg.Text & "', jnsbrg='" & jnsbrg.Text & "', harga='" & harga.Text & "', jumlah='" & jumlah.Text & "', kadaluarsa='" & kadaluarsa.Text & "' WHERE kdbrg='" & kdbrg.Text & "'"
comSQL = New SqlCommand(Sql, conn)
Try
comSQL.ExecuteNonQuery()
MsgBox("Update berhasil")
kdbrg.Enabled = True
btnsave.Enabled = True
Catch ex As Exception
MsgBox("Update gagal !!")
End Try
Call updatedata()
Call bersih()
tutup_koneksi()
End Sub
- #
Delete
Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
Dim pesan As String
pesan = MsgBox("Apakah Anda Ingin Menghapus
Data ini ?",
vbYesNo, "Konfirmasi")
If pesan = 6 Then
hapusbarang()
kdbrg.Enabled = True
btnsave.Enabled = True
End If
End Sub
-
#Laporan
Private Sub btnlap_Click(sender As Object, e As EventArgs) Handles btnlap.Click
laporanbrg.Show()
End Sub
-
#Close
Private Sub btnclose_Click(sender As Object, e As EventArgs) Handles btnclose.Click
Close()
End Sub
3. Form Supplier
Berikut codingnya:
-Form Supplier
-
#Edit
Imports System.Data.SqlClient
Public Class form_supplier
Sub updatedata()
buka_koneksi()
Sql = "select *from supplier"
Dim da As New SqlDataAdapter(Sql, conn)
Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable
For Each dt In ds.Tables
dgvsupplier.DataSource = dt
Next
tutup_koneksi()
End Sub
-
#Simpan
Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
buka_koneksi()
Sql = "insert into supplier values ('" & kdsup.Text & "', '" & nmsup.Text & "', '" & tgllhr.Text & "', '" & alamat.Text & "', '" & tlpkntr.Text & "', '" & cbjekel.Text & "', '" & email.Text & "', '" & txtjnsproduk.Text & "')"
comSQL = New SqlCommand(Sql, conn)
Try
comSQL.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan")
Catch ex As Exception
MsgBox("Data Gagal Disimpan
!!!")
End Try
Call updatedata()
Call bersih()
tutup_koneksi()
End Sub
-
#Hapus
Private Sub btndelete_Click(sender As Object, e As EventArgs) Handlesbtndelete.Click
Dim pesan As String
pesan = MsgBox("Apakah Anda Ingin Menghapus
Data ini ?",
vbYesNo, "Konfirmasi")
If pesan = 6 Then
hapussupplier()
kdsup.Enabled = True
btnsave.Enabled = True
End If
End Sub
-
#Laporan
Private Sub btnlaporan_Click(sender As Object, e As EventArgs) Handles btnlaporan.Click
lapsupplier.Show()
End Sub
-
#Close
Private Sub btnclose_Click(sender As Object, e As EventArgs) Handles btnclose.Click
Close()
End Sub
4. Form Pembelian
Berikut codingnya:
-form pembelian
-
#Save
Private Sub btnsave_Click(sender As Object, e As EventArgs) Handles btnsave.Click
buka_koneksi()
Sql = "insert into pembelian values ('" & nonota.Text & "', '" & kodebrg.Text & "', '" & kodesup.Text & "', '" & tglbeli.Text & "', '" & jumlahbeli.Text & "', '" & hargabeli.Text & "', '" & total.Text & "')"
comSQL = New SqlCommand(Sql, conn)
Try
comSQL.ExecuteNonQuery()
MsgBox("Data Berhasil Disimpan")
Catch ex As Exception
MsgBox("Data Gagal Disimpan
!!!")
End Try
Call updatedata()
Call bersih()
tutup_koneksi()
End Sub
-
#Edit
Private Sub btnedit_Click(sender As Object, e As EventArgs) Handles btnedit.Click
buka_koneksi()
Sql = "UPDATE supplier SET kdbrg='" & kodebrg.Text & "', kdsup='" & kodesup.Text & "', tanggalbeli='" & tglbeli.Text & "', jumlahbeli='" & jumlahbeli.Text & "', hargabeli='" & hargabeli.Text & "', total='" & total.Text & "' WHERE nonota='" & nonota.Text & "'"
comSQL = New SqlCommand(Sql, conn)
Try
comSQL.ExecuteNonQuery()
MsgBox("Update berhasil")
nonota.Enabled = True
btnsave.Enabled = True
Catch ex As Exception
MsgBox("Update gagal !!")
End Try
Call updatedata()
Call bersih()
tutup_koneksi()
End Sub
-
#Delete
Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
Dim pesan As String
pesan = MsgBox("Apakah Anda Ingin Menghapus
Data ini ?",
vbYesNo, "Konfirmasi")
If pesan = 6 Then
hapuspembelian()
nonota.Enabled = True
btnsave.Enabled = True
End If
End Sub
- #
Laporan
Private Sub btnlap_Click(sender As Object, e As EventArgs) Handles btnlap.Click
lappembelian.Show()
End Sub
-
#Close
Private Sub btnclose_Click(sender As Object, e As EventArgs) Handles btnclose.Click
Close()
End Sub