Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports
Imports System.Text
Imports System.IO
Imports System.Xml
Imports System.Data.SqlClient
Public Class FrmCryt_HR
Dim sb As StringBuilder
Dim ds As DataSet
Dim da As SqlDataAdapter
Dim prv_id As New ArrayList
Dim status As New ArrayList
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sb = New StringBuilder
sb.Append("SELECT PRV_ID,PRV_NAME_TH from Province")
connection()
da = New SqlDataAdapter(sb.ToString, conn)
ds = New DataSet
For i = 0 To da.Fill(ds, "Province") - 1
cboPRV.Properties.Items.Add(ds.Tables("Province").Rows(i)("PRV_NAME_TH").ToString)
prv_id.Add(ds.Tables("Province").Rows(i)("PRV_ID").ToString)
Next
conn.Close()
sb = New StringBuilder
sb.Append("SELECT* from Status")
connection()
da = New SqlDataAdapter(sb.ToString, conn)
ds = New DataSet
For i = 0 To da.Fill(ds, "Status") - 1
Cbstatus.Properties.Items.Add(ds.Tables("Status").Rows(i)("status_full").ToString)
status.Add(ds.Tables("Status").Rows(i)("status").ToString)
Next
conn.Close()
End Sub
Private Sub cbomenu_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbomenu.SelectedIndexChanged
If cbomenu.SelectedIndex = 0 Then
Panel2.Visible = True
Panel1.Visible = False
Panel3.Visible = False
ElseIf cbomenu.SelectedIndex = 1 Then
Panel2.Visible = False
Panel1.Visible = True
cboPRV.SelectedIndex = -1
Panel3.Visible = False
ElseIf cbomenu.SelectedIndex = 2 Then
Panel1.Visible = False
Panel2.Visible = False
Panel3.Visible = True
Cbstatus.SelectedIndex = -1
End If
End Sub
Private Sub txtsearch_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtsearch.EditValueChanged
sb = New StringBuilder
sb.Append("SELECT * FROM V_User_TH")
sb.Append(" WHERE User_id like '" & txtsearch.Text & "'")
sb.Append("Order by User_id asc")
connection()
da = New SqlDataAdapter(sb.ToString, conn)
ds = New DataSet
da.Fill(ds, "V_User_TH")
conn.Close()
End Sub
Private Sub cboPRV_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboPRV.SelectedIndexChanged
sb = New StringBuilder
sb.Append("SELECT * FROM V_User_TH")
sb.Append(" WHERE prv_id ='" & prv_id(cboPRV.SelectedIndex).ToString & "'")
connection()
da = New SqlDataAdapter(sb.ToString, conn)
ds = New DataSet
da.Fill(ds, "V_User_TH")
conn.Close()
End Sub
Private Sub Cbstatus_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cbstatus.SelectedIndexChanged
sb = New StringBuilder
sb.Append("SELECT * FROM V_User_TH")
sb.Append(" WHERE status ='" & status(Cbstatus.SelectedIndex).ToString & "'")
connection()
da = New SqlDataAdapter(sb.ToString, conn)
ds = New DataSet
da.Fill(ds, "V_User_TH")
conn.Close()
End Sub
End Class
Tag : .NET, Ms SQL Server 2008, Crystal Report, Win (Windows App), VS 2010 (.NET 4.x)