PENDAHULUAN
1. Latar Belakang
1
4. Fitur / Fasilitas Aplikasi
a. Page login
b. Page menu home
c. Page data
- Data Supplier
- Data pengguna
- Data stok.
5. Kelebihan Aplikasi
a. Terdapat pendataan transaksi barang masuk dan barang keluar
b. Terdapat laporan barang masuk dan barang keluar
6. Kekurangan Aplikasi
2
BAB II
LAPORAN KERJA PROJEK
3
2. Hardware dan Software
a. Hardware (Komputer atau Laptop dengan spesifikasi) :
1. Processor Intel Core i5
2. RAM 4gb
3. HDD 500gb
4. Sistem Operasi Win10 x64Bit
b. Software :
1. Microsoft Visual Studio 2012
2. XAMPP
3. PHP MY SQL (Database)
3. Langkah Kerja
a. Pembuatan Database
1. Klik 2x XAMPP CONTROL PANEL
4
2. Lalu akan muncul tampilan Xampp, dan lalu klik start pada module
Apache dan MySQL.
5
4. Lalu klik 2x Google Chrome
6
7. Setelah itu buat database dengan nama “stock_app”.
10. Lalu buatlah tabel dengan nama “ref_stock” dengan struktur tabel
seperti tabel berikut.
7
Struktur tabel ref_stock
Nama Tipe Data Extra
id Integer (11) Primary Key
id_ref_stock_categor Integer (11)
y
id_ref_supplier Integer (11)
name Varchar(100)
quantity float
id_ref_unit Integer (11)
12. Lalu buat tabel dengan nama “ref_supplier” dengan struktur tabel
seperti tabel berikut.
Tabel 3.5 Struktur tabel dari ref_supplier.
Struktur tabel ref_supplier
Nama Tipe Data Extra
Id Integer (11) Primary Key
name Varchar(255)
8
13. Lalu buat tabel dengan nama “ref_transaction_type” dengan struktur
tabel seperti tabel berikut.
Tabel 3.6 Struktur tabel dari ref_transaction_type.
Struktur tabel ref_transaction_type
Nama Tipe Data Extra
Id Integer (11) Primary Key
Name Varchar (30)
14. Lalu buat tabel dengan nama “ref_unit” dengan struktur seperti tabel
berikut.
Tabel 3.7 Struktur tabel dari ref_unit.
Struktur tabel ref_unit
Nama Tipe Data Extra
id Integer (10) Primary Key
Name Varchar (50)
15. Lalu buat tabel dengan nama “transaction” dengan struktur tabel
berikut.
9
date datetime
id_auth_user Integer (11)
16. Lalu buat tabel dengan nama “transaction_detail” dengan struktur tabel
berikut.
Tabel 3.9 Struktur tabel dari transaction_detail”.
Struktur tabel transaction_detail
Nama Tipe Data Extra
Id Integer (11) Primary Key
id_transaction Integer (11)
id_ref_stock Integer (11)
10
Gambar 2.10 Tampilan Awal Microsoft Visual Studio 2012.
11
Gambar 2.11 Tampilan membuat project baru.
12
Gambar 2.13 Tampilan membuat Form Login
13
Microsoft Sans Serif;
Font
Button2 14pt; style=Bold;
Size 32; 29
name Button2
Microsoft Sans Serif;
Font
Button3 14pt; style=Bold;
Size 33; 29
name Button3
Microsoft Sans Serif;
Font
Textbox1 12pt; style=Bold;
Size 233; 29
Name textboxUsername
Microsoft Sans Serif;
Font
Textbox2 12pt; style=Bold;
Size 232; 29
Name textboxPassword
14
24. Berikut merupakan Properties pada form main
Tabel 3.11 Tampilan Properties Form main
Name Control Properties Nilai
Name Stock Management
StockApp.My.Resources.Resources.i
Background
Form v
Size 800; 418
Text Stock Management
Name DataToolStripMenuItem
Backcolour ControlLight
Menustrip1
Size 43; 20
Text Data
Name SupplierToolStripMenuItem
Modifiers Friend
Menustrip2 Text Supplier
visible true
Size 152; 22
Name KategoriStokToolStripMenuItem
Size 152; 22
Menustrip3
Modifiers Friend
Text Kategori Stok
Name StokToolStripMenuItem
Text Stok
Menustrip4
Size 152; 22
Modifiers Friend
Name PenggunaToolStripMenuItem
Text Pengguna
Menustrip5
Modifiers Friend
Size 152; 22
Name TranToolStripMenuItem
Size 152; 22
Menustrip6
Text Transaksi Stok
Modifiers Friend
Name LaporanToolStripMenuItem
Size 152; 22
Menustrip7
Modifiers Friend
Text Laporan
Menustrip8 Name LogOutToolStripMenuItem
Size 152; 22
Text Log out
15
Modifiers Friend
16
Name Label 4
Backcolour White
Label 4
Text Nama Stock
Size 90; 21
Name Label 3
Backcolour White
Label 3
Size 57; 21
Text Jumlah
Name Label 1
Backcolour White
Label 1
Text Supplier
Size 64; 21
Name Label 2
Backcolour White
Label 2
Size 65; 21
Text Kategori
Name Label 6
Backcolour White
Label 6
Text Satuan
Size 57; 21
Name textboxName
Textbox 1 Size 188; 20
Font Segoe UI Light; 11.25pt
Name textboxQty
Textbox 2 Size 188; 20
Font Segoe UI Light; 11.25pt
Name selectSupplier
Textbox 3 Size 188; 20
Font Segoe UI Light; 11.25pt
Name selectCategory
Textbox 4 Size 188; 20
Font Segoe UI Light; 11.25pt
Name selectUnit
Textbox 5 Size 188; 20
Font Segoe UI Light; 11.25pt
Name buttonClear
Text Reset
Size 78; 31
Button 1 Font Segoe UI Light; 11.25pt
Name SaveBtn
Text Simpan
17
Size 78; 31
Font Segoe UI Light; 11.25pt
Button 2
Name UpdateBtn
Text Update
Size 78; 31
Button 3 Font Segoe UI Light; 11.25pt
Name DeleteBtn
Text Delete
Size 78; 31
Button 4 Font Segoe UI Light; 11.25pt
18
28. Berikut merupakan Properties pada form stock Category
Tabel 3.13 Tampilan Properties Form stock Category
Name Control Properties Nilai
Name StockCategory
White
BackColor
Form
Size 363; 432
Text Kategori Stok
Name Label 5
Backcolour White
Label 4
Size 109; 21
Text Nama Kategori
Name Label 5
Backcolour White
Label 5
Text Nama Stock
Size 90; 21
Name textboxName
Textbox 1 Size 188; 20
Font Segoe UI Light; 11.25pt
Tblindex 130
Name SaveBtn
Text Save
Size 78; 31
Button 1 Font Segoe UI Light; 11.25pt
Name UpdateBtn
Text Update
Size 78; 31
Button 2 Font Segoe UI Light; 11.25pt
Name DeleteBtn
Text Delete
Size 78; 31
Button 3 Font Segoe UI Light; 11.25pt
DataGridView1 Name DataGridView1
19
29. Berikut merupakan tampilan pada form Supplier
20
Size 108; 21
Text Nama Supplier
Name Label 5
Backcolour White
Label 5
Text Nama Supplier
Size 90; 21
Name textboxName
Textbox 1 Size 188; 20
Font Segoe UI Light; 11.25pt
Tblindex 130
Name SaveBtn
Text Save
Size 78; 31
Button 1 Font Segoe UI Light; 11.25pt
Name UpdateBtn
Text Update
Size 78; 31
Button 2 Font Segoe UI Light; 11.25pt
Name DeleteBtn
Text Delete
Size 78; 31
Button 3 Font Segoe UI Light; 11.25pt
DataGridView1 Name DataGridView1
21
Gambar 2.18 Tampilan membuat Form Transaction
22
Size 57; 21
Text Jumlah
Name Button1
Font Segoe UI Light; 12pt
Button1
Size 35; 20
Table index 186
Name Label 5
Backcolour White
Label 5
Size 96; 30
Text Transaksi
Name Label 1
Backcolour White
Label 1
Text Tanggal
Size 61; 21
Name Label 2
Backcolour White
Label 2
Size 100; 21
Text Tipe Transaksi
Name Label 6
Backcolour White
Label 6
Text Deskripsi
Size 68; 21
Name Label 6
Backcolour White
Label 7
Size 71; 21
Text List Stock
Name Label 6
Text Total Stock
Label 8
Backcolour White
Size 80; 21
Name dateTrans
DateTimePicker Size 302; 20
Enabled False
Name selectType
Table Index 172
Size 302; 28
ComboBox 1 Font Segoe UI Light; 11.25pt
Name textboxDesc
Textbox 1 Size 302; 96
Font Segoe UI Light; 11.25pt
Tblindex 173
23
Name ListView 1
Text Update
Size 302; 142
ListView 1 Microsoft Sans Serif;
Font
8.25pt
Name DeleteBtn
Text Reset List
Size 78; 31
Button 1 Font Segoe UI Light; 11.25pt
Name totalQty
Textbox 1 Size 302; 20
Font Segoe UI Light; 11.25pt
Tblindex 183
Name SaveBtn
Text Simpan Transaksi
Size 143; 31
Button 2 Font Segoe UI Light; 11.25pt
24
34. Berikut merupakan Properties pada form UserManagement
Tabel 3.16 Tampilan Properties pada form UserManagement
Name Control Properties Nilai
Name UserManagement
White
BackColor
Form
Size 773; 456
Text Manajemen Pengguna
Name Label 3
Backcolour White
Label 3
Size 84; 21
Text Level Akses
Name Label 1
Backcolour White
Label 1
Text Nama Lengkap
Size 111; 21
Name Label 4
Backcolour White
Label 4
Size 77; 21
Text Username
Name Label 1
Backcolour White
Label 1
Text Supplier
Size 64; 21
Name Label 2
Backcolour White
Label 2
Size 72; 21
Text Passsword
Name selectCategory
Table Index 157
Size 188; 28
ComboBox 1 Font Segoe UI Light; 11.25pt
Name textboxName
Textbox 1 Size 188; 20
Font Segoe UI Light; 11.25pt
Textbox 2 Name textboxUsername
Size 188; 20
25
Font Segoe UI Light; 11.25pt
Name textboxPassword
Textbox 3 Size 188; 20
Font Segoe UI Light; 11.25pt
Name buttonClear
Text Reset
Button 2
Size 78; 31
Name SaveBtn
Text Simpan
Button 3
Size 78; 31
Name UpdateBtn
Text Update
Size 78; 31
Button 3 Font Segoe UI Light; 11.25pt
Name DeleteBtn
Text Delete
Size 78; 31
Button 4 Font Segoe UI Light; 11.25pt
Name textboxSearch
TabIndex 158
Size 327; 20
TextBox1 Font Segoe UI Light; 11.25pt
Name buttonSearch
TabIndex 159
Size 35; 20
Button 5 Font Segoe UI Light; 11.25pt
26
Gambar 2.20 Tampilan membuat Form ChooseTrans
37. Berikut merupakan tampilan pada form Login saat sudah di Jalankan
27
Gambar 2.21 Tampilan Form Login.
Setelah itu masukkan source code dibawah ini dan simpan sesuai nama file
yang ada diatasnya :
28
textboxPassword.Text = ""
End Sub
Sub processLogin()
Call connect()
If textboxUsername.Text = "" Or textboxPassword.Text = "" Then
MsgBox("Data belum lengkap", vbInformation)
Else
cmd = New MySqlCommand("SELECT * FROM auth_user WHERE
username='" & textboxUsername.Text & "' AND password='" &
textboxPassword.Text & "'", conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
Dim group_user As String
Dim name As String
Dim id As String
name = rd.Item("fullname")
id = rd.Item("id")
group_user = rd.Item("id_auth_user_group")
Main.labelIdUser.Text = id
Main.labelUser.Text = name
If group_user = 1 Then
29
MsgBox("Berhasil login sebagai administrator", vbInformation)
Main.Show()
Me.Hide()
ElseIf group_user = 2 Then
MsgBox("Berhasil login sebagai operator", vbInformation)
Main.DataToolStripMenuItem.Visible = False
Main.Show()
Me.Hide()
End If
Else
MsgBox("Username atau password salah", vbInformation)
clear()
End If
End If
End Sub
30
Private Sub textboxPassword_KeyPress(ByVal sender As Object, ByVal e As
KeyPressEventArgs) Handles textboxPassword.KeyPress
If (e.KeyChar = Chr(13)) Then
processLogin()
End If
End Sub
End Class
38. Berikut merupakan tampilan pada form Login saat sudah di Jalankan.
31
Tabel 3.19 Source code form Main.
Public Class Main
Private Sub KategoriStokToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles KategoriStokToolStripMenuItem.Click
StockCategory.Show()
End Sub
Private Sub SupplierToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles SupplierToolStripMenuItem.Click
Supplier.Show()
End Sub
Private Sub StokToolStripMenuItem_Click(sender As Object, e As EventArgs)
Handles StokToolStripMenuItem.Click
Stock.Show()
End Sub
32
Private Sub LogOutToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles LogOutToolStripMenuItem.Click
Login.textboxPassword.Text = ""
Login.textboxUsername.Text = ""
Me.Hide()
Login.Show()
MsgBox("Log Out Berhasil", vbInformation)
Login.textboxUsername.Focus()
End Sub
Private Sub Main_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
End Sub
End Class
39. Berikut merupakan tampilan pada form Stock saat sudah di Jalankan.
33
Gambar 2.23 Tampilan Form Stock.
34
da = New MySqlDataAdapter("SELECT a.id, c.id as id_supplier, c.name as
supplier, b.id as id_category, b.name as stock_category, a.name, a.quantity,
a.id_ref_unit, d.name as unit " & _
"FROM ref_stock a " & _
"LEFT JOIN ref_stock_category b ON b.id =
a.id_ref_stock_category " & _
"LEFT JOIN ref_supplier c ON c.id = a.id_ref_supplier " & _
"LEFT JOIN ref_unit d ON d.id = a.id_ref_unit", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView1.DataSource = (ds.Tables("records"))
DataGridView1.Enabled = True
DataGridView1.Refresh()
'ID supplier
Me.DataGridView1.Columns(1).Visible = False
'ID Category Stock
Me.DataGridView1.Columns(3).Visible = False
'ID Unit
Me.DataGridView1.Columns(7).Visible = False
Me.DataGridView1.Columns(0).HeaderText = "ID Stok"
Me.DataGridView1.Columns(2).HeaderText = "Supplier"
Me.DataGridView1.Columns(4).HeaderText = "Kategori"
Me.DataGridView1.Columns(5).HeaderText = "Nama Stok"
Me.DataGridView1.Columns(6).HeaderText = "Qty"
Me.DataGridView1.Columns(8).HeaderText = "Satuan"
End Sub
Sub getData()
35
Dim i As Integer
i = DataGridView1.CurrentRow.Index
id.Text = DataGridView1.Item(0, i).Value
textboxName.Text = DataGridView1.Item(5, i).Value
textboxQty.Text = DataGridView1.Item(6, i).Value
selectSupplier.SelectedIndex =
selectSupplier.FindString(DataGridView1.Item(1, i).Value.ToString)
selectCategory.SelectedIndex =
selectCategory.FindString(DataGridView1.Item(3, i).Value.ToString)
For Each item As Object In Me.selectSupplier.Items
Dim selectValue As Object =
item.GetType.GetProperty(Me.selectSupplier.ValueMember).GetValue(item,
Nothing)
If DataGridView1.Item(1, i).Value.ToString = selectValue Then
Me.selectSupplier.SelectedItem = item
Exit For
End If Next
For Each item As Object In Me.selectCategory.Items
Dim selectValue As Object =
item.GetType.GetProperty(Me.selectCategory.ValueMember).GetValue(item,
Nothing)
If DataGridView1.Item(3, i).Value.ToString = selectValue Then
Me.selectCategory.SelectedItem = item
Exit For
End If
Next
For Each item As Object In Me.selectUnit.Items
36
Dim selectValue As Object =
item.GetType.GetProperty(Me.selectUnit.ValueMember).GetValue(item, Nothing)
If DataGridView1.Item(7, i).Value.ToString = selectValue Then
Me.selectUnit.SelectedItem = item
Exit For
End If
Next
End Sub
Private Sub selectSupplier_SelectionchangeCommitted(sender As Object, e As
EventArgs) Handles selectSupplier.SelectionChangeCommitted
If selectSupplier.SelectedIndex <> -1 Then
'MessageBox.Show(selectSupplier.SelectedValue.ToString())
End If
End Sub
Sub search()
Call connect()
da = New MySqlDataAdapter("SELECT a.id, c.id as id_supplier, c.name as
supplier, b.id as id_category, b.name as stock_category, a.name, a.quantity,
a.id_ref_unit, d.name as unit " & _
37
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView1.DataSource = (ds.Tables("records"))
DataGridView1.Enabled = True
DataGridView1.Refresh()
'ID supplier
Me.DataGridView1.Columns(1).Visible = False
'ID Category Stock
Me.DataGridView1.Columns(3).Visible = False
'ID Unit
Me.DataGridView1.Columns(7).Visible = False
Me.DataGridView1.Columns(0).HeaderText = "ID Stok"
Me.DataGridView1.Columns(2).HeaderText = "Supplier"
Me.DataGridView1.Columns(4).HeaderText = "Kategori"
Me.DataGridView1.Columns(5).HeaderText = "Nama Stok"
Me.DataGridView1.Columns(6).HeaderText = "Qty"
Me.DataGridView1.Columns(8).HeaderText = "Satuan"
End Sub
Class SelectList
Property ID As Integer
Property Name As String
End Class
Sub loadSelectSupplier()
rd.Close()
38
Try
cmd = New MySqlCommand("SELECT id, name FROM ref_supplier", conn)
rd = cmd.ExecuteReader
While rd.Read()
_listSupplier.Add(New SelectList With {.ID = rd("id").ToString, .Name =
rd("name")})
End While
selectSupplier.DataSource = _listSupplier
selectSupplier.DisplayMember = "Name"
selectSupplier.ValueMember = "ID"
Catch ex As Exception
MsgBox("Gagal memuat data supplier")
End Try
End Sub
Sub loadSelectCategory()
rd.Close()
Try
39
Catch ex As Exception
MsgBox("Gagal memuat data kategori stok" & ex.Message)
End Try
End Sub
Sub loadSelectUnit()
rd.Close()
Try
cmd = New MySqlCommand("SELECT id, name FROM ref_unit", conn)
rd = cmd.ExecuteReader
While rd.Read()
_listUnit.Add(New SelectList With {.ID = rd("id").ToString, .Name =
rd("name")})
End While
selectUnit.DataSource = _listUnit
selectUnit.DisplayMember = "Name"
selectUnit.ValueMember = "ID"
Catch ex As Exception
MsgBox("Gagal memuat data satuan" & ex.Message)
End Try
End Sub
Sub save()
rd.Close()
Dim alert As String
40
alert = MsgBox("Apa data yang diisikan sudah benar?", MsgBoxStyle.YesNo,
"Perhatian")
If alert = vbYes Then
If selectSupplier.SelectedIndex <> -1 And selectCategory.SelectedIndex <>
-1 Then
cmd = New MySqlCommand("INSERT INTO ref_stock(name, quantity,
id_ref_supplier, id_ref_stock_category, id_ref_unit) " & _
"VALUES('" & textboxName.Text & "', '" & textboxQty.Text
& "', '" & selectSupplier.SelectedValue.ToString() & "', '" &
selectCategory.SelectedValue.ToString() & "', '" &
selectUnit.SelectedValue.ToString() & "')", conn)
cmd.ExecuteNonQuery()
MsgBox("Data tersimpan")
clear()
records()
Else
41
Sub update()
rd.Close()
Dim alert As String
alert = MsgBox("Apa data yang diisikan sudah benar?", MsgBoxStyle.YesNo,
"Perhatian")
If alert = vbYes Then
cmd = New MySqlCommand("UPDATE ref_stock SET name='" &
textboxName.Text & "', quantity='" & textboxQty.Text & "', id_ref_supplier = '" &
selectSupplier.SelectedValue.ToString() & "', id_ref_stock_category = '" &
selectCategory.SelectedValue.ToString() & "', id_ref_unit = '" &
selectUnit.SelectedValue.ToString() & "' " & _
"WHERE id = '" & id.Text & "'", conn)
cmd.ExecuteNonQuery()
MsgBox("Data telah diupdate")
clear()
records()
Else
Exit Sub
clear()
End If
End Sub
Sub delete()
rd.Close()
Dim del As String
del = MsgBox("Yakin ingin menghapus data?", MsgBoxStyle.YesNo,
"Perhatian")
42
If del = vbYes Then
cmd = New MySqlCommand("DELETE FROM ref_stock WHERE id='" &
id.Text & "'", conn)
cmd.ExecuteNonQuery()
MsgBox("Data berhasil dihapus")
clear()
records()
Else
Exit Sub
clear()
End If
End Sub
Private Sub DataGridView1_CellClick(sender As Object, e As
DataGridViewCellEventArgs) Handles DataGridView1.CellClick
getData()
End Sub
Private Sub SaveBtn_Click(sender As Object, e As EventArgs) Handles
SaveBtn.Click
If textboxName.Text = "" Then
43
Private Sub UpdateBtn_Click(sender As Object, e As EventArgs) Handles
UpdateBtn.Click
If id.Text = "" Then
MsgBox("Silakan pilih data terlebih dahulu")
Else
update()
End If
End Sub
Private Sub DeleteBtn_Click(sender As Object, e As EventArgs) Handles
DeleteBtn.Click
If id.Text = "" Then
MsgBox("Silakan pilih data terlebih dahulu")
Else
delete()
End If
End Sub
Private Sub buttonClear_Click(sender As Object, e As EventArgs) Handles
buttonClear.Click
clear()
End Sub
44
If (e.KeyChar = Chr(13)) Then
search()
End If
End Sub
End Class
40. Berikut merupakan tampilan pada form Category Stock saat sudah di Jalankan.
45
Sub clear()
id.Text = ""
textboxName.Text = ""
End Sub
Sub records()
Call connect()
da = New MySqlDataAdapter("SELECT * FROM ref_stock_category", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView1.DataSource = (ds.Tables("records"))
DataGridView1.Enabled = True
DataGridView1.Refresh()
End Sub
Sub getData()
Dim i As Integer
i = DataGridView1.CurrentRow.Index
id.Text = DataGridView1.Item(0, i).Value
textboxName.Text = DataGridView1.Item(1, i).Value
End Sub
Sub save()
rd.Close()
Dim alert As String
alert = MsgBox("Apa data yang diisikan sudah benar?", MsgBoxStyle.YesNo,
"Perhatian")
If alert = vbYes Then
46
cmd = New MySqlCommand("INSERT INTO ref_stock_category(name) " &
_
"VALUES('" & textboxName.Text & "')", conn)
cmd.ExecuteNonQuery()
MsgBox("Data tersimpan")
clear()
records()
Else
Exit Sub
clear()
End If
End Sub
Sub update()
rd.Close()
Dim alert As String
alert = MsgBox("Apa data yang diisikan sudah benar?", MsgBoxStyle.YesNo,
"Perhatian")
47
Else
Exit Sub
clear()
End If
End Sub
Sub delete()
rd.Close()
Dim del As String
del = MsgBox("Yakin ingin menghapus data?", MsgBoxStyle.YesNo,
"Perhatian")
If del = vbYes Then
cmd = New MySqlCommand("DELETE FROM ref_stock_category WHERE
id='" & id.Text & "'", conn)
cmd.ExecuteNonQuery()
MsgBox("Data berhasil dihapus")
clear()
records()
Else
Exit Sub clear()
End If
End Sub
Private Sub DataGridView1_CellClick(sender As Object, e As
DataGridViewCellEventArgs) Handles DataGridView1.CellClick
getData()
End Sub
48
Private Sub SaveBtn_Click(sender As Object, e As EventArgs) Handles
SaveBtn.Click
If textboxName.Text = "" Then
MsgBox("Data belum lengkap")
Else
save()
End If
End Sub
Private Sub UpdateBtn_Click(sender As Object, e As EventArgs) Handles
UpdateBtn.Click
If id.Text = "" Then
MsgBox("Silakan pilih data terlebih dahulu")
Else
update()
End If
End Sub
49
End Sub
End Class
41. Berikut merupakan tampilan pada form Supplier saat sudah di Jalankan.
Imports MySql.Data.MySqlClient
50
records()
clear()
End Sub
Sub clear()
id.Text = ""
textboxName.Text = ""
End Sub
Sub records()
Call connect()
da = New MySqlDataAdapter("SELECT * FROM ref_supplier", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView1.DataSource = (ds.Tables("records"))
DataGridView1.Enabled = True
DataGridView1.Refresh()
End Sub
Sub getData()
Dim i As Integer
i = DataGridView1.CurrentRow.Index
id.Text = DataGridView1.Item(0, i).Value
textboxName.Text = DataGridView1.Item(1, i).Value
End Sub
Sub save()
rd.Close()
Dim alert As String
51
alert = MsgBox("Apa data yang diisikan sudah benar?",
MsgBoxStyle.YesNo, "Perhatian")
If alert = vbYes Then
cmd = New MySqlCommand("INSERT INTO ref_supplier(name) " &
_
"VALUES('" & textboxName.Text & "')", conn)
cmd.ExecuteNonQuery()
MsgBox("Data tersimpan")
clear()
records()
Else
Exit Sub
clear()
End If
End Sub
Sub update()
rd.Close()
Dim alert As String
alert = MsgBox("Apa data yang diisikan sudah benar?",
MsgBoxStyle.YesNo, "Perhatian")
If alert = vbYes Then
cmd = New MySqlCommand("UPDATE ref_supplier SET name='" &
textboxName.Text & "' " & _
"WHERE id = '" & id.Text & "'", conn)
cmd.ExecuteNonQuery()
52
MsgBox("Data telah diupdate")
clear()
records()
Else
Exit Sub
clear()
End If
End Sub
Sub delete()
rd.Close()
Dim del As String
del = MsgBox("Yakin ingin menghapus data?", MsgBoxStyle.YesNo,
"Perhatian")
If del = vbYes Then
cmd = New MySqlCommand("DELETE FROM ref_supplier WHERE
id='" & id.Text & "'", conn)
cmd.ExecuteNonQuery()
MsgBox("Data berhasil dihapus")
clear()
records()
Else
Exit Sub
clear()
End If
End Sub
53
Private Sub DataGridView1_CellClick(sender As Object, e As
DataGridViewCellEventArgs) Handles DataGridView1.CellClick
getData()
End Sub
Private Sub SaveBtn_Click(sender As Object, e As EventArgs) Handles
SaveBtn.Click
If textboxName.Text = "" Then
MsgBox("Data belum lengkap")
Else
save()
End If
End Sub
Private Sub UpdateBtn_Click(sender As Object, e As EventArgs) Handles
UpdateBtn.Click
If id.Text = "" Then
MsgBox("Silakan pilih data terlebih dahulu")
Else
update()
End If
End Sub
54
End If
End Sub
End Class
42. Berikut merupakan tampilan pada form Transaction saat sudah di Jalankan.
55
Class SelectList
Property ID As Integer
Property Name As String
End Class
Sub clear()
id.Text = ""
textboxName.Text = ""
TextBox1.Text = ""
textboxQty.Text = ""
loadUnitType()
currentStock.Text = ""
End Sub
Sub clearTrans()
ListView1.Items.Clear()
totalQty.Text = ""
textboxDesc.Text = ""
End Sub
56
clearTrans()
Dim arr(1, 1) As String
arr(0, 0) = "ID Stok"
arr(0, 1) = "Nama Stok"
arr(1, 0) = "Jumlah"
arr(1, 1) = "Satuan"
ListView1.GridLines = True
ListView1.View = View.Details
Sub loadSelectType()
rd.Close()
Try
cmd = New MySqlCommand("SELECT id, name FROM
ref_transaction_type", conn)
rd = cmd.ExecuteReader
While rd.Read()
_listType.Add(New SelectList With {.ID =
rd("id").ToString, .Name = rd("name")})
End While
57
selectType.DataSource = _listType
selectType.DisplayMember = "Name"
selectType.ValueMember = "ID"
Catch ex As Exception
MsgBox("Gagal memuat data tipe transaksi")
End Try
End Sub
Sub loadUnitType()
rd.Close()
Try
cmd = New MySqlCommand("SELECT id, name FROM
ref_unit", conn)
rd = cmd.ExecuteReader
While rd.Read()
_listUnit.Add(New SelectList With {.ID =
rd("id").ToString, .Name = rd("name")})
End While
unitType.DataSource = _listUnit
unitType.DisplayMember = "Name"
unitType.ValueMember = "ID"
Catch ex As Exception
MsgBox("Gagal memuat data tipe unit")
End Try
End Sub
Sub recordsStock()
58
Call connect()
Sub getData()
Dim i As Integer
i = DataGridView1.CurrentRow.Index
id.Text = DataGridView1.Item(0, i).Value
textboxName.Text = DataGridView1.Item(1, i).Value
currentStock.Text = DataGridView1.Item(2, i).Value
End Sub
Sub search()
Call connect()
da = New MySqlDataAdapter("SELECT a.id, a.name,
a.quantity " & _
59
"FROM ref_stock a " & _
"WHERE a.id LIKE '%" & id.Text & "%'",
conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView1.DataSource = (ds.Tables("records"))
DataGridView1.Enabled = True
DataGridView1.Refresh()
Sub save()
rd.Close()
60
Dim qtyStock As Integer
Dim qtyTrans As Integer
Dim qtyFixed As Integer
Dim idRefUnit As Integer
Dim satuan As String
For i = 0 To ListView1.Items.Count - 1
idStock = ListView1.Items(i).SubItems(0).Text
qtyTrans = ListView1.Items(i).SubItems(2).Text
satuan = ListView1.Items(i).SubItems(3).Text
61
qtyStock = rd.Item("quantity") - Val(qtyFixed)
End If
End If
rd.Close()
MsgBox("Data tersimpan")
clear()
clearTrans()
recordsStock()
End Sub
If Val(textboxQty.Text) = 0 Then
62
MsgBox("Jumlah tidak boleh 0", vbInformation)
Exit Sub
End If
listStock = ListView1.Items.Add(id.Text)
listStock.SubItems.Add(textboxName.Text)
listStock.SubItems.Add(textboxQty.Text)
listStock.SubItems.Add(unitType.Text)
Dim i As Integer
Dim satuan As String
Dim total As Integer
Dim qtySatuan As Integer
For i = 0 To ListView1.Items.Count - 1
satuan = ListView1.Items(i).SubItems(3).Text
63
rd.Close()
cmd = New MySqlCommand("SELECT quantity FROM
ref_unit WHERE name='" & satuan & "'", conn)
rd = cmd.ExecuteReader()
rd.Read()
If rd.HasRows Then
qtySatuan = rd.Item("quantity")
End If
rd.Close()
totalQty.Text = total
clear()
End Sub
64
End Sub
65
RichTextBox1.Text = "PT.Sucofindo"
RichTextBox1.Enabled = False
textboxDesc.Text = ""
ElseIf selectType.SelectedValue.ToString() = "2" Then
Label6.Text = "Tujuan Barang"
Label13.Text = "Asal Barang"
textboxDesc.Text = ""
RichTextBox1.Text = "PT. Sucofindo"
textboxDesc.Enabled = True
RichTextBox1.Enabled = False
End If
End Sub
If rd.HasRows Then
JmlSatuan.Text = rd.Item("quantity")
calculateTotal()
End If
rd.Close()
End Sub
66
Private Sub calculateTotal()
TextBox1.Text = Val(textboxQty.Text) * Val(JmlSatuan.Text)
End Sub
End Sub
End Sub
End Sub
End Class
43. Berikut merupakan tampilan pada form ChooseTrans saat sudah di Jalankan.
67
Gambar 2.27 Tampilan Form ChooseTrans.
Imports MySql.Data.MySqlClient
Public Class ChooseTrans
Sub records()
Call connect()
68
da = New MySqlDataAdapter("SELECT a.id, a.date, a.total_quantity " &
_
"FROM transaction a", conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView1.DataSource = (ds.Tables("records"))
DataGridView1.Enabled = True
DataGridView1.Refresh()
Me.DataGridView1.Columns(0).HeaderText = "ID Transaksi"
Me.DataGridView1.Columns(1).HeaderText = "Tanggal"
Me.DataGridView1.Columns(2).HeaderText = "Total Quantity"
End Sub
Sub getData()
Dim i As Integer
i = DataGridView1.CurrentRow.Index
id.Text = DataGridView1.Item(0, i).Value
recordsDetail()
End Sub
Sub recordsDetail()
Call connect()
69
ds = New DataSet
ds.Clear()
da.Fill(ds, "records")
DataGridView2.DataSource = (ds.Tables("records"))
DataGridView2.Enabled = True
DataGridView2.Refresh()
Me.DataGridView2.Columns(0).HeaderText = "ID"
Me.DataGridView2.Columns(1).HeaderText = "Nama Stock"
Me.DataGridView2.Columns(2).HeaderText = "Quantity Transaksi"
End Sub
70
Dim parameterID As Object
parameterID = id.Text
report.SetParameterValue("id", id.Text)
ViewReport.CrystalReportViewer1.ReportSource = report
ViewReport.CrystalReportViewer1.Refresh()
ViewReport.CrystalReportViewer1.RefreshReport()
ViewReport.Show()
End Sub
End Class
44. Berikut merupakan tampilan pada cetak laporan Stock in saat sudah di
Jalankan.
71
Gambar 2.28 Tampilan Cetak Laporan stock in.
72
45. Berikut merupakan tampilan pada cetak laporan Stock out saat sudah di
Jalankan.
73
46. Berikut merupakan tampilan pada cetak semua laporan Rekapitulasi transaksi
saat sudah di Jalankan.
74
4. Hasil Akhir
Setelah admin memasukkan data barang. Admin juga dapat melakukan transaksi
pencarian data dengan mudah serta admin bisa menambah, edit, delete data.
a. Form login
b. Form main
75
Gambar 2.32 Tampilan Main.
c. Form stock
76
d. Form category stock
77
e. Tampilan Supplier
78
Gambar 2.38 Tampilan ChoseTrans.
79
Gambar 2.39 Tampilan Laporan stock in.
80
Gambar 2.40 Tampilan Cetak Laporan stock out.
81
Gambar 2.41 Tampilan Cetak Laporan Rekapitulasi transaksi.
82