Listing Program Dopur
Listing Program Dopur
Listing Program Dopur
FORM LOGIN
Imports System.Data.OleDb
Public Class frmLogin
End Sub
End Class
Imports System.Data.OleDb
Public Class frmHandphone
Button2.Enabled = False
Button3.Enabled = False
End Sub
Button1.Enabled = False
Button2.Enabled = True
Button3.Enabled = True
End Sub
End Sub
End Class
Imports System.Data.OleDb
Public Class frmTransaksi
Dim no As Integer
Dim idTransaksi As String
Sub tampilDataItem()
Dim x As Integer = 0
Using con As New OleDbConnection(dburl)
Using cmd As New OleDbCommand("SELECT * FROM tblHandphone", con)
con.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
ListView1.Items.Clear()
While dr.Read
With ListView1
.Items.Add(x + 1)
.Items(x).SubItems.Add(IIf(IsDBNull(dr(0)) = True, "-",
(dr(0))))
.Items(x).SubItems.Add(IIf(IsDBNull(dr(1)) = True, "-",
(dr(1))))
x += 1
End With
End While
End Using
End Using
End Using
End Sub
Sub autoID()
Try
Using conn As New OleDbConnection(dburl)
Using cmd As New OleDbCommand("SELECT MAX(kdTransaksi) as [nilMAX] FROM
tblTransaksi", conn)
conn.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
If dr.Read Then
idTransaksi = dr("nilMAX")
no = Val(idTransaksi.Substring(3, 3))
no += 1
If no > 9 Then
TextBox1.Text = "TR-0" & no
ElseIf no > 99 Then
TextBox1.Text = "TR-" & no
Else
TextBox1.Text = "TR-00" & no
End If
End If
End Using
End Using
End Using
Catch ex As Exception
TextBox1.Text = "TR-001"
End Try
End Sub
Sub tampilDataTransaksi()
Try
Using con As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("Select DISTINCT kdTransaksi,tglTransaksi
from tblTransaksi", con)
con.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
ListView3.Items.Clear()
Dim x As Integer = 0
While dr.Read
ListView3.Items.Add(dr("kdTransaksi"))
ListView3.Items(x).SubItems.Add(dr(1))
Dim cmd1 As New OleDbCommand("SELECT * from QTransaksi WHERE
kdTransaksi='" & dr("kdTransaksi") & "'", con)
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader
Dim transaksi As String
transaksi = ""
While dr1.Read
transaksi = transaksi & dr1("nmBarang") & ", "
End While
ListView3.Items(x).SubItems.Add(transaksi)
x += 1
End While
End Using
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub hilangkan_checklist()
For i = 0 To ListView1.Items.Count - 1
ListView1.Items(i).Checked = False
Next
End Sub
Private Sub frmTransaksi_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
tampilDataItem()
tampilDataTransaksi()
autoID()
TextBox1.Enabled = True
End Sub
End If
End Sub
Try
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("SELECT * FROM tblTransaksi WHERE
kdTransaksi = '" & ListView3.SelectedItems(0).Text & "'", conn)
conn.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
ListView2.Items.Clear()
Dim x As Integer = 0
While dr.Read
TextBox1.Text = dr(0)
Me.DateTimePicker1.Text = dr(1)
ListView2.Items.Add(dr(2))
ListView2.Items(x).SubItems.Add(dr(3))
x += 1
End While
End Using
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
Button1.Enabled = False
Button2.Enabled = True
Button3.Enabled = True
End Sub
End Sub
End Class
FORM LAPORAN
Imports System.Data.OleDb
Public Class frmProses
Private Function getJlhTransaksi()
Dim jlhPenjualan As Integer = 0
Try
Using con As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("SELECT COUNT(*) as [jlh] FROM (SELECT
DISTINCT kdTransaksi FROM tblTransaksi) ", con)
con.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
If dr.Read Then
jlhPenjualan = dr("jlh")
End If
End Using
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return jlhPenjualan
End Function
Sub oneItemset()
Dim no As Integer = 0
Using con As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("Select * from tblHandphone", con)
con.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
ListView1.Items.Clear()
While dr.Read
no += 1
Dim lv = ListView1.Items.Add(no)
lv.SubItems.Add(dr(0))
lv.SubItems.Add(dr(1))
Dim cmd1 As New OleDbCommand("Select count(kdBarang) as jlh from
tblTransaksi where kdBarang='" & dr("kdBarang") & "'", con)
Dim dr1 As OleDbDataReader = cmd1.ExecuteReader()
dr1.Read()
lv.SubItems.Add(dr1("jlh"))
Dim nilSupport As Double
nilSupport = FormatNumber(dr1("jlh") / getJlhTransaksi() * 100,
0)
lv.SubItems.Add(nilSupport)
End While
End Using
End Using
End Using
End Sub
Private Sub frmProses_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
oneItemset()
End Sub
ListView2.Items.Clear()
ListView3.Items.Clear()
ListView4.Items.Clear()
Dim no As Integer = 1
ListView3.Sorting = SortOrder.Descending
For i = 0 To ListView1.Items.Count - 1
If Val(ListView1.Items(i).SubItems(4).Text) >= TextBox1.Text Then
Dim lv = ListView2.Items.Add(ListView1.Items(i).SubItems(4).Text)
With lv
.SubItems.Add(no)
.SubItems.Add(ListView1.Items(i).SubItems(1).Text)
.SubItems.Add(ListView1.Items(i).SubItems(2).Text)
.SubItems.Add(ListView1.Items(i).SubItems(3).Text)
.SubItems.Add(ListView1.Items(i).SubItems(4).Text)
End With
End If
Next
For i = 0 To ListView2.Items.Count - 1
ListView2.Items(i).SubItems(1).Text = no
no += 1
Next
.SubItems.Add(ListView2.Items(j).SubItems(3).Text
)
.SubItems.Add(ListView2.Items(i).SubItems(3).Text
)
.SubItems.Add(freq2Item)
.SubItems.Add(support2)
.SubItems.Add(conf)
End With
'Else
' MsgBox("Tidak Ada Itemset yang memenuhi Min.Support
dan Min. Confidence")
End If
End Using
Catch ex As Exception
MsgBox("error 2 " & ex.Message)
End Try
End If
Next
jlhDataMemenuhiSupport -= 1
Next
For i = 0 To ListView3.Items.Count - 1
Dim teks1, teks2 As String
teks1 = ListView3.Items(i).SubItems(1).Text
teks2 = ListView3.Items(i).SubItems(2).Text
ListView4.Items.Add("Jika Konsumen Membeli " & teks1 & " maka akan membeli "
& teks2 & " Dengan Nilai Keyakinan sebesar " & ListView2.Items(i).SubItems(5).Text)
Next
Me.Text = "PROSES FP-Growth | Selesai"
End Sub
Dim ID As Integer = 1
Sub simpanHasilProses()
Try
For i = 0 To ListView3.Items.Count - 1
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("INSERT INTO tblHasil VALUES('" &
ListView3.Items(i).Text & "','" & ListView3.Items(i).SubItems(1).Text & "', '" & _
ListView3.Items(i).SubItems(2).Text &
"', '" & _
ListView3.Items(i).SubItems(3).Text &
"', '" & _
ListView3.Items(i).SubItems(4).Text &
"', '" & _
ListView3.Items(i).SubItems(5).Text &
"', '" & _
ListView4.Items(i).Text & "')", conn)
conn.Open()
cmd.ExecuteReader()
End Using
End Using
ID += 1
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
If ListView3.Items.Count = 0 Then
MsgBox("Proses Simpan tidak dapat dilakukan, Hasil Proses Kosong")
Else
Try
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("DELETE FROM tblHasil", conn)
conn.Open()
cmd.ExecuteReader()
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
Finally
simpanHasilProses()
MsgBox("Data Telah Disimpan")
End Try
End If
End Sub
End Sub
End Class
FORM HASIL
rptEng.Load(rptPath)
End Sub
End Class
MODULE
Imports System.Data.OleDb
Module Module1
Public DBURL As String = "Provider=Microsoft.jet.oledb.4.0;Data Source=" &
Application.StartupPath & "\DB.mdb"
End Module