Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.OleDb
- Public Class Form3
- Dim ds As New DataSet
- Sub isibox()
- Try
- ComboBox1.Items.Add("Pemasukan")
- ComboBox1.Items.Add("Pengeluaran")
- ComboBox1.Text = ""
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- End Sub
- Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Try
- Dim connectionString As String = "provider=microsoft.ACE.oledb.12.0;data source=db_keuangan.accdb"
- Dim sql As String = "SELECT IdKas,TglKas,KetKas,JPemasukan,Jpengeluaran,Saldo FROM Kas"
- Dim connection As New OleDbConnection(connectionString)
- Dim dataadapter As New OleDbDataAdapter(sql, connection)
- connection.Open()
- dataadapter.Fill(ds, "Kas")
- connection.Close()
- DataGridView1.DataSource = ds.Tables(0)
- Call isibox()
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim dv As DataView
- Try
- If ComboBox1.Text = "Pemasukan" Then
- dv = New DataView(ds.Tables(0), "JPemasukan > 0 ", "JPemasukan Desc", DataViewRowState.CurrentRows)
- DataGridView1.DataSource = dv
- ElseIf ComboBox1.Text = "Pengeluaran" Then
- dv = New DataView(ds.Tables(0), "JPengeluaran > 0 ", "JPengeluaran Desc", DataViewRowState.CurrentRows)
- DataGridView1.DataSource = dv
- Else
- MsgBox("Pilihan tidak tersedia!")
- Exit Sub
- End If
- Catch ex As Exception
- MsgBox(ex.ToString)
- End Try
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement