Program Penjualan Buku Sederhana dengan Visual Basic .net

Program Penjualan Buku Sederhana dengan Visual Basic .net, Dalam studi kasus kali ini kita akan belajar membuat sebuah program sederhana yang dapat diguanakan untuk melakukan rekap data penjualan buku sederhana, dengan adanya rekap data penjualan tentu akan lebih mudah dalam melakukan pembukuan.

Program penjualan buku ini hanyalah sebuah program sederhana tidak komplek, jika anda ingin membuat program tersebut anda dapat mengembangkannya lagi dengan program vb.net yang kita gunakan. Untuk membuat program penjualan buku sederhana ini anda dapat mengikuti langkah - langkah berikut.

Buatlah satub buah database dengan nama db_buku, dan tabel dengan nama tb_buku, kemudian buatlah project baru pada visual basic anda dengan nama PenjualanBuku. Berikut adalah tabel buku yang dapat anda buat untuk transaksi penjualan buku tersebut.

Tabel Buku

 Field  Type  Size  Key
 notransaksi  Text  11  *
 tanggaljual  Date/Time
 judul  Text  40
 pengarang  Text  30
 penerbit  Text  30
 hargasatuan  Number
 jumlahbuku  Number
 hargajual  Number
 ppn  Number
 totalharga  Number
 photo  OLE Object

Selanjutnya buatlah desain seperti gambar berikut ini pada form1.

https://qualov.blogspot.com/2019/07/program-penjualan-buku-sederhana-dengan-visual-basic-net.html

Tambahkan satu buah module jika anda sudah selesai membuat form1 tersebut kemudian isi dengan source code berikut.

Source code Module

Imports System.Data.OleDb
Module Module1
    Public conn As OleDbConnection
    Public da As OleDbDataAdapter
    Public ds As DataSet
    Public cmd As OleDbCommand
    Public rd As OleDbDataReader
    Public str As String
    Public Sub koneksi()
        str = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath &
            "\db_buku.accdb"
        conn = New OleDbConnection(str)
        If conn.State = ConnectionState.Closed Then
            conn.Open()
        End If
    End Sub
End Module

Source code berikut ini akan kita gunakan pada form1,

Source code form1

Imports System.Data.OleDb
Imports System.IO
Public Class Form1
    Sub kosong()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()
        TextBox7.Clear()
        TextBox8.Clear()
        TextBox9.Clear()
        DateTimePicker1.Value = Today
        PictureBox1.Image = Nothing
        TextBox2.Focus()
    End Sub
    Sub isi()
        TextBox1.Clear()
        TextBox2.Clear()
        TextBox3.Clear()
        TextBox4.Clear()
        TextBox5.Clear()
        TextBox6.Clear()
        TextBox7.Clear()
        TextBox8.Clear()
        TextBox9.Clear()
        TextBox2.Focus()
    End Sub
    Sub tampilpenjualan()
        da = New OleDbDataAdapter("Select * from tb_buku order by notransaksi", conn)
        ds = New DataSet
        ds.Clear()
        da.Fill(ds, "tb_buku")
        da.Dispose()
        DataGridView1.DataSource = ds.Tables("tb_buku")
        DataGridView1.Refresh()
        conn.Close()
    End Sub
    Sub autoGrid()
        DataGridView1.Columns(0).Width = 80
        DataGridView1.Columns(1).Width = 170
        DataGridView1.Columns(2).Width = 150
        DataGridView1.Columns(3).Width = 150
        DataGridView1.Columns(4).Width = 150
        DataGridView1.Columns(5).Width = 150
        DataGridView1.Columns(6).Width = 150
        DataGridView1.Columns(7).Width = 150
        DataGridView1.Columns(8).Width = 150
        DataGridView1.Columns(9).Width = 150
        DataGridView1.Columns(10).Width = 150

        DataGridView1.Columns(0).HeaderText = "No Transaksi"
        DataGridView1.Columns(1).HeaderText = "Tanggal"
        DataGridView1.Columns(2).HeaderText = "Judul"
        DataGridView1.Columns(3).HeaderText = "Pengarang"
        DataGridView1.Columns(4).HeaderText = "Penerbit"
        DataGridView1.Columns(5).HeaderText = "Harga Satuan"
        DataGridView1.Columns(6).HeaderText = "Jumlah Buku"
        DataGridView1.Columns(7).HeaderText = "Harga Jual"
        DataGridView1.Columns(8).HeaderText = "PPN"
        DataGridView1.Columns(9).HeaderText = "Total Harga"
        DataGridView1.Columns(10).HeaderText = "Photo"
    End Sub

Private Sub Otomatis()
        Call koneksi()
        cmd = New OleDbCommand("Select * from tb_buku order by notransaksi desc", conn)
        Dim urutan, b As String
        Dim tanggal As String
        tanggal = Format(DateTimePicker1.Value, "ddMMyyyy")
        urutan = Format(Now, "ddMMyyyy")
        b = Format(DateTimePicker1.Value, "ddMMyyyy")
        If b = urutan Then
            rd = cmd.ExecuteReader
            rd.Read()
            If Not rd.HasRows Then
                TextBox1.Text = tanggal + "001"

            Else
                TextBox1.Text = Val(Microsoft.VisualBasic.Mid(rd.Item("notransaksi").ToString, 9, 8)) + 1
                If Len(TextBox1.Text) = 1 Then
                    TextBox1.Text = tanggal + "00" & TextBox1.Text & ""
                ElseIf Len(TextBox1.Text) = 2 Then
                    TextBox1.Text = tanggal + "0" & TextBox1.Text & ""

                End If
            End If
        Else
            rd = cmd.ExecuteReader
            rd.Read()
            If Not rd.HasRows Then
                TextBox1.Text = Val(Microsoft.VisualBasic.Mid(rd.Item("notransaksi").ToString, 9, 8)) + 1
                If Len(TextBox1.Text) = 1 Then
                    TextBox1.Text = tanggal + "00" & TextBox1.Text & ""
                ElseIf Len(TextBox1.Text) = 2 Then
                    TextBox1.Text = tanggal + "0" & TextBox1.Text & ""

                End If

            Else
                TextBox1.Text = tanggal + "001"
            End If
        End If
    End Sub
 

Source Code Button Upload Gambar

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Dim OpenFileDialog1 As New OpenFileDialog
        With OpenFileDialog1
            .CheckFileExists = True
            .ShowReadOnly = False
            .Filter = "All Files|*.*|Bitmap Files (*)|*.bmp;*.gif;*.jpg;*.jpeg"
            .FilterIndex = 2
            If .ShowDialog = DialogResult.OK Then
                ' Load the specified file into a PictureBox control.
                PictureBox1.Image = Image.FromFile(.FileName)

            End If
        End With
    End Sub
    
Source code Form1_Load

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Call koneksi()
        Call tampilpenjualan()
        Call kosong()
        Call autoGrid()
        Call Otomatis()
    End Sub

Source code button exit

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Me.Close()

    End Sub

Source code button Simpan

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or PictureBox1.Image Is Nothing Then
            MsgBox("Data Belum Lengkap, mohon lengkapi data", MsgBoxStyle.Critical, "Perhatian")
            TextBox1.Focus()
            Exit Sub
        Else

            Dim ms As New MemoryStream
            PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
            Dim gambar() As Byte = ms.GetBuffer
            ms.Close()
            Dim simpan As String = "insert into tb_buku(notransaksi,tanggaljual,judul,pengarang,penerbit,hargasatuan,jumlahbuku,hargajual,ppn,totalharga,photo) values " & _
                    "('" & TextBox1.Text & "','" & DateTimePicker1.Value & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox7.Text & "','" & TextBox8.Text & "','" & TextBox9.Text & "',@photo)"
            cmd = New OleDbCommand(simpan, conn)
            cmd.Parameters.Add("@photo", OleDbType.Binary).Value = gambar
            rd = cmd.ExecuteReader


            MsgBox("Simpan data sukses", MsgBoxStyle.Information, "Perhatian")
            Call tampilpenjualan()
            Call kosong()

        End If
    End Sub
    
Source code button proses

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox7.Text = Val(TextBox6.Text) * Val(TextBox5.Text)
        If TextBox7.Text > 500000 Then
            TextBox8.Text = (5 / 100) * (TextBox7.Text)
        Else
            TextBox8.Text = 0
        End If
        TextBox9.Text = Val(TextBox7.Text) + Val(TextBox8.Text)
    End Sub

Source code button Batal

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Call kosong()
    End Sub

Source code button Ubah

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox7.Text = "" Or TextBox8.Text = "" Or TextBox9.Text = "" Or PictureBox1.Image Is Nothing Then
            MsgBox("Data Belum Lengkap, mohon lengkapi data", MsgBoxStyle.Critical, "Perhatian")
            TextBox1.Focus()
            Exit Sub
        Else
            conn.Open()
            Dim ms As New MemoryStream
            PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
            Dim gambar() As Byte = ms.GetBuffer
            ms.Close()
            Dim ubah As String = "Update tb_buku set " & _
               "judul='" & TextBox2.Text & "', " & _
               "pengarang='" & TextBox3.Text & "', " & _
               "penerbit='" & TextBox4.Text & "', " & _
               "hargasatuan='" & TextBox5.Text & "', " & _
               "jumlahbuku='" & TextBox6.Text & "', " & _
               "hargajual='" & TextBox7.Text & "', " & _
               "ppn='" & TextBox8.Text & "', " & _
               "totalharga='" & TextBox9.Text & "', " & _
               "photo=@photo " & _
               "where notransaksi='" & TextBox1.Text & "'"
            cmd = New OleDbCommand(ubah, conn)
            cmd.Parameters.Add("@photo", OleDbType.Binary).Value = gambar
            rd = cmd.ExecuteReader
            conn.Close()
            MsgBox("Ubah data sukses", MsgBoxStyle.Information, "Perhatian")
            Call tampilpenjualan()
            Call kosong()
            TextBox1.Focus()
        End If
    End Sub

Source code Datagrid1

Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
        Call koneksi()
        Dim simpan As String = "Select * from tb_buku where notransaksi='" & DataGridView1.SelectedCells(0).Value & "'"
        cmd = New OleDbCommand(simpan, conn)
        rd = cmd.ExecuteReader
        If rd.Read Then
            TextBox1.Text = rd("notransaksi")
            TextBox2.Text = rd("judul")
            TextBox3.Text = rd("pengarang")
            TextBox4.Text = rd("penerbit")
            TextBox5.Text = rd("hargasatuan")
            TextBox6.Text = rd("jumlahbuku")
            TextBox7.Text = rd("hargajual")
            TextBox8.Text = rd("ppn")
            TextBox9.Text = rd("totalharga")
            Dim gambar() As Byte
            gambar = rd.Item("photo")
            PictureBox1.Image = Image.FromStream(New IO.MemoryStream(gambar))
            Button2.Enabled = True
            Button3.Enabled = True
            Button4.Enabled = True
        End If
        conn.Close()
    End Sub

Source code button Hapus

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If TextBox1.Text = "" Then
            MsgBox("No Transaksi belum diisi")
            TextBox1.Focus()
            Exit Sub
        Else
            conn.Open()
            If MessageBox.Show("Yakin akan menghapus Data ini " & TextBox1.Text & " ?", "",
                               MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
                cmd = New OleDbCommand("Delete * From tb_buku where notransaksi='" & TextBox1.Text &
                                       "'", conn)
                cmd.ExecuteNonQuery()
                MsgBox("Hapus data sukses", MsgBoxStyle.Information, "Perhatian")

                Call tampilpenjualan()
                Call kosong()
            End If
        End If
    End Sub

Source code Datetimepicker1
 
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
        Otomatis()
    End Sub
End Class

Untuk button report silahkan anda kreasikan sendiri dengan mengikuti tutorial berikut Cara membuat laporan dengan crystal report di visual basic .net, terima kasih semoga bermnafaat.

1 Response to "Program Penjualan Buku Sederhana dengan Visual Basic .net"

  1. Program Penjualan Buku Sederhana Dengan Visual Basic .Net - Qualov >>>>> Download Now

    >>>>> Download Full

    Program Penjualan Buku Sederhana Dengan Visual Basic .Net - Qualov >>>>> Download LINK

    >>>>> Download Now

    Program Penjualan Buku Sederhana Dengan Visual Basic .Net - Qualov >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel