Listing Program Dopur

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

LISTING PROGRAM

FORM LOGIN

Imports System.Data.OleDb
Public Class frmLogin

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Try
Using con As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("SELECT * FROM tblLogin WHERE username = '"
& TextBox1.Text & "' AND password = '" & TextBox2.Text & "'", con)
con.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
If dr.HasRows Then
bersih(Me, TextBox1)
Me.Hide()
frmUtama.Show()
Else
MsgBox("Cek Kembali Username dan Password Anda",
MsgBoxStyle.Exclamation)
bersih(Me, TextBox1)
End If
End Using
End Using
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
TextBox1.Focus()
End Sub
End Class

FORM MENU UTAMA

Public Class frmUtama

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
frmHandphone.MdiParent = Me
frmHandphone.Show()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
frmTransaksi.MdiParent = Me
frmTransaksi.Show()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
frmProses.MdiParent = Me
frmProses.Show()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
frmLaporan.ShowDialog()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button5.Click
Me.Hide()
frmLogin.Show()
End Sub

Private Sub frmUtama_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load

End Sub
End Class

FORM DATA HANDPHONE

Imports System.Data.OleDb
Public Class frmHandphone

Private Sub frmHandphone_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
bersih(Me, TextBox1)
tampilData("SELECT * FROM tblHandphone", ListView1)

Button2.Enabled = False
Button3.Enabled = False

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Proses simpan tidak dapat dilakukan, Semua Field Data wajib diisi",
MsgBoxStyle.Information)
Else
simpan("INSERT INTO tblHandphone VALUES('" & TextBox1.Text & "', '" &
TextBox2.Text & "')")
tampilData("SELECT * FROM tblHandphone", ListView1)
bersih(Me, TextBox1)
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
If MsgBox("Yakin Data Akan Diubah?", MsgBoxStyle.YesNo, "Confirm") =
MsgBoxResult.Yes Then
ubah("UPDATE tblHandphone SET nmBarang='" & TextBox2.Text & "' WHERE
kdBarang='" & TextBox1.Text & "'")
tampilData("SELECT * FROM tblHandphone", ListView1)
TextBox1.Enabled = True
bersih(Me, TextBox1)
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Else
TextBox1.Enabled = True
bersih(Me, TextBox1)
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
If MsgBox("Yakin Data Akan Dihapus?", MsgBoxStyle.YesNo, "Confirm") =
MsgBoxResult.Yes Then
hapus("DELETE * FROM tblHandphone WHERE kdBarang = '" & TextBox1.Text & "'")
tampilData("SELECT * FROM tblHandphone", ListView1)
TextBox1.Enabled = True
bersih(Me, TextBox1)
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Else
TextBox1.Enabled = True
bersih(Me, TextBox1)
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
End If
End Sub

Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As


System.EventArgs) Handles ListView1.DoubleClick
TextBox1.Text = ListView1.SelectedItems(0).Text
TextBox2.Text = ListView1.SelectedItems(0).SubItems(1).Text
TextBox1.Enabled = False
TextBox2.Focus()

Button1.Enabled = False
Button2.Enabled = True
Button3.Enabled = True
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
TextBox1.Enabled = True
bersih(Me, TextBox1)
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button5.Click
Me.Close()
End Sub

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ListView1.SelectedIndexChanged

End Sub
End Class

FORM DATA TRANSAKSI

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

Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RadioButton1.CheckedChanged
If RadioButton1.Checked = True Then
TextBox1.Enabled = True
DateTimePicker1.Enabled = True
ListView1.Enabled = True
ListView2.Enabled = True
ListView3.Enabled = True
Button1.Enabled = True
Button2.Enabled = True
Button3.Enabled = True
Button4.Enabled = True
Else
TextBox1.Enabled = False
DateTimePicker1.Enabled = False
ListView1.Enabled = False
ListView2.Enabled = False
ListView3.Enabled = False
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
End If
End Sub

Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = True Then

End If
End Sub

Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As


System.EventArgs) Handles ListView1.DoubleClick
Dim kdBarang As String
kdBarang = Me.ListView1.SelectedItems(0).SubItems(1).Text
If ListView2.Items.Count = 0 Then
Dim lv As New ListViewItem
lv.Text = kdBarang
lv.SubItems.Add(Me.ListView1.SelectedItems(0).SubItems(2).Text)
ListView2.Items.Add(lv)
Else
With ListView2
Dim itm As ListViewItem
itm = .FindItemWithText(kdBarang, False, 0, False)
If Not itm Is Nothing Then
MsgBox("Data Dengan Kode Produk " & kdBarang & " Sudah Dipilih")
Else
Dim lv As New ListViewItem
lv.Text = kdBarang
lv.SubItems.Add(Me.ListView1.SelectedItems(0).SubItems(2).Text)
ListView2.Items.Add(lv)
End If
End With
End If
Label6.Text = ListView2.Items.Count
End Sub
Private Sub ListView2_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListView2.DoubleClick
ListView2.SelectedItems(0).Remove()
Label6.Text = ListView2.Items.Count
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Try
For i = 0 To ListView2.Items.Count - 1
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("INSERT INTO tblTransaksi VALUES('" &
TextBox1.Text & "', '" & DateTimePicker1.Text & "', '" &
ListView2.Items(i).SubItems(0).Text & "', '" & ListView2.Items(i).SubItems(1).Text &
"')", conn)
conn.Open()
cmd.ExecuteReader()
End Using
End Using
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
MsgBox("Data Telah Disimpan")
tampilDataTransaksi()
ListView2.Items.Clear()
autoID()
End Try
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button2.Click
Try
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("DELETE FROM tblTransaksi WHERE kdTransaksi
= '" & TextBox1.Text & "'", conn)
conn.Open()
cmd.ExecuteReader()
End Using
End Using
For i = 0 To ListView2.Items.Count - 1
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("INSERT INTO tblTransaksi VALUES('" &
TextBox1.Text & "', '" & DateTimePicker1.Text & "', '" &
ListView2.Items(i).SubItems(0).Text & "', '" & ListView2.Items(i).SubItems(1).Text &
"')", conn)
conn.Open()
cmd.ExecuteReader()
End Using
End Using
Next
Catch ex As Exception
MsgBox(ex.Message)
Finally
MsgBox("Data Telah Diubah")
tampilDataTransaksi()
ListView2.Items.Clear()
autoID()
Me.DateTimePicker1.Focus()
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
End Try
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
Try
If MsgBox("Anda Akan Menghapus Data Transaksi?", MsgBoxStyle.YesNo,
"Konfirmasi") = MsgBoxResult.Yes Then
hapus("DELETE FROM tblTransaksi WHERE kdTransaksi='" & TextBox1.Text &
"'")
End If
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Catch ex As Exception
MsgBox(ex.Message)
Finally
tampilDataTransaksi()
autoID()
ListView2.Items.Clear()
Me.DateTimePicker1.Value = Today
End Try
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
ListView2.Items.Clear()
autoID()
Me.DateTimePicker1.Value = Today
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button5.Click
ListView2.Items.Clear()
autoID()
Me.DateTimePicker1.Value = Today
End Sub
Private Sub ListView3_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListView3.DoubleClick

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

Private Sub ListView3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ListView3.SelectedIndexChanged

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

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
If TextBox1.Text = 0 And TextBox2.Text = 0 Then
MsgBox("Tentukan Min. Support dan Min.Confidence Terlebih Dahulu",
MsgBoxStyle.Exclamation, "Warning")
Else
Me.Text = "PROSES FP-Growth | Sedang Berjalan..."

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

Dim jlhDataMemenuhiSupport As Integer = ListView2.Items.Count - 1


For i = jlhDataMemenuhiSupport To 0 Step -1
For j = 0 To jlhDataMemenuhiSupport

Dim kdBarang As String = ListView2.Items(i).SubItems(2).Text


Dim kdBarang1 As String = ListView2.Items(j).SubItems(2).Text
Dim support1 As Integer = Val(ListView2.Items(j).SubItems(4).Text)
If kdBarang = kdBarang1 Then
Else
Dim cek1, cek2 As Boolean
Dim freq2Item As Integer = 0
Dim support2 As Double
Try
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand("SELECT DISTINCT
kdTransaksi FROM tblTransaksi", conn)
conn.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
While dr.Read
cek1 = False
cek2 = False
Using cmd1 As New OleDbCommand("SELECT * FROM
tblTransaksi WHERE kdTransaksi = '" & dr("kdTransaksi") & "' and kdBarang = '" & kdBarang
& "'", conn)
Using dr1 As OleDbDataReader =
cmd1.ExecuteReader
While dr1.Read
cek1 = True
End While
End Using
End Using
Using cmd2 As New OleDbCommand("SELECT * FROM
tblTransaksi WHERE kdTransaksi = '" & dr("kdTransaksi") & "' and kdBarang = '" &
kdBarang1 & "'", conn)
Using dr2 As OleDbDataReader =
cmd2.ExecuteReader
While dr2.Read
cek2 = True
End While
End Using
End Using

If cek1 = True And cek2 = True Then


cek1 = False
cek2 = False
freq2Item += 1
End If
End While
End Using
End Using

support2 = FormatNumber(freq2Item / getJlhTransaksi() *


100, 2)
Dim conf As Double
conf = FormatNumber(freq2Item / support1 * 100, 2)
If support2 >= Val(TextBox1.Text) And conf >=
Val(TextBox2.Text) Then
Dim lv =
ListView3.Items.Add(ListView2.Items(j).SubItems(3).Text)
With lv

.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

Dim no1 As Integer = 1


For i = 0 To ListView3.Items.Count - 1
ListView3.Items(i).SubItems(0).Text = no1
no1 += 1
Next
End If

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

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button3.Click
frmLaporan.ShowDialog()
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button4.Click
Me.Close()
End Sub

Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ListView1.SelectedIndexChanged

End Sub
End Class

FORM HASIL

Public Class frmLaporan

Private Sub frmLaporan_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Try
Dim rptEng As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim conInfo As New CrystalDecisions.Shared.TableLogOnInfo
Dim rptPath As String = Application.StartupPath & "\Report1.rpt"

rptEng.Load(rptPath)

For counter As Integer = 0 To rptEng.Database.Tables.Count - 1


rptEng.Database.Tables(counter).ApplyLogOnInfo(conInfo)
Next
rptEng.RecordSelectionFormula = ""
CrystalReportViewer1.ReportSource = rptEng
CrystalReportViewer1.RefreshReport()
CrystalReportViewer1.Show()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub CrystalReportViewer1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CrystalReportViewer1.Load

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"

Public Sub tampilData(ByVal query As String, ByVal lv As ListView)


Dim no As Integer = 1
Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand(query, conn)
conn.Open()
Using dr As OleDbDataReader = cmd.ExecuteReader
lv.Items.Clear()
While dr.Read
Dim lv1 = lv.Items.Add(no)
With lv1
For i = 0 To dr.FieldCount - 1
.subitems.add(IIf(IsDBNull(dr(i)) = True, "-", dr(i)))
Next
End With
no += 1
End While
End Using
End Using
End Using
End Sub

Public Sub simpan(ByVal query As String)


Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand(query, conn)
conn.Open()
cmd.ExecuteReader()
MsgBox("Data Telah Disimpan")
End Using
End Using
End Sub

Public Sub ubah(ByVal query As String)


Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand(query, conn)
conn.Open()
cmd.ExecuteReader()
MsgBox("Data Telah Diubah")
End Using
End Using
End Sub

Public Sub hapus(ByVal query As String)


Using conn As New OleDbConnection(DBURL)
Using cmd As New OleDbCommand(query, conn)
conn.Open()
cmd.ExecuteReader()
MsgBox("Data Telah Dihapus")
End Using
End Using
End Sub

Sub bersih(ByVal obj As Control, ByVal txt1 As Control)


For Each itm As Control In obj.Controls
If TypeOf itm Is TextBox Then
itm.Text = ""
itm.Enabled = True
End If
If TypeOf itm Is ComboBox Then
itm.Text = "-PILIH-"
End If
Next
txt1.Focus()
End Sub

End Module

You might also like