KERJA IT - COMPUTER

Markas Rabbani Surabaya Jl.Pucang Anom Timur No. 14 Surabaya Telp. 08123015071 Email : Markas_rabbani_sby@yahoo.co.id

  • RSS
  • Google +
  • Facebook

Popular Posts

IDHOSTINGER memang OK
Radio - TV OnLine
Asyiiikk Bro

Translate Google

About Me

Foto saya

1. Kerja di Perusahaan Jualan Computer 2. Konsultan Management and Software House di Jakarta Jl. Kemang Raya Jakarta Selatan, PT Sumber Saran Sempurna 3. Honor di Kantor Bea dan Cukai TG. Perak dan Juanda Surabaya 4. Free Line di berbagai Instansi sebagai Programmer 5. Mulai awal tahun 2007 sampai sekarang kerja di Rabbani Profesor Kerudung Instan Jl. Dharmawangsa 98 A Surabaya

Popular Posts

Markas Rabbani Surabaya

HOSTINGER

Web Hosting

KOMINITAS VFP

IP ADDRESS INFO

IP

Google+ Followers

Total Tayangan Halaman

HOSTINGER

Web Hosting

Prof DR KH Said Aqil Sirodj - Ketua PB NU

Gus Mus - Prof DR KH Said Aqil Sirodj - Alm Gus Dur

HOSTINGER Web Gratis Tanpa Iklan

Gak Percaya Buktikan

Griya Asy-Syifa

Jl Suromulang Timur II/18 Perum Citra Surodinawan Estate Kota Mojokerto Contac : 081231821800, 08814353000, 085746201881 Pin BB : 24D0B84C e-mail : ariesmojokerto@gmail.com

HOSTINGER Gratis tanpa Iklan

Web Hosting GRATIS dI Indonesia Tanpa Iklan

WaliSongo

Babat alas Tanah Jawa - Pengikut Nabi Muhammad saw - NU

Minggu, 14 Oktober 2012

PENCARIAN DATA TABEL


CARA MEMBUATNYA :

Setelah Form1 kita buat maka untuk membuat Form2 Yaitu :

Klik kanan di Pojok Kanan Atas Klik Add > Windows Form :


Kemudian kita atur design nya :


Karena Tombol Button Pencarian nya ada di Form1 maka cara panggil
Form2 ( Tabel Customer ) :

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        form2.Show()
    End Sub

Kita beri nama TextBox nya misal txtcarib
DataGridViewnya kita beri nama dgvb
Ini Coding nya
Imports System.Data
Imports MySql.Data.MySqlClient
Public Class form2
    Private Sub TampilDataG()
        modul_oc.konek()

        Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer", db)

        Dim dt As New DataTable
        da.Fill(dt)
        dgvb.DataSource = dt

    End Sub

    Private Sub CekCustb()
        txtcarib.Text = Trim(UCase(txtcarib.Text))
       modul_oc.konek()
        Try
            strSql = "SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'"
            cmd.CommandText = strSql
            cmd.Connection = db
            dadapter.SelectCommand = cmd

            datardr = cmd.ExecuteReader
            datardr.Read()
            If datardr.HasRows Then
                ' datardr.Read()
                'Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'", db)

                Dim query As String = "SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'"
                Dim da As New MySqlDataAdapter(query, db)
                Dim ds As New DataSet()

                If da.Fill(ds, "ketemu") Then
                    dgvb.DataSource = ds.Tables("ketemu")
                    dgvb.ReadOnly = True
                End If

            Else
                MsgBox("Data Tables Customer Tidak Ditemukan....!", MsgBoxStyle.Exclamation, "Informasi")


            End If
            ' db.Close()
        Catch ex As Exception

        End Try

    End Sub
    Private Sub form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TampilDataG()
    End Sub

    Private Sub dgvb_CellClick(ByVal sender As Object, _
 ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvb.CellClick
        With dgvb
              Form1.txtkdcust.Text = .Item(0, .CurrentRow.Index).Value
              Form1.txtnama.Text = .Item(1, .CurrentRow.Index).Value
              Form1.txtalamat.Text = .Item(3, .CurrentRow.Index).Value
         
          End With
    End Sub

' Jika Data yg ada di Grid di Klik 2 X maka textbox yang ada di Form1 akan terisi Data yg terpilih

    Private Sub dgvb_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvb.DoubleClick
        With dgvb
            Form1.txtkdcust.Text = .Item(0, .CurrentRow.Index).Value
            Form1.txtnama.Text = .Item(1, .CurrentRow.Index).Value
            Form1.txtalamat.Text = .Item(3, .CurrentRow.Index).Value
            Me.Close()
            Form1.txtnomor.Focus()

        End With
    End Sub



    Private Sub TampilKUST()
        modul_oc.konek()
        Dim da As New MySqlDataAdapter("SELECT customercode,customername,enddate,alamat,telp FROM customer WHERE customername like '%" & txtcarib.Text & "%'", db)
        Dim dt As New DataTable
        da.Fill(dt)
        dgvb.DataSource = dt
        dgvb.Refresh()
    End Sub

' Dengan Memilih Pencarian di TextChanged maka data yg kita ketik
   langsung cari di Grid
' Misal kita ketik w maka data yg ada w nya akan muncul / di tampilkan semua.

    Private Sub txtcarib_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcarib.TextChanged
        TampilKUST()
    End Sub
End Class







Tidak ada komentar:

Posting Komentar