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
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
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
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 As Object, e As EventArgs) Handles HargaToolStripMenuItem.Click
FrmHarga.Show() End Sub
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()
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()
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
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
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
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
Private Sub txtkey_TextChanged(sender As Object, e As EventArgs) Handles txtkey.TextChanged
End Sub
Private Sub ListView2_KeyPress(sender As Object, e As 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
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()
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 <= 0 Then
qry = "insert into tblpenjualan (nofaktur, tgl, kodebrg, qty, harga) values ('" & lblno.Text & "', '" & txttgl.Value & "', '" & txtkode.Text & "', '" & txtqty.Text & "', '" & txtharga.Text & "')"
cmd = New OleDb.OleDbCommand(qry, conn) cmd.ExecuteNonQuery()
End If
jlhbrg1 = txtqty.Text + jlh If jlh >= 1 Then
qry = "update tblpenjualan set qty='" & jlhbrg1 & "' where nofaktur='" & lblno.Text & "' and kodebrg='" & txtkode.Text & "'"
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 & "'"
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 End Sub
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 End Sub
Sub ListBarang() Dim no As Integer Dim lst As ListViewItem no = 0
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
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.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
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
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
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
'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) & "'"
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 <= 1 Then b = b + 1 nas(b) = h1(i) End If
Next jlhnas = b End Sub
Function CEKitemSETKiri(ByVal kode1 As String, nofaktur As String) As Integer
CEKitemSETKiri = 0
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then CEKitemSETKiri = 1 End If
End Function
Function CEKitemSETKanan(ByVal kode1 As String, nofaktur As String) As Integer
CEKitemSETKanan = 0
qry = "select * from tblpenjualan where nofaktur='" & nofaktur & "' and kodebrg='" & kode1 & "'"
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then CEKitemSETKanan = 1 End If
End Function
Sub TabelConfedence()
Dim no As Integer, f As Integer, t As Integer no = 0 : f = 0 : t = 0
qry = "select * from tblanalisa where noanalisa='" & rkode & "' and f<>0"
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then While dtreader.Read no = no + 1 End While End If
f = no
qry = "Select * from tblanalisa1 where noanalisa='" & rkode & "'" cmd = New OleDb.OleDbCommand(qry, conn)
dtreader = cmd.ExecuteReader no = 0
If dtreader.HasRows Then While dtreader.Read no = no + 1 End While End If
t = no
no = 0
qry = "select * from tblsupportconfedence where nokasus='" & rkode & "'"
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then While dtreader.Read no = no + 1
kid(no) = dtreader("id") kode(no) = dtreader("a1") End While
End If
Dim n As Integer, a As Integer n = no
For a = 1 To n
sp = (f / t) * 100
nc = cekhimpunan(kode(a)) cf = (f / nc) * 100 simpanSC(sp, cf, kid(a)) Next
Timer1.Enabled = False End Sub
Sub simpanSC(ByVal kodes As Integer, kodec As Integer, id As Integer) qry = "update tblsupportconfedence set support='" & kodes & "', confedence='" & kodec & "' where id=" & id
cmd = New OleDb.OleDbCommand(qry, conn) cmd.ExecuteNonQuery()
End Sub
Function cekhimpunan(ByVal kode As String) As Integer cekhimpunan = 0
qry = "Select * from tblanalisa where noanalisa='" & rkode & "' and kodebrg='" & kode & "'"
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then If dtreader.Read Then
cekhimpunan = dtreader("f") End If
End If End Function
'--->>
'--->>
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
'
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 <= 1 Then
Else
ListBox2.Items.Add(fpList(a, b) & "->" & a & ", " & b & "= " & lintas)
simpanfpg(n, lintas) End If
' End If Next
'ListBox2.Items.Add("Lintas-" & n & ", " & a & "->" & lintas) 'simpanfpg(n, lintas)
Next Next
'->load data atribut
Dim key As String, link As String, target As String, linklist As String For a = 1 To baris
key = fpfak(a) link = "" linklist = "" For b = 1 To kolom For c = 1 To fpN(b) target = fpList(a, b)
link = link & ", " & fpList(a, b) If key = target Then
End If Next Next
'ListBox2.Items.Add("Transaksi->" & key & ">>" & linklist) Next
End Sub
Sub simpanfpg(ByVal fp As String, fpg As String) Dim stsimpanfpg As Boolean
stsimpanfpg = False
qry = "Select * from tblfpgrowth where nokasus='" & rkode & "' and fp='" & fp & "' and fpg='" & fpg & "'"
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then stsimpanfpg = True End If
If stsimpanfpg = False Then
qry = "insert into tblfpgrowth (nokasus, fp, fpg) values ('" & rkode & "', '" & fp & "', '" & fpg & "')"
cmd = New OleDb.OleDbCommand(qry, conn) cmd.ExecuteNonQuery()
End If
End Sub
Function reloadHasil(ByVal kode As Integer) As Integer reloadHasil = 0
reloadHasil = XHasil(1) End Function
Sub ReadHasil(ByVal kode As Integer) kode = reloadHasil(1)
qry = "select * from tblsupportconfedence where nokasus='" & rkode & "' and confedence=" & kode
cmd = New OleDb.OleDbCommand(qry, conn) dtreader = cmd.ExecuteReader
If dtreader.HasRows Then While dtreader.Read
PrintHasil(dtreader("a1"), dtreader("a2")) lblc.Text = dtreader("confedence")
lbls.Text = dtreader("support") End While
TimeAnalisa() End Sub
Function patters(ByVal kode As String) As String patters = ""
End Function
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
sec = sec + 1
Dim a As Integer, b As Integer a = ListBox1.Items.Count b = ListBox2.Items.Count If sec <= 1 Then
Label5.Text = a \ 60 Timer1.Enabled = False End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close() End Sub
Sub PrintHasil(ByVal kode As String, kode1 As String)
ListBox3.Items.Add("Jika beli " & kode & ", maka dibeli " & kode1) ListBox4.Items.Add("Jika beli " & kode & ", maka dibeli " & kode1) End Sub
Sub TimeAnalisa()
Dim a As Integer, b As Integer a = ListBox1.Items.Count b = ListBox2.Items.Count
Label5.Text = (a \ 60) & "," & a & " second" Label6.Text = (b \ 60) & ", " & b & " second" End Sub