Imports MySql.Data.MySqlClient
Public Class
FPenerbit
Dim MyCon As New
MySqlConnection("Server=localhost;User
id=root;Password=3306;Database=Perpustakaan")
Private Sub FMahasiswa_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim
MyAdapter As New
MySqlDataAdapter("Select
IdPenerbit,Nama,Alamat,Kota,NoTelepon
from Penerbit", MyCon)
Dim
MyDataTbl As New
DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
End Sub
Private Sub BtnKeluar_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles BtnKeluar.Click
If
MsgBox("YAKIN ANDA MAU KELUAR?",
MsgBoxStyle.YesNo + MsgBoxStyle.Question, "Konfirmasi")
= MsgBoxResult.Yes Then
End
End If
End Sub
Private Sub Txtcari_KeyPress(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
Txtcari.KeyPress
If
e.KeyChar = vbCr Then
If cmbcari.Text
= "IdPenerbit" Then
Dim
MyAdapter As New
MySqlDataAdapter("Select
IdPenerbit,Nama,Alamat,Kota,NoTelepon
from Penerbit Where NPM Like '%" & txtcari.Text & "%'", MyCon)
Dim
MyDataTbl As New
DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf
cmbcari.Text = "Nama" Then
Dim
MyAdapter As New
MySqlDataAdapter("Select
IdPenerbit,Nama,Alamat,Kota,NoTelepon
from Penerbit Where Nama Like '%" & txtcari.Text & "%'", MyCon)
Dim
MyDataTbl As New
DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf
cmbcari.Text = "Alamat" Then
Dim
MyAdapter As New
MySqlDataAdapter("Select
IdPenerbit,Nama,Alamat,Kota,NoTelepon
from Penerbit Where TGLLAHIR Like '%" & txtcari.Text & "%'", MyCon)
Dim
MyDataTbl As New
DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf
cmbcari.Text = "Kota" Then
Dim
MyAdapter As New
MySqlDataAdapter("Select
IdPenerbit,Nama,Alamat,Kota,NoTelepon
from Penerbit Where JKel Like '%" & txtcari.Text & "%'", MyCon)
Dim
MyDataTbl As New
DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
ElseIf
cmbcari.Text = "NoTelepon" Then
Dim
MyAdapter As New
MySqlDataAdapter("Select
IdPenerbit,Nama,Alamat,Kota,NoTelepon
from Penerbit Where ALAMAT Like '%" & txtcari.Text & "%'", MyCon)
Dim
MyDataTbl As New
DataTable
MyAdapter.Fill(MyDataTbl)
DGV.DataSource = MyDataTbl
End
If
End If
End Sub
Private Sub Txtcari_TextChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Txtcari.TextChanged
End Sub
Private Sub Btntambah_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Btntambah.Click
Btntambah.Focus()
FPenerbit_Tambah.ShowDialog()
Me.Close()
End Sub
Private Sub txtcari_TextChanged_1(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles txtcari.TextChanged
End Sub
End Class