Sistem Informasi Pengiriman Kayu Menggunakan VB Net

Malam agan - agan semua....
sudah lama admin tidak posting, maklum lah lagi sibuk nyusun tugas akhir :D
hari ini admin mau share gimana caraya membuat Sistem Informasi pengiriman Barang menggunakan VB Net, sebekumnya admin sudah posting membuat module koneksi di vb net 2008, 
ini adalah lanjutan dari module sebelumnya, oh ia admin disini menggunakan database mysql.
ok saat nya dimulai
pertama rancang sebuah form seperti gambar dibawah ini :


form diiatas terdiri dari :
  1. lima buah button
  2. tujuh buah textbox
  3.  satu buah listview 
nama dari masing - masing komponen tersebut bisa anda sesuaikan dari koding dibawah ini :
Imports MySql.Data.MySqlClient
Public Class DataKayu
    Sub Bersih()
        BersihForm(Me)
        Kunci(Me)
        Simpan.ImageKey = "Simpan.Ico"
        RubahTombol(0, Baru, Simpan, Hapus, Batal, Keluar)
        Cari.Enabled = True
    End Sub
    Sub TampilData()
        LV.Items.Clear()
        SQL = "SELECT * FROM Kayu ORDER BY KodeKayu ASC "
        BacaData()
        While RS.Read
            Dim AZ As New ListViewItem
            With AZ
                .Text = RS("KodeKayu")
                .SubItems.Add(RS("JenisKayu"))
                .SubItems.Add(RS("Ukuran"))
                .SubItems.Add(RS("Harga"))
                .SubItems.Add(RS("Stok"))
                .SubItems.Add(RS("Satuan"))
                LV.Items.Add(AZ)
            End With
        End While
        RS.Close()
    End Sub
    Private Sub DataKayu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Bersih()
        TampilData()
    End Sub
    Private Sub Baru_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Baru.Click
        KodeKayu.Enabled = True
        KodeOtomatis(KodeKayu, "Kayu", "KodeKayu", "BR-000", "BR-0001", 4)
        KodeKayu.Focus()
    End Sub

    Private Sub Simpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simpan.Click
        If KodeKayu.Text <> "" And JenisKayu.Text <> "" And Ukuran.Text <> "" Then
            If Simpan.Text = "Simpan" Then
                SQL = "INSERT INTO Kayu VALUES ('" & KodeKayu.Text & _
                "','" & JenisKayu.Text & _
                "','" & Ukuran.Text & _
                 "','" & Harga.Text & _
                  "','" & Stok.Text & _
                "','" & Satuan.Text & "')"
                MsgBox("Kayu " & JenisKayu.Text & vbCrLf & " Telah Berhasil Disimpan ", MsgBoxStyle.Information, "Sukses")
                EksekusiData()
            ElseIf Simpan.Text = "Edit" Then
                SQL = "Update Kayu Set JenisKayu='" & JenisKayu.Text & "', " & _
                     " Ukuran='" & Ukuran.Text & "', Harga='" & Harga.Text & "', Stok='" & Stok.Text & "', Satuan='" & Satuan.Text & " ' " & _
                     "Where KodeKayu='" & KodeKayu.Text & "'"
                MsgBox("Kayu " & JenisKayu.Text & vbCrLf & " Telah Berhasil Diperbahurui ", MsgBoxStyle.Information, "Sukses")
                EksekusiData()
            End If
            TampilData()
            Bersih()
        Else
            MsgBox("Data Tidak Lengkap", MsgBoxStyle.Exclamation, "Perhatikan")
        End If
    End Sub

    Private Sub Hapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Hapus.Click
        Dim X As String
        X = MsgBox("Yakin Ingin Menghapus Kayu ", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Konfirmasi")
        If X = MsgBoxResult.Yes Then
            SQL = "DELETE FROM Kayu WHERE KodeKayu='" & KodeKayu.Text & "'"
            EksekusiData()
            MsgBox(JenisKayu.Text & vbCrLf & "Berhasil Dihapus", MsgBoxStyle.Information, "Sukses")
        End If
        Bersih()
        TampilData()
    End Sub

    Private Sub Batal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Batal.Click
        Bersih()
    End Sub

    Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        Me.Close()
    End Sub
    Private Sub KodeKayu_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles KodeKayu.KeyPress
        If e.KeyChar = Chr(13) Then
            If KodeKayu.Text = "" Then
                MsgBox("Kode Kayu Tidak Boleh  Kosong", MsgBoxStyle.Exclamation, "Perhatikan")
            Else
                CekKayu()
            End If
        End If
    End Sub
    Sub CekKayu()
        SQL = "SELECT * FROM Kayu WHERE KodeKayu='" & KodeKayu.Text & "'"
        BacaData()
        If RS.HasRows = True Then
            RS.Read()
            KodeKayu.Text = RS("KodeKayu")
            JenisKayu.Text = RS("JenisKayu")
            Ukuran.Text = RS("Ukuran")
            Harga.Text = RS("Harga")
            Stok.Text = RS("Stok")
            Satuan.Text = RS("Satuan")
            RubahTombol(2, Baru, Simpan, Hapus, Batal, Keluar)
            Simpan.ImageKey = "Edit.Ico"
        Else
            RubahTombol(1, Baru, Simpan, Hapus, Batal, Keluar)
            Simpan.ImageKey = "Simpan.Ico"
        End If
        RS.Close()
        BukaKunci(Me)
        KodeKayu.Enabled = False
        JenisKayu.Focus()
    End Sub
    Private Sub LV_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles LV.DoubleClick
        KodeKayu.Text = LV.SelectedItems(0).Text
        Call CekKayu()
    End Sub
    Private Sub Harga_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Harga.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True
    End Sub
    Private Sub Stok_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Stok.KeyPress
        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True
    End Sub
    Private Sub JenisKayu_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles JenisKayu.KeyPress
        Dim KeyAscii As Short = Asc(e.KeyChar)
        If (e.KeyChar Like "[A-Za-z]" _
                OrElse KeyAscii = Keys.Back _
                OrElse KeyAscii = Keys.Return _
                OrElse KeyAscii = Keys.Space _
                OrElse KeyAscii = Keys.Delete) Then
            KeyAscii = 0
        End If
        e.Handled = CBool(KeyAscii)
    End Sub

    Private Sub Satuan_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Satuan.KeyPress
        e.KeyChar = Chr(13)
    End Sub

    Private Sub Cari_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cari.TextChanged
        LV.Items.Clear()
        SQL = "SELECT * FROM KAYU  WHERE JENISKAYU LIKE '%" & Cari.Text & "%'"
        BacaData()
        While RS.Read
            Dim AZ As New ListViewItem
            With AZ
                .Text = RS("KodeKayu")
                .SubItems.Add(RS("JenisKayu"))
                .SubItems.Add(RS("Ukuran"))
                .SubItems.Add(RS("Harga"))
                .SubItems.Add(RS("Stok"))
                .SubItems.Add(RS("Satuan"))
                LV.Items.Add(AZ)
            End With
        End While
        RS.Close()
        CMD.Dispose()
    End Sub

    Private Sub LV_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LV.SelectedIndexChanged

    End Sub
End Class
Ok  selesai form data kayu nya, tunggu postingan selanjutnya untuk penyelesaian program ini.Happy Coding :D

Related Posts: