Advertisement
binjeeclick

fillter

Dec 9th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.75 KB | None | 0 0
  1. Imports System.Data.OleDb
  2. Public Class Form3
  3.     Dim ds As New DataSet
  4.     Sub isibox()
  5.         Try
  6.             ComboBox1.Items.Add("Pemasukan")
  7.             ComboBox1.Items.Add("Pengeluaran")
  8.             ComboBox1.Text = ""
  9.         Catch ex As Exception
  10.             MsgBox(ex.ToString)
  11.         End Try
  12.     End Sub
  13.     Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  14.         Try
  15.             Dim connectionString As String = "provider=microsoft.ACE.oledb.12.0;data source=db_keuangan.accdb"
  16.             Dim sql As String = "SELECT IdKas,TglKas,KetKas,JPemasukan,Jpengeluaran,Saldo FROM Kas"
  17.             Dim connection As New OleDbConnection(connectionString)
  18.             Dim dataadapter As New OleDbDataAdapter(sql, connection)
  19.             connection.Open()
  20.             dataadapter.Fill(ds, "Kas")
  21.             connection.Close()
  22.             DataGridView1.DataSource = ds.Tables(0)
  23.             Call isibox()
  24.         Catch ex As Exception
  25.             MsgBox(ex.ToString)
  26.         End Try
  27.     End Sub
  28.     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  29.         Dim dv As DataView
  30.         Try
  31.             If ComboBox1.Text = "Pemasukan" Then
  32.                 dv = New DataView(ds.Tables(0), "JPemasukan > 0 ", "JPemasukan Desc", DataViewRowState.CurrentRows)
  33.                 DataGridView1.DataSource = dv
  34.             ElseIf ComboBox1.Text = "Pengeluaran" Then
  35.                 dv = New DataView(ds.Tables(0), "JPengeluaran > 0 ", "JPengeluaran Desc", DataViewRowState.CurrentRows)
  36.                 DataGridView1.DataSource = dv
  37.             Else
  38.                 MsgBox("Pilihan tidak tersedia!")
  39.                 Exit Sub
  40.             End If
  41.         Catch ex As Exception
  42.             MsgBox(ex.ToString)
  43.         End Try
  44.     End Sub
  45. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement