Implementasi Algoritma Apriori Dan Fp-Growth Dalam Market Basket Analysis Pembelian Obat Pada Suatu Apotek

57

LISTING PROGRAM

Koneksi
Module Koneksi
Public conn As OleDb.OleDbConnection
Public cmd As OleDb.OleDbCommand
Public dtreader As OleDb.OleDbDataReader
Public dtreader2 As OleDb.OleDbDataReader
Public lokasi As String
Public kon As String, rkode As String
Public qry As String
Public kolom As Integer, baris As Integer
Public data(1000) As String, transaksibrg(1000) As String,
databrg(1000) As String
Public tabelku(1000, 1000) As Integer, XHasil(100) As Integer
Public Sub KoneksiDB()
On Error GoTo adaerror
lokasi = System.Environment.CurrentDirectory
kon = "provider=microsoft.jet.oledb.4.0;data source=" & lokasi &

"\db.mdb"
conn = New OleDb.OleDbConnection(kon)
conn.Open()
Exit Sub
adaerror:
MsgBox("Terjadi Kesalahan Dalam Koneksi, Periksa kembali Koneksi
Anda!", MsgBoxStyle.Critical, "Error Koneksi")
End Sub
Sub susun()
Dim variabel As String
Dim no As Integer
variabel = ""
qry = "select * from tblanalisa1 where noanalisa='" & rkode & "'
order by nofaktur asc"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
no = no + 1


Universitas Sumatera Utara

58

data(no) = dtreader("nofaktur")
End While
End If
kolom = no
End Sub
Sub resusun()
Dim a As Integer, b As Integer
a = 0 : b = 0
For a = 1 To kolom
qry = "select * from tblpenjualan where nofaktur='" & data(a) &
"'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
b = cekrecordtransaksi(dtreader("kodebrg"), data(a))

If b = 1 Then
SimpanRecordTransaksi(dtreader("kodebrg"), data(a))
End If
End While
'If dtreader.Read Then
'b = cekrecordtransaksi(dtreader("kodebrg"), data(a))
'If b = 1 Then
' SimpanRecordTransaksi(dtreader("kodebrg"), data(a))
'End If
'End If
End If
Next
End Sub
Function cekrecordtransaksi(ByVal kode As String, notransaksi As
String) As Integer
cekrecordtransaksi = 0
qry = "select * from tbltransaksi where nofaktur='" & notransaksi &
"' and kodebrg='" & kode & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
If dtreader.HasRows Then

cekrecordtransaksi = 1
End If
End Function
Sub SimpanRecordTransaksi(ByVal kode As String, notransaksi As String)
Dim a As Integer

Universitas Sumatera Utara

59

a = cekDataAnalisa(kode, rkode)
If a = 0 Then
qry = "insert into tblanalisa(noanalisa, kodebrg) values ('" &
rkode & "', '" & kode & "')"
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()
End If
End Sub
Function cekDataAnalisa(ByVal kode As String, nokas As String) As
Integer

cekDataAnalisa = 0
qry = "Select * from tblanalisa where noanalisa='" & nokas & "' and
kodebrg='" & kode & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader2 = cmd.ExecuteReader
If dtreader2.HasRows Then
cekDataAnalisa = 1
End If
End Function
Sub LoadAtribut(ByVal kodekasus As String)
Dim no As Integer
no = 0
qry = "select * from tblanalisa where noanalisa='" & kodekasus & "'
order by kodebrg asc"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
no = no + 1
databrg(no) = dtreader("kodebrg")

End While
End If
baris = no
End Sub
Sub SusunTabel(ByVal kodekasus As String)
LoadAtribut(kodekasus)
Dim a As Integer, b As Integer, c As Integer
c = 0
For a = 1 To kolom
For b = 1 To baris
qry = "select * from tblpenjualan where nofaktur='" &
data(a) & "' and kodebrg='" & databrg(b) & "'"

Universitas Sumatera Utara

60

cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then

tabelku(a, b) = 1
Else
tabelku(a, b) = 0
End If
Next
Next
End Sub
Sub Akhir()
qry = "select distinct(confedence) from tblsupportconfedence where
nokasus='" & rkode & "' order by confedence desc"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
If dtreader.Read Then
XHasil(1) = dtreader("confedence")
End If
End If
End Sub
End Module


Menu Utama
Public Class FrmUtama
Private Sub BarangToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles BarangToolStripMenuItem.Click
FrmBarang.Show()
End Sub
Private Sub HargaToolStripMenuItem_Click(sender
EventArgs) Handles HargaToolStripMenuItem.Click
FrmHarga.Show()
End Sub

As

Object,

e

As

Private Sub PenjualanToolStripMenuItem_Click(sender As Object, e As

EventArgs) Handles PenjualanToolStripMenuItem.Click

Universitas Sumatera Utara

61

FrmPenjualan.Show()
End Sub
Private Sub TransaksiToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles TransaksiToolStripMenuItem.Click
End Sub
Private Sub AnalisaToolStripMenuItem_Click(sender As Object, e As
EventArgs) Handles AnalisaToolStripMenuItem.Click
FrmAPilih.ShowDialog()
End Sub
Private Sub FrmUtama_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
End Sub

Menu Harga

Public Class FrmHarga
Dim pilih As Integer
Private Sub FrmHarga_FormClosing(sender As Object, e As
FormClosingEventArgs) Handles Me.FormClosing
conn.Close()
End Sub
Private Sub FrmHarga_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
KoneksiDB()
tampil()
DateTimePicker1.Value = Now
End Sub
Sub tampil()
Dim lst As ListViewItem
Lv.Items.Clear()
qry = "select * from tblbarang order by kodebrg asc"
cmd = New OleDb.OleDbCommand(qry, conn)

Universitas Sumatera Utara


62

dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
lst = Lv.Items.Add(dtreader("kodebrg"))
lst.SubItems.Add(dtreader("barang"))
End While
End If
End Sub
Sub cari()
Dim lst As ListViewItem
Lv.Items.Clear()
qry = "select * from tblbarang where barang like'%" & txtnama.Text
& "%'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
lst = Lv.Items.Add(dtreader("kodebrg"))
lst.SubItems.Add(dtreader("barang"))
End While
End If
End Sub
Private Sub txtnama_RegionChanged(sender As Object, e As EventArgs)
Handles txtnama.RegionChanged
End Sub
Private Sub txtnama_TextChanged(sender As Object, e As EventArgs)
Handles txtnama.TextChanged
cari()
End Sub
Private Sub Lv_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles Lv.SelectedIndexChanged
If Lv.Items.Count 0 Then
txtkode.Text = Lv.FocusedItem.Text
txtnama.Text = Lv.FocusedItem.SubItems(1).Text
tampilHarga()
End If
End Sub

Universitas Sumatera Utara

63

Sub tampilHarga()
Dim lst As ListViewItem
Lv1.Items.Clear()
qry = "select * from tblharga where kodebrg='" & txtkode.Text & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader()
If dtreader.HasRows Then
While dtreader.Read
lst = Lv1.Items.Add(dtreader("tgl"))
lst.SubItems.Add(dtreader("harga"))
lst.SubItems.Add(dtreader(0))
End While
End If
End Sub
Private Sub txtkode_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtkode.KeyPress
If e.KeyChar = Chr(13) Then
txtnama.Focus()
End If
End Sub
Private Sub txtkode_TextChanged(sender As Object, e As EventArgs)
Handles txtkode.TextChanged
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles
Button5.Click
conn.Close()
Me.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If Len(Trim(txtkode.Text)) = 0 Or Len(Trim(txtharga.Text)) = 0 Or
Len(Trim(txtnama.Text)) = 0 Then
MsgBox("Data tidak lengkap, periksa kembali data anda.")
Exit Sub
End If

Universitas Sumatera Utara

64

qry = "insert into tblharga(tgl, kodebrg, harga) values('" &
DateTimePicker1.Value & "','" & txtkode.Text & "','" & txtharga.Text & "')"
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()
tampil()
Bersih()
End Sub
Sub Bersih()
txtnama.Text = ""
txtkode.Text = ""
txtharga.Text = ""
End Sub
Private Sub Lv1_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles Lv1.SelectedIndexChanged
If Lv1.Items.Count 0 Then
txtharga.Text = Lv1.FocusedItem.SubItems(1).Text
pilih = Lv1.FocusedItem.SubItems(2).Text
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
Dim pesan As String
If pilih = 0 Then
MsgBox("Pilih dahulu data pada list!", MsgBoxStyle.Information,
"Pilih data")
Exit Sub
End If
pesan = MsgBox("Yakin ingin menghapus data ini?",
MsgBoxStyle.Question + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
qry = "delete from tblharga where idharga=" & pilih
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()
pilih = 0
End If
tampil()
tampilHarga()
End Sub

Universitas Sumatera Utara

65

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
Bersih()
tampil()
tampilHarga()
End Sub
Private Sub cmdedit_Click(sender As Object, e As EventArgs) Handles
cmdedit.Click
If pilih = 0 Then
MsgBox("Pilih dahulu item pada list!")
Exit Sub
End If
If cmdedit.Text = "&Edit" Then
cmdedit.Text = "&Update"
Else
cmdedit.Text = "&Edit"
qry = "update tblharga set harga='" & txtharga.Text & "' where
idharga=" & pilih
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()
Bersih()
tampil()
tampilHarga()
End If
End Sub
End Class

Menu Penjualan
Public Class FrmPenjualan
Dim pilih As String, noNoTA As String, NamaBarang As String
Private Sub Label1_Click(sender As Object, e As EventArgs) Handles
Label1.Click
End Sub

Universitas Sumatera Utara

66

Private Sub FrmPenjualan_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
KoneksiDB()
lblno.Text = ""
End Sub
Private Sub txtkode_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtkode.KeyPress
If e.KeyChar = Chr(27) Then
If GroupBox1.Visible = False Then
GroupBox1.Visible = True
GroupBox1.Left = 10
GroupBox1.Top = 10
txtkey.Focus()
Else
GroupBox1.Visible = False
End If
End If
End Sub
Sub Nota()
noNota = Now.Year & Now.Day & Now.Day & Now.Hour & Now.Minute &
Now.Second
End Sub
Private Sub txtkey_KeyPress(sender As Object, e As KeyPressEventArgs)
Handles txtkey.KeyPress
If e.KeyChar = Chr(27) Then
GroupBox1.Visible = False
txtkode.Focus()
End If
If e.KeyChar = Chr(13) Then
ListView2.Focus()
End If
End Sub
Private Sub txtkey_KeyUp(sender As Object, e As KeyEventArgs) Handles
txtkey.KeyUp
ListBarang()
End Sub

Universitas Sumatera Utara

67

Private Sub txtkey_TextChanged(sender As Object, e As EventArgs)
Handles txtkey.TextChanged
End Sub
Private
Sub
ListView2_KeyPress(sender
KeyPressEventArgs) Handles ListView2.KeyPress
If e.KeyChar = Chr(27) Then
txtkey.Focus()
End If
If e.KeyChar = Chr(13) Then
GroupBox1.Visible = False
txtqty.Focus()
End If
End Sub

As

Object,

e

As

Private Sub ListView2_SelectedIndexChanged(sender As Object, e As
EventArgs) Handles ListView2.SelectedIndexChanged
If ListView2.Items.Count 0 Then
pilih = ListView2.FocusedItem.Text
txtkode.Text = pilih
txtnama.Text = ListView2.FocusedItem.SubItems(1).Text
cekharga()
End If
End Sub
Sub LoadNOTA()
lblno.Text = Now.Year & Now.Month & Now.Day & Now.Hour & Now.Minute
& Now.Second
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
LoadNOTA()
ListView1.Items.Clear()
ListView2.Items.Clear()
txtkode.Text = ""
txtharga.Text = ""
txtqty.Text = ""
txtnama.Text = ""
txtkode.Focus()

Universitas Sumatera Utara

68

End Sub
Private Sub cmdsimpan_Click(sender As Object, e As EventArgs) Handles
cmdsimpan.Click
Dim jlh As Integer, jlhbrg As Integer, jlhbrg1 As Integer
jlh = 0 : jlhbrg1 = 0
If lblno.Text = "" Then
MsgBox("Klik terlebih dahulu tombol Transaksi Baru",
MsgBoxStyle.Information, "Informasi")
Exit Sub
End If
If Len(Trim(txtharga.Text)) = 0 Then
MsgBox("Harga belum disetting", MsgBoxStyle.Information,
"informasi")
Exit Sub
End If
qry = "Select * from tblpenjualan where nofaktur='" & lblno.Text &
"' and kodebrg='" & txtkode.Text & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
MsgBox("Data sudah ada, periksa kembali data anda! Data akan
ditambahkan ke record sebelumnya")
If dtreader.Read Then
jlh = dtreader("qty")
End If
End If
jlhbrg = txtqty.Text
If jlh = 1 Then
qry = "update tblpenjualan set qty='" & jlhbrg1 & "' where
nofaktur='" & lblno.Text & "' and kodebrg='" & txtkode.Text & "'"
cmd = New OleDb.OleDbCommand(qry, conn)

Universitas Sumatera Utara

69

cmd.ExecuteNonQuery()
End If
Tampil()
txtkode.Focus()
End Sub
Sub Tampil()
Dim no As Integer
Dim lst As ListViewItem
no = 0
ListView1.Items.Clear()
qry = "select * from tblpenjualan where nofaktur='" & lblno.Text &
"'"

End
Sub

End
Sub

cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
no = no + 1
lst = ListView1.Items.Add(no)
lst.SubItems.Add(dtreader("kodebrg"))
CekItem(dtreader("kodebrg"))
lst.SubItems.Add(NamaBarang)
lst.SubItems.Add(dtreader("qty"))
lst.SubItems.Add(dtreader("harga"))
End While
End If
Sub
CekItem(kode As String)
qry = "select * from tblbarang where kodebrg='" & kode & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader2 = cmd.ExecuteReader
If dtreader2.HasRows Then
If dtreader2.Read Then
NamaBarang = dtreader2("barang")
End If
End If
Sub
ListBarang()
Dim no As Integer
Dim lst As ListViewItem
no = 0
ListView2.Items.Clear()

Universitas Sumatera Utara

70

qry = "select * from tblbarang where kodebrg like '%" & txtkey.Text
& "%' or barang like '%" & txtkey.Text & "%'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader()
If dtreader.HasRows Then
While dtreader.Read
no = no + 1
lst = ListView2.Items.Add(dtreader(0))
lst.SubItems.Add(dtreader(1))
lst.SubItems.Add(dtreader(2))
'lst.SubItems(1).Text = dtreader(1)
'lst.SubItems(2).Text = dtreader(2)
End While
End If
End Sub
Sub cekharga()
qry = "select * from tblharga where kodebrg='" & txtkode.Text & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
If dtreader.Read Then
txtharga.Text = dtreader("harga")
End If
End If
End Sub
Private Sub cmdkeluar_Click(sender As Object, e As EventArgs) Handles
cmdkeluar.Click
Me.Close()
End Sub
Private Sub cmdedit_Click(sender As Object, e As EventArgs)
FrmEditPenjualan.ShowDialog()
End Sub
End Class

Form Menu Barang

Universitas Sumatera Utara

71

Public Class FrmBarang
Dim pilih As String
Private Sub FrmBarang_FormClosed(sender As Object, e As
FormClosedEventArgs) Handles Me.FormClosed
conn.Close()
End Sub
Private Sub FrmBarang_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
KoneksiDB()
LoadKategori()
Tampil()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles
Button4.Click
conn.Close()
Me.Close()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
KoneksiDB()
If Len(Trim(txtkode.Text)) = 0 Then
MsgBox("Data tidak lengkap!", MsgBoxStyle.Critical, "Duplikat")
Exit Sub
End If
qry = "select * from tblbarang where kodebrg='" & txtkode.Text & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader()
If dtreader.HasRows Then
MsgBox("Data sudah ada, periksa kembali data anda!",
MsgBoxStyle.Critical, "Duplikat")
Exit Sub
End If
qry = "insert into tblbarang (kodebrg, barang, kategori) values ('" &
txtkode.Text & "', '" & txtnama.Text & "', '" & txtkategori.Text & "')"
cmd = New OleDb.OleDbCommand(qry, conn)

Universitas Sumatera Utara

72

cmd.ExecuteNonQuery()
LoadKategori()
Bersih()
txtnama.Focus()
Tampil()
End Sub
Sub Bersih()
txtkode.Text = ""
txtnama.Text = ""
txtkategori.Text = ""
End Sub
Sub LoadKategori()
txtkategori.Items.Clear()
qry = "select distinct(kategori) from tblbarang"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
txtkategori.Items.Add(dtreader(0))
End While
End If
End Sub
Sub Tampil()
Dim lst As ListViewItem
Lv.Items.Clear()
qry = "select * from tblbarang order by kodebrg asc"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
While dtreader.Read
lst = Lv.Items.Add(dtreader(0))
lst.SubItems.Add(dtreader(1))
lst.SubItems.Add(dtreader(2))
End While
End If
End Sub
Private Sub Lv_Click(sender As Object, e As EventArgs) Handles Lv.Click
If Lv.Items.Count 0 Then
pilih = Lv.FocusedItem.Text
End If
End Sub
Private Sub Lv_SelectedIndexChanged(sender As Object, e As EventArgs)
Handles Lv.SelectedIndexChanged

Universitas Sumatera Utara

73

End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
If Len(Trim(pilih)) = 0 Then
MsgBox("Pilih dahulu data pada list!", MsgBoxStyle.Information, "No
Selected")
Exit Sub
End If
Dim pesan As String
pesan = MsgBox("Yakin ingin menghapus data ini?", MsgBoxStyle.Question
+ vbYesNo, "Konfirmasi")
If pesan = vbYes Then
qry = "delete from tblbarang where kodebrg='" & pilih & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()
Tampil()
pilih = ""
End If
End Sub
End Class

Form Apriori
Public Class FrmApriori
Dim itemset(1000) As String, sec As Integer
Dim pn As Integer, batas As Integer, h1(500) As String, rn As Integer,
nas(500) As String
Dim jlhnas As Integer, himpF2(500, 500) As String, rule(100) As String,
fpg(1000, 1000) As String
Dim ToTn(500) As Integer, confi As Double
Private Sub FrmApriori_Load(sender As Object, e As EventArgs) Handles
MyBase.Load
Dim a As Integer, b As Integer, c As Integer, hasil As String
Dim ntotal(1000) As Integer
ListBox1.Items.Clear()
ListBox2.Items.Clear()
ListBox3.Items.Clear()
ListBox4.Items.Clear()
sec = 0

Universitas Sumatera Utara

74

batas = 3
pn = 0
hasil = ""
susun()
resusun()
SusunTabel(rkode)
For a = 1 To baris
c = 0
For b = 1 To kolom
hasil = databrg(a) & "->" & a & ", " & b & tabelku(b, a)
ListBox1.Items.Add(hasil)
c = c + tabelku(b, a)
Next
ntotal(a) = c
If validasiITEMSET(c, batas) >= 1 Then
pn = pn + 1
itemset(pn) = databrg(a)
End If
ListBox1.Items.Add(c)
Next
CalonItemSet()
TabelConfedence()
PROSESFP()
'ReadHasil(1)
Akhir()
ReadHasil(XHasil(1))
End Sub
Function validasiITEMSET(ByVal kode As Integer, nilai As Integer) As
Integer
validasiITEMSET = 0
If kode >= nilai Then
validasiITEMSET = 1
Else
validasiITEMSET = 0
End If
End Function
Sub SimpanITEMSET(ByVal nilai As String)
itemset(pn) = nilai
End Sub
Sub CalonItemSet()
Dim NCI(100, 100) As String
Dim a As Integer, b As Integer, c As Integer, n1 As Integer, n2 As
Integer, hasiln As Integer
Dim nk As Integer

Universitas Sumatera Utara

75

nk = 0
hasiln = 0
n1 = 0 : n2 = 0
For a = 1 To pn
For b = a + 1 To pn
NCI(a, b) = a & b
ListBox1.Items.Add(itemset(a) & ", is " & itemset(b))
Next
Next
For a = 1 To pn
For b = a + 1 To pn
n1 = 0 : n2 = 0
hasiln = 0
For c = 1 To kolom
n1 = CEKitemSETKiri(itemset(a), data(c))
n2 = CEKitemSETKanan(itemset(b), data(c))
If n1 = 1 And n2 = 1 Then
hasiln = hasiln + 1
End If
ListBox1.Items.Add("Transaksi " & c & "->" & a & ", " & b &
", -=" & n1 & n2)
Next
ListBox1.Items.Add("----------->" & hasiln)
If hasiln >= 3 Then
nk = nk + 1
h1(nk) = itemset(a)
nk = nk + 1
h1(nk) = itemset(b)
ListBox1.Items.Add("NK=" & itemset(a) & " " & itemset(b))
End If
Next
Next
rn = nk
susunarray()
Dim ket As String
ket = ""
For a = 1 To jlhnas
ListBox1.Items.Add("Nas->" & nas(a))
ket = ket & " " & nas(a)
Next
ListBox1.Items.Add("Pada F2 didapat himpunan" & ket)
c = 0
For a = 1 To jlhnas

Universitas Sumatera Utara

76

'ListBox1.Items.Add("Maka disusun =>" & nas(a))
For b = a + 1 To jlhnas
c = c + 1
himpF2(a, b) = nas(a) & nas(b)
ListBox1.Items.Add("if buy " & nas(a) & "then buy" & nas(b))
SimpanDataConfedence(nas(a), nas(b))
Rule(c) = nas(a) & " " & nas(b)
c = c + 1
ListBox1.Items.Add("if buy " & nas(b) & "then buy" & nas(a))
rule(c) = nas(b) & " " & nas(a)
SimpanDataConfedence(nas(b), nas(a))
Next
Next
Dim sumnas(1000) As Integer, nnas As Integer
nnas = 0
HitungTabelNas()
End Sub
Sub HitungTabelNas()
Dim no As Integer, b As Integer
no = 0 : b = 0
For a = 1 To kolom
For b = 1 To jlhnas
qry = "select * from tblpenjualan where nofaktur='" & data(a) &
"' and kodebrg='" & nas(b) & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
ToTn(b) = ToTn(b) + 1
ListBox1.Items.Add(a & "->" & ToTn(b))
Else
ListBox1.Items.Add(a & "->")
ToTn(b) = ToTn(b) + 0
End If
Next
Next
'qry = "select * from tblanalisa1 where noanalisa1='" & rkode & "' and
"
For a = 1 To jlhnas
ListBox1.Items.Add("-->" & nas(a) & " " & ToTn(a))
qry = "update tblanalisa set f='" & ToTn(a) & "' where kodebrg='" &
nas(a) & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()

Universitas Sumatera Utara

77

Next
End Sub
Sub SimpanDataConfedence(ByVal kode As String, kode1 As String)
Dim atur As Boolean
atur = False
qry = "select * from tblsupportconfedence where nokasus='" & rkode & "'
and a1='" & kode & "' and a2='" & kode1 & "'"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
atur = True
End If
If atur = True Then
'MsgBox("Terjadi Duplikasi Data.!", MsgBoxStyle.Critical, "Alert")
Else
qry = "insert into tblsupportconfedence (nokasus, a1, a2) values
('" & rkode & "', '" & kode & "', '" & kode1 & "')"
cmd = New OleDb.OleDbCommand(qry, conn)
cmd.ExecuteNonQuery()
End If
End Sub
Sub susunarray()
Dim i As Integer, j As Integer, a As Integer, b As Integer
i = 0 : j = 0 : a = 0 : b = 0
For i = 1 To rn
a = 0
For j = 1 To i
If h1(i) = h1(j) Then
a = a + 1
End If
Next
If a >
'--------------------------------------------------------------------------------->>
Sub PROSESFP()
Dim fpfak(1000) As String, fpList(1000, 1000) As String, fpN(1000) As
Integer
Dim countfpList As Integer, a As Integer, b As Integer, c As Integer, n
As Integer
countfpList = 0 : a = 0 : b = 0 : c = 0 : n = 0
'ambil data transaksi
'-->1
For a = 1 To kolom
fpfak(a) = data(a)
qry = "select * from tblpenjualan where nofaktur='" & data(a) & "'
order by id asc"
cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader
If dtreader.HasRows Then
b = 0
While dtreader.Read
b = b + 1
fpList(a, b) = dtreader("kodebrg")
End While
fpN(a) = b
End If
Next

Dim KTr As String, lintas As String, nlintas As Integer
KTr = "" : lintas = "" : nlintas = 0
ListBox2.Items.Add("Kode Transaksi")
For a = 1 To kolom
KTr = ""
For b = 1 To fpN(a)
KTr = KTr & " " & fpList(a, b)
Next
ListBox2.Items.Add(fpfak(a) & "[" & KTr & " ]")
Next
'
For a = 1 To baris

Universitas Sumatera Utara

81

fpfak(a) = databrg(a)
Next
'
For n = 1 To baris
For a = 1 To kolom
KTr = ""
nlintas = 0
For b = 1 To fpN(a)
KTr = KTr & " " & fpList(a, b)
nlintas = nlintas + 1
If fpfak(n) = fpList(a, b) Then
lintas = KTr
If nlintas