Untuk mempermudah pembayaran tol
yang manual, aplikasi ini dapat mempermudah pekerjaan bayar tol, disini kita
dapat melakukan:
- Memasukan Data Admin
lengkap dengan adanya sistem jika lupa password
- Memasukan Data Tarif
dengan simpel
- Menginputkan Data
Transaksi, Nomor Transaksi sudah otomatis mengikuti tanggal + Kode nya
- Membuat Laporan Excel
atas Transaksi
- Membuat Laporan
Transaksi menjadi PDF/CSV/Dll sesuai yang diinginkan (Crystal Report)
- Membuat Struk dari
Transaksi secara otomatis dengan Crystal Report
- Menampilkan Menu secara
Interface yang mudah
Selain itu, aplikasi ini menggunakan Database Access.
Selanjutnya adalah Gambar dan penjelasan dari Coding masing-masing Form.
Jika gambar kecil/tidak kelihatan, silahkan diklik. Berkas unduhan/download ada laman paling bawah.
Jika gambar kecil/tidak kelihatan, silahkan diklik. Berkas unduhan/download ada laman paling bawah.
Imports System.Data
Imports System.Data.OleDb
Imports Excel = Microsoft.Office.Interop.Excel
Public Class FormMenu
Sub disable()
Button1.Enabled = False
Button2.Enabled = False
Button3.Enabled = False
Button4.Enabled = False
Button5.Enabled = False
LogoutToolStripMenuItem.Enabled = False
MasterToolStripMenuItem.Enabled = False
TransaksiToolStripMenuItem.Enabled = False
LaporanToolStripMenuItem.Enabled = False
TentangKamiToolStripMenuItem.Enabled = False
ToolStripStatusLabel8.Visible = False
ToolStripStatusLabel9.Visible = False
ToolStripStatusLabel10.Visible = False
End Sub
Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click
FormTarif.ShowDialog()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
FormAdmin.ShowDialog()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
FormTransaksi.ShowDialog()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Timer1.Start()
Call disable()
FormLogin.ShowDialog()
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ToolStripStatusLabel5.Text = TimeOfDay
ToolStripStatusLabel7.Text =
Format(Now, Date.Today)
End Sub
Private Sub LoginToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
LoginToolStripMenuItem.Click
FormLogin.ShowDialog()
FormLogin.TextBox1.Focus()
End Sub
Private Sub KeluarToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
KeluarToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub AdminToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
AdminToolStripMenuItem.Click
FormAdmin.ShowDialog()
End Sub
Private Sub PenjualanToolStripMenuItem_Click(sender As Object, e As EventArgs)
FormTransaksi.ShowDialog()
End Sub
Private Sub TarifToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
TarifToolStripMenuItem.Click
FormTarif.ShowDialog()
End Sub
Private Sub TransaksiToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
TransaksiToolStripMenuItem.Click
FormTransaksi.ShowDialog()
End Sub
Private Sub LogoutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
LogoutToolStripMenuItem.Click
If ToolStripStatusLabel8.Visible = True Then
LogoutToolStripMenuItem.Enabled = True
End If
LoginToolStripMenuItem.Enabled = True
disable()
FormLogin.TextBox1.Text = ""
FormLogin.TextBox2.Text = ""
MsgBox("Berhasil
Logout")
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
FormLaporan.ShowDialog()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
FormQuery.ShowDialog()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
MsgBox("Terimakasih
sudah memakai aplikasi kami - VATSI 14, Universitas Indonesia")
End Sub
Private Sub TentangKamiToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles
TentangKamiToolStripMenuItem.Click
MsgBox("Terimakasih
sudah memakai aplikasi kami - VATSI 14, Universitas Indonesia")
End Sub
End Class
Imports System.Data
Imports System.Data.OleDb
Public Class FormLogin
Dim Koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=L:\Semester 3\2. UAS\Lab VB\UAS\AplikasiBayarTol\DBJasaTol.accdb"
Dim objkoneksi As New OleDb.OleDbConnection(Koneksi)
Private xReader As OleDbDataReader
Private Sub Login_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox2.PasswordChar = "*"
TextBox1.Focus()
End Sub
Sub enable()
FormMenu.Button1.Enabled = True
FormMenu.Button2.Enabled = True
FormMenu.Button3.Enabled = True
FormMenu.Button4.Enabled = True
FormMenu.Button5.Enabled = True
FormMenu.Button6.Enabled = True
FormMenu.LogoutToolStripMenuItem.Enabled = True
FormMenu.MasterToolStripMenuItem.Enabled = True
FormMenu.TransaksiToolStripMenuItem.Enabled
= True
FormMenu.LaporanToolStripMenuItem.Enabled = True
FormMenu.TentangKamiToolStripMenuItem.Enabled = True
FormMenu.ToolStripStatusLabel8.Visible
= True
FormMenu.ToolStripStatusLabel9.Visible
= True
FormMenu.ToolStripStatusLabel10.Visible
= True
FormMenu.LoginToolStripMenuItem.Enabled
= False
End Sub
Sub Login()
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Data login belum lengkap")
TextBox1.Focus()
Exit Sub
Else
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd As New OleDbCommand("SELECT * FROM
TableAdmin where Username='" &
TextBox1.Text & "' and
Password='" & TextBox2.Text & "'",
objkoneksi)
xReader = ocmd.ExecuteReader
If xReader.HasRows Then
MsgBox("Welcome", MsgBoxStyle.Information, "konfirmasi")
xReader.Read()
FormMenu.ToolStripStatusLabel8.Text = xReader("Username")
FormMenu.ToolStripStatusLabel9.Text = xReader("Nama")
FormMenu.ToolStripStatusLabel10.Text = xReader("Status")
Me.Close()
Call enable()
Else
MsgBox("Username
atau Password Salah", MsgBoxStyle.Information, "Konfirmasi")
End If
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Login()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
Try
If msg.WParam.ToInt32 = Convert.ToInt32(Keys.Escape) Then
Me.Close()
Else
Return MyBase.ProcessCmdKey(msg, keyData)
End If
Catch ex As Exception
Return False
End Try
Return MyBase.ProcessCmdKey(msg, keyData)
End Function
Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
e.Handled = False
TextBox2.Focus()
If TextBox2.TextLength <> 0 Then
Button1.PerformClick()
End If
End If
End Sub
Private Sub TextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox2.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
e.Handled = False
Button1.Focus()
Button1.PerformClick()
End If
End Sub
Private Sub LinkLabel1_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
Dim x As String = InputBox("Masukan
Username")
Dim y As String = InputBox("Masukkan
Nomor Telpon")
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd As New OleDbCommand("SELECT * FROM
TableAdmin where Username='" + x + "' and NoTelpon='" +
y + "' ", objkoneksi)
xReader = ocmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
MsgBox("Username: " +
xReader("Username") + " Password: " + xReader("Password"))
Else
MsgBox("Username tidak ada/No telpon salah")
End If
End Sub
End Class
Imports System.Data
Imports System.Data.OleDb
Public Class FormAdmin
Dim Koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=L:\Semester 3\2. UAS\Lab VB\UAS\AplikasiBayarTol\DBJasaTol.accdb"
Dim objkoneksi As New OleDb.OleDbConnection(Koneksi)
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim LokasiDB As String
Private xReader As OleDbDataReader
Sub Clean()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
ComboBox1.Text = ""
End Sub
Sub UpdateTabel()
da = New OleDbDataAdapter("Select * from
TableAdmin", objkoneksi)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TableAdmin")
DataGridView1.DataSource = (ds.Tables("TableAdmin"))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
objkoneksi.Close()
objkoneksi.Open()
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Then
MsgBox("Data belum lengkap")
Else
Dim command As New OleDbCommand("SELECT * FROM
TableAdmin where Username='" +
TextBox1.Text + "'", objkoneksi)
xReader = command.ExecuteReader
If xReader.HasRows Then
MsgBox("Data Sudah Ada")
Exit
Sub
Else
objkoneksi.Close()
objkoneksi.Open()
Dim tambah As String = "INSERT INTO
TableAdmin values('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "',
'" & TextBox4.Text & "','" &
ComboBox1.Text & "')"
Dim ocmd = New OleDbCommand(tambah, objkoneksi)
ocmd.ExecuteNonQuery()
objkoneksi.Close()
MsgBox("Sukses")
UpdateTabel()
Clean()
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim X As String = InputBox("Masukan
Usernamenya !")
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd As New OleDbCommand("SELECT * FROM TableAdmin where Username='" + X + "'", objkoneksi)
xReader = ocmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox1.Text = xReader("Username")
TextBox2.Text = xReader("Password")
TextBox3.Text = xReader("Nama")
TextBox4.Text = xReader("NoTelpon")
ComboBox1.Text = xReader("Status")
Else
MsgBox("Username Tidak ada !")
Clean()
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Call Clean()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
Me.Close()
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
objkoneksi.Close()
objkoneksi.Open()
Dim Delete1 As String = "Delete from
TableAdmin where Username ='" &
TextBox1.Text & "'"
Dim oCmd = New OleDbCommand(Delete1, objkoneksi)
Dim x As String = MsgBox("Apakah anda
yakin ingin di hapus ?", MsgBoxStyle.YesNo, "Konfirmasi")
If x = vbYes Then
If TextBox1.Text = "" Then
MsgBox("Data Masih Kosong, Cek Kembali", , "Konfirmasi")
Else
oCmd.ExecuteNonQuery()
Call Clean()
End If
Else
Exit Sub
End If
objkoneksi.Close()
UpdateTabel()
End Sub
Private Sub FormAdmin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO:
This line of code loads data into the 'DBJasaTolDataSet.TableAdmin' table. You
can move, or remove it, as needed.
Me.TableAdminTableAdapter.Fill(Me.DBJasaTolDataSet.TableAdmin)
UpdateTabel()
End Sub
End Class
Imports System.Data
Imports System.Data.OleDb
Public Class FormTarif
Dim Koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=L:\Semester 3\2. UAS\Lab VB\UAS\AplikasiBayarTol\DBJasaTol.accdb"
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim LokasiDB As String
Private xReader As OleDbDataReader
Sub Clean()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Sub UpdateTabel()
da = New OleDbDataAdapter("Select * from
TableTarif", objkoneksi)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TableTarif")
DataGridView1.DataSource = (ds.Tables("TableTarif"))
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Data belum lengkap")
Else
objkoneksi.Close()
objkoneksi.Open()
Dim command As New OleDbCommand("SELECT * FROM
TableTarif where Golongan='" +
TextBox1.Text + "'", objkoneksi)
xReader = command.ExecuteReader
If xReader.HasRows Then
MsgBox("Data Sudah Ada")
Exit
Sub
Else
Dim tambah As String = "INSERT INTO
TableTarif values('" & TextBox1.Text & "','" &
TextBox2.Text & "','" & TextBox3.Text & "')"
Dim ocmd = New OleDbCommand(tambah, objkoneksi)
ocmd.ExecuteNonQuery()
objkoneksi.Close()
MsgBox("Sukses")
UpdateTabel()
Clean()
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim X As String = InputBox("Masukan
Kodenya")
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd As New OleDbCommand("SELECT * FROM TableTarif
where Golongan='" + X + "'",
objkoneksi)
xReader = ocmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox1.Text = xReader("Golongan")
TextBox2.Text = xReader("JenisMobil")
TextBox3.Text = xReader("HargaTarif")
Else
MsgBox("Golongan Tidak ada !")
Clean()
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
Call Clean()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd1 As New OleDbCommand("SELECT * FROM
TableTarif where Golongan='" +
TextBox1.Text + "'", objkoneksi)
xReader = ocmd1.ExecuteReader
If xReader.HasRows Then
xReader.Read()
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
MsgBox("Data belum lengkap")
Else
objkoneksi.Close()
objkoneksi.Open()
Dim update1 As String = "UPDATE TableTarif set
JenisMobil='" & TextBox2.Text & "', HargaTarif= '"
& TextBox3.Text & "' WHERE
Golongan='" & TextBox1.Text & "'"
Dim ocmd = New OleDbCommand(update1, objkoneksi)
ocmd.ExecuteNonQuery()
objkoneksi.Close()
UpdateTabel()
MsgBox("Sukses")
End If
Else
MsgBox("Kode Tidak ada !")
TextBox2.Text = ""
TextBox2.Text = ""
End If
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Me.Close()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
objkoneksi.Close()
objkoneksi.Open()
Dim Delete1 As String = "Delete from
TableTarif where Golongan ='" &
TextBox1.Text & "'"
Dim oCmd = New OleDbCommand(Delete1, objkoneksi)
Dim x As String = MsgBox("Apakah anda
yakin ingin di hapus ?", MsgBoxStyle.YesNo, "Konfirmasi")
If x = vbYes Then
If TextBox1.Text = "" Then
MsgBox("Data Masih Kosong, Cek Kembali", , "Konfirmasi")
Else
oCmd.ExecuteNonQuery()
Call Clean()
End If
Else
Exit Sub
End If
objkoneksi.Close()
UpdateTabel()
End Sub
Private Sub FormTarif_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO:
This line of code loads data into the 'DBJasaTolDataSet.TableTarif' table. You
can move, or remove it, as needed.
Me.TableTarifTableAdapter.Fill(Me.DBJasaTolDataSet.TableTarif)
UpdateTabel()
End Sub
End Class
Imports System.Data.OleDb
Public Class FormTransaksi
Dim Koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=L:\Semester 3\2. UAS\Lab VB\UAS\AplikasiBayarTol\DBJasaTol.accdb"
Dim objkoneksi As New OleDb.OleDbConnection(Koneksi)
Public CMD As OleDbCommand
Public RD As OleDbDataReader
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim LokasiDB As String
Private xReader As OleDbDataReader
Sub Cetak()
FormStruk.ShowDialog()
End Sub
Sub Clean()
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
Sub UpdateTabel()
da = New OleDbDataAdapter("Select * from
TableTransaksi", objkoneksi)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TableTransaksi")
DataGridView1.DataSource = (ds.Tables("TableTransaksi"))
End Sub
Private Sub NoKode()
Dim NomOt As String = ""
objkoneksi.Close()
objkoneksi.Open()
Try
CMD = New OleDbCommand("SELECT TOP 1 right(NoTransaksi,3) + 1 as NoTransaksi
FROM TableTransaksi order by NoTransaksi desc ", objkoneksi)
RD = CMD.ExecuteReader
If RD.Read Then
Dim NoTransaksi1 As String
NoTransaksi1 = RD!NoTransaksi
CMD = New OleDbCommand("SELECT max(NoTransaksi) as nomax FROM
TableTransaksi", objkoneksi)
RD = CMD.ExecuteReader
If RD.Read Then
Dim tanggal, NoTransaksi2 As String
NoTransaksi2 = RD!nomax
tanggal = Format(Date.Now, "yyyyMMdd")
If
Microsoft.VisualBasic.Left(NoTransaksi2, 8) <> tanggal Then
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "0000001"
Else
Select Case NoTransaksi1
Case Is <= 9
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "000000" &
NoTransaksi1
Case Is <= 99
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "00000" &
NoTransaksi1
Case Is <= 999
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "0000" &
NoTransaksi1
Case Is <= 9999
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "000" &
NoTransaksi1
Case Is <= 99999
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "00" &
NoTransaksi1
Case Is <= 999999
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "0" &
NoTransaksi1
End Select
End If
End If
Else
NomOt = Format(Date.Now, "yyyyMMdd") & "-" & "0000001"
End If
TextBox1.Text = NomOt
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub TextBox2_KeyDown(sender As Object, e As KeyEventArgs) Handles TextBox2.KeyDown
If e.KeyCode = Keys.Enter Then
e.SuppressKeyPress = True
e.Handled = False
Button1.Focus()
Button1.PerformClick()
End If
End Sub
Private Sub FormTransaksi_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO:
This line of code loads data into the 'DBJasaTolDataSet.TableTransaksi' table.
You can move, or remove it, as needed.
Me.TableTransaksiTableAdapter.Fill(Me.DBJasaTolDataSet.TableTransaksi)
NoKode()
TextBox2.Focus()
UpdateTabel()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Data belum lengkap")
Else
If TextBox2.Text > 4 Or TextBox2.Text < 1 Then
MsgBox("Isi golongan 1-4")
TextBox2.Text = ""
Else
Dim command As New OleDbCommand("SELECT * FROM
TableTransaksi where NoTransaksi='" +
TextBox1.Text + "'", objkoneksi)
xReader = command.ExecuteReader
If xReader.HasRows Then
MsgBox("Data Sudah Ada")
Exit Sub
Else
objkoneksi.Close()
objkoneksi.Open()
Dim tambah As String = "INSERT INTO TableTransaksi values('" & TextBox1.Text & "','" & FormMenu.ToolStripStatusLabel5.Text & "','" &
FormMenu.ToolStripStatusLabel7.Text & "','" & TextBox2.Text & "')"
Dim ocmd = New OleDbCommand(tambah,
objkoneksi)
ocmd.ExecuteNonQuery()
objkoneksi.Close()
MsgBox("Sukses")
UpdateTabel()
Clean()
NoKode()
FormStruk.ShowDialog()
End If
End If
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim X As String = InputBox("Masukan
No Transaksi nya")
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd As New OleDbCommand("SELECT * FROM
TableTransaksi where NoTransaksi='" + X + "'", objkoneksi)
xReader = ocmd.ExecuteReader
If xReader.HasRows Then
xReader.Read()
TextBox1.Text = xReader("NoTransaksi")
TextBox2.Text = xReader("Golongan")
Else
MsgBox("No Transaksi Tidak ada !")
Clean()
NoKode()
End If
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
objkoneksi.Close()
objkoneksi.Open()
Dim ocmd1 As New OleDbCommand("SELECT * FROM
TableTransaksi where NoTransaksi='" +
TextBox1.Text + "'", objkoneksi)
xReader = ocmd1.ExecuteReader
If xReader.HasRows Then
xReader.Read()
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("Data
belum lengkap")
Else
Dim update1 As String = "UPDATE TableTransaksi
set Golongan='" & TextBox2.Text & "' WHERE NoTransaksi='" & TextBox1.Text & "'"
Dim ocmd = New OleDbCommand(update1, objkoneksi)
ocmd.ExecuteNonQuery()
objkoneksi.Close()
UpdateTabel()
MsgBox("Sukses")
End If
Else
MsgBox("Kode Tidak ada !")
TextBox2.Text = ""
End If
Clean()
NoKode()
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
objkoneksi.Close()
objkoneksi.Open()
Dim Delete1 As String = "Delete from
TableTransaksi where NoTransaksi ='" &
TextBox1.Text & "'"
Dim oCmd = New OleDbCommand(Delete1, objkoneksi)
Dim x As String = MsgBox("Apakah anda
yakin ingin di hapus ?", MsgBoxStyle.YesNo, "Konfirmasi")
If x = vbYes Then
If TextBox1.Text = "" Then
MsgBox("Data Masih Kosong, Cek Kembali", , "Konfirmasi")
Else
Dim command As New OleDbCommand("SELECT * FROM
TableTransaksi where NoTransaksi='" +
TextBox1.Text + "'", objkoneksi)
xReader = command.ExecuteReader
If xReader.HasRows Then
xReader.Read()
ocmd.ExecuteNonQuery()
Call Clean()
NoKode()
MsgBox("Sukses")
Else
MsgBox("Data tidak ada")
End If
End If
Else
Exit
Sub
End If
objkoneksi.Close()
UpdateTabel()
Clean()
NoKode()
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Me.Close()
End Sub
End Class
Imports System.Data.OleDb
Public Class FormQuery
Dim Koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=L:\Semester 3\2. UAS\Lab VB\UAS\AplikasiBayarTol\DBJasaTol.accdb"
Dim objkoneksi As New OleDb.OleDbConnection(Koneksi)
Public CMD As OleDbCommand
Public RD As OleDbDataReader
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim LokasiDB As String
Private xReader As OleDbDataReader
Sub UpdateTabel()
da = New OleDbDataAdapter("Select * from
QueryTransaksi", objkoneksi)
ds = New DataSet
ds.Clear()
da.Fill(ds, "QueryTransaksi")
DataGridView1.DataSource = (ds.Tables("QueryTransaksi"))
End Sub
Private Sub FormQuery_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO:
This line of code loads data into the 'DBJasaTolDataSet.QueryTransaksi' table.
You can move, or remove it, as needed.
Me.QueryTransaksiTableAdapter.Fill(Me.DBJasaTolDataSet.QueryTransaksi)
UpdateTabel()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
Dim misValue As Object = System.Reflection.Missing.Value
Dim i As Integer
Dim j As Integer
xlApp = New
Microsoft.Office.Interop.Excel.Application
xlWorkBook =
xlApp.Workbooks.Add(misValue)
xlWorkSheet = xlWorkBook.Sheets("sheet1")
For i = 0 To DataGridView1.RowCount - 2
For j = 0 To DataGridView1.ColumnCount - 1
For k As Integer = 1 To DataGridView1.Columns.Count
xlWorkSheet.Cells(1, k)
= DataGridView1.Columns(k - 1).HeaderText
xlWorkSheet.Cells(i + 2, j
+ 1) = DataGridView1(j, i).Value.ToString()
Next
Next
Next
xlWorkSheet.SaveAs("D:\Laporan Aplikasi Tol.xls")
xlWorkBook.Close()
xlApp.Quit()
releaseObject(xlApp)
releaseObject(xlWorkBook)
releaseObject(xlWorkSheet)
MsgBox("Hasil export tersimpan di D:\Laporan Aplikasi
Tol.xls")
Catch ex As Exception
End Try
End Sub
Private Sub releaseObject(ByVal obj As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
obj = Nothing
Catch ex As Exception
obj = Nothing
Finally
GC.Collect()
End Try
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
- Hasil Print Out Laporan