ADSENSE HERE!
Jika ingin membuat form PopUp klik kanan di projec=>pilih add windows form beri nama form tersebut searchsiswa. Desain PopUp anda seperti gambar di bawah ini :
Kemudian masukkan kode di bawah ini.
Imports Oracle.DataAccess
Imports Oracle.DataAccess.Client
Public Class searchsiswa
Public popnis, popnama, popalamat, poptgllahir, poptlp, poppendidikan, popjurusan, popjnskel As String
Dim con As OracleConnection
Dim cmmd As OracleCommand
Dim strconnecting As String = "Data Source=xe; User Id=windamr; Password=windamr;"
Dim dReader As OracleDataReader
Private Sub clear_list()
While Val(counter.Text) > 0
ListView1.Items(0).Remove()
counter.Text = Val(counter.Text) - 1
End While
End Sub
Private Sub list_data()
'Call clear_list()
Dim sqlx As String
Dim x As Integer
sqlx = "select * from datasiswa where nis like '%" & Trim(txtkey.Text) & "%' order by nis asc"
con = New OracleConnection(strconnecting)
If con.State <> ConnectionState.Closed Then
con.Close()
Else
con.Open()
End If
cmmd = New OracleCommand(sqlx, con)
dReader = cmmd.ExecuteReader
Try
While dReader.Read = True
x = Val(counter.Text)
counter.Text = Str(Val(counter.Text) + 1)
With ListView1
.Items.Add("")
.Items(ListView1.Items.Count - 1).SubItems.Add("nis")
.Items(ListView1.Items.Count - 1).SubItems.Add("nama")
.Items(ListView1.Items.Count - 1).SubItems.Add("alamat")
.Items(ListView1.Items.Count - 1).SubItems.Add("tgllahir")
.Items(ListView1.Items.Count - 1).SubItems.Add("tlp")
.Items(ListView1.Items.Count - 1).SubItems.Add("pendidikan")
.Items(ListView1.Items.Count - 1).SubItems.Add("jurusan")
.Items(ListView1.Items.Count - 1).SubItems.Add("jnskel")
.Items(x).SubItems(0).Text = dReader.GetString(0)
.Items(x).SubItems(1).Text = dReader.GetString(1)
.Items(x).SubItems(2).Text = dReader.GetString(2)
.Items(x).SubItems(3).Text = Format(CDate(dReader.GetDateTime(3)), "dd-MM-yyyy")
.Items(x).SubItems(4).Text = dReader.GetString(4)
.Items(x).SubItems(5).Text = dReader.GetString(5)
.Items(x).SubItems(6).Text = dReader.GetString(6)
.Items(x).SubItems(7).Text = dReader.GetString(7)
End With
End While
Finally
dReader.Close()
End Try
con.Close()
End Sub
Private Sub pilih()
Try
popnis = ListView1.SelectedItems(0).SubItems(0).Text.ToString
popnama = ListView1.SelectedItems(0).SubItems(1).Text.ToString
popalamat = ListView1.SelectedItems(0).SubItems(2).Text.ToString
poptgllahir = ListView1.SelectedItems(0).SubItems(3).Text.ToString
poptlp = ListView1.SelectedItems(0).SubItems(4).Text.ToString
poppendidikan = ListView1.SelectedItems(0).SubItems(5).Text.ToString
popjurusan = ListView1.SelectedItems(0).SubItems(6).Text.ToString
popjnskel = ListView1.SelectedItems(0).SubItems(7).Text.ToString
Me.Close()
Catch ex As Exception
MsgBox("pilih salah satu data", MsgBoxStyle.Information)
End Try
End Sub
Private Sub searchsiswa_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call list_data()
End Sub
Private Sub txtkey_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkey.TextChanged
Call list_data()
End Sub
Private Sub ListView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
Call pilih()
End Sub
Private Sub cmdok_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdok.Click
Call pilih()
End Sub
End Class
Untuk menjalankan form ini pertama-tama kita harus setting form mana yang ingin kita tampilkan. Dengan cara klik kanan di project=> Properties=> pilih menu bar aplication startup form di ganti sesuai form yang ingin anda jalankan.
ADSENSE HERE!
No comments:
Post a Comment