Sub Search()
If TbxSearch.Text = "" Then
MessageBox.Show("กรุณาระบุรหัสพนักงานก่อน !!! ", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
Dim sql As String
Dim dr As OleDbDataReader
Dim ID As String
ID = TbxSearch.Text.Trim
sql = "select * from Employee where IDEmployee='" & ID & "'"
Dim cmd As New OleDbCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = sql
cmd.Connection = connect
dr = cmd.ExecuteReader
If dr.HasRows Then
dr.Read()
TbxIDEmployee.Text = dr.Item("IDEmployee").ToString
CMBTitleName.Text = dr.Item("TitleName").ToString
TbxFullName.Text = dr.Item("FullName").ToString
CmbDay.Text = dr.Item("_Day").ToString
CmbMonth.Text = dr.Item("_Month").ToString
CmbYear.Text = dr.Item("_Year").ToString
TbxAddress.Text = dr.Item("Address").ToString
MPhoneNumber.Text = dr.Item("PhoneNumber").ToString
MIDCard.Text = dr.Item("IDCard").ToString
DateTimePicker1.Value = dr.Item("Start").ToString
TbxAppointment.Text = dr.Item("Appointment").ToString
CMBEducation.Text = dr.Item("Education").ToString
TbxBranch.Text = dr.Item("Branch").ToString
TbxSalary.Text = dr.Item("Salary").ToString
Picture.Image = dr.Item("Picture").ToString
TbxSearch.Text = ""
Else
MessageBox.Show("ไม่พบพนักงานในระบบ", "ค้นหา", MessageBoxButtons.OK, MessageBoxIcon.Error)
TbxSearch.SelectAll()
End If
ListBox1.Enabled = False
Dim text As String
text = MessageBox.Show("ต้องการค้นหาข้อมูลพนักงานต่อหรือไม่", ".", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If text = MsgBoxResult.Yes Then
Else
ListBox1.Enabled = True
End If
Dim fiStream As New FileStream(TbxFilename.Text, FileMode.Open, FileAccess.Read)
Dim binReader As New BinaryReader(fiStream)
Dim pic() As Byte = binReader.ReadBytes(fiStream.Length)
cmd.Parameters.AddWithValue("Picture", pic)