Private Sub frmPeople_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblPeopleID.BackColor = Color.FromArgb(0, 0, 0, 0)
Dim FD As New FormFader
FD.FadeIn(Me, 0.25)
sw.Reset()
sw.Start()
Dim strConn As String
strConn = DBConnString.strConn
Conn = New SqlConnection()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
sb = New StringBuilder()
sb.Append("SELECT * FROM tbl_preT;")
sb.Append("SELECT * FROM tbl_preE;")
sb.Append("SELECT * FROM tbl_type;")
sb.Append("SELECT * FROM tbl_campus;")
sb.Append("SELECT * FROM tbl_dep1 ORDER BY dep1Name;")
sb.Append("SELECT * FROM tbl_dep2 ORDER BY dep2Name;")
Dim sqlIni As String
sqlIni = sb.ToString()
RemoveHandler cboPreT.SelectedValueChanged, AddressOf cboPreT_SelectedValueChanged
RemoveHandler cboPreE.SelectedValueChanged, AddressOf cboPreE_SelectedValueChanged
RemoveHandler cboCampus.SelectedValueChanged, AddressOf cboCampus_SelectedValueChanged
RemoveHandler cboDep1.SelectedValueChanged, AddressOf cboDep1_SelectedValueChanged
' RemoveHandler cboDep2.SelectedValueChanged, AddressOf cboDep2_SelectedValueChanged
RemoveHandler cboType.SelectedValueChanged, AddressOf cboType_SelectedValueChanged
com = New SqlCommand()
With com
.CommandText = sqlIni
.CommandType = CommandType.Text
.Connection = Conn
dr = .ExecuteReader()
If dr.HasRows Then
dtPreT = New DataTable
dtPreT.Load(dr)
With cboPreT
.BeginUpdate()
.DisplayMember = "preTNameS"
.ValueMember = "preTID"
.DataSource = dtPreT
.EndUpdate()
End With
dtPreE = New DataTable
dtPreE.Load(dr)
With cboPreE
.BeginUpdate()
.DisplayMember = "preENameS"
.ValueMember = "preEID"
.DataSource = dtPreE
.EndUpdate()
End With
dtType = New DataTable
dtType.Load(dr)
With cboType
.BeginUpdate()
.DisplayMember = "typeName"
.ValueMember = "typeID"
.DataSource = dtType
.EndUpdate()
End With
dtCampus = New DataTable
dtCampus.Load(dr)
With cboCampus
.BeginUpdate()
.DisplayMember = "CampusNameS"
.ValueMember = "campusID"
.DataSource = dtCampus
.EndUpdate()
End With
dtDep1 = New DataTable
dtDep1.Load(dr)
With cboDep1
.BeginUpdate()
.DisplayMember = "dep1Name"
.ValueMember = "dep1ID"
.DataSource = dtDep1
.EndUpdate()
End With
dtDep2 = New DataTable
dtDep2.Load(dr)
With cboDep2
.BeginUpdate()
.DisplayMember = "dep2Name"
.ValueMember = "dep2ID"
.DataSource = dtDep2
.EndUpdate()
End With
End If
End With
dr.Close()
AddHandler cboPreT.SelectedValueChanged, AddressOf cboPreT_SelectedValueChanged
AddHandler cboPreE.SelectedValueChanged, AddressOf cboPreE_SelectedValueChanged
AddHandler cboCampus.SelectedValueChanged, AddressOf cboCampus_SelectedValueChanged
AddHandler cboDep1.SelectedValueChanged, AddressOf cboDep1_SelectedValueChanged
' AddHandler cboDep2.SelectedValueChanged, AddressOf cboDep2_SelectedValueChanged
AddHandler cboType.SelectedValueChanged, AddressOf cboType_SelectedValueChanged
iPreT.SelectedValue = cboPreT.SelectedValue
iPreE.SelectedValue = cboPreE.SelectedValue
iCampus.SelectedValue = cboCampus.SelectedValue
iDep1.SelectedValue = cboDep1.SelectedValue
iDep2.SelectedValue = cboDep2.SelectedValue
iType.SelectedValue = cboType.SelectedValue
With cboSearch
.Items.Add("รหัสบุคคล")
.Items.Add("ชื่อบุคคล(ภาษาไทย)")
.Items.Add("ชื่อบุคคล(ภาษาอังกฤษ)")
' .Items.Add("คณะ")
' .Items.Add("ภาควิชา")
.Items.Add("เบอร์โทรศัพท์มือถือ")
.SelectedIndex = 1
End With
cboPreT.ContextMenu = New ContextMenu()
cboPreE.ContextMenu = New ContextMenu()
cboCampus.ContextMenu = New ContextMenu()
cboDep1.ContextMenu = New ContextMenu()
cboDep2.ContextMenu = New ContextMenu()
cboType.ContextMenu = New ContextMenu()
picPeople.Image = picPeople.ErrorImage
' dtpAdmitDate.Value = DateTime.Today()
ClearCustomer()
tsAdd.Enabled = True
tsOK.Enabled = False
' tsCancel.Enabled = False
sw.Stop()
ProcessTime = sw.ElapsedMilliseconds / 1000
_ToolStripLabel.Text = "เวลาที่ใช้ : " & ProcessTime.ToString("0.0000") & "วินาที"
If (iSubjectDetail = False) Then
bgwPeople.RunWorkerAsync()
End If
End Sub
Private Sub cboDep1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDep1.SelectedValueChanged
iDep1.SelectedValue = cboDep1.SelectedValue
End Sub
Private Sub cboDep2_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDep2.SelectedValueChanged
iDep2.SelectedValue = cboDep2.SelectedValue
End Sub
Private Sub cboDep2_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboDep2.SelectedValueChanged
Dim sqlSelect As String = ""
sqlSelect = "SELECT *fROM tbl_Dep2 "
sqlSelect &= " WHERE(dep1ID ='" & cboDep2.SelectedValue.ToString & "') "
Dim strConn As String
strConn = DBConnString.strConn
Conn = New SqlConnection()
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
If isFind2 = True Then
ds.Tables("iDep1").Clear()
End If
da = New SqlDataAdapter(sqlSelect, Conn)
da.Fill(ds, "iDep1")
With cboDep1
.DataSource = dtDep1.Tables("cboDep1")
.DisplayMember = "dep1Name"
.ValueMember = "dep1ID"
End With
isFind2 = True
iDep2.SelectedValue = cboDep2.SelectedValue
End Sub