Private Sub EmpInfo()
'Dim sql As String = "SELECT DISTINCT(EmpFrontName) FROM Employee" ตรวจสอบค่าซ้ำ
Dim sql As String = "SELECT IDEmp,EmpFrontName FROM Employee"
Cmd = New OleDbCommand(sql, con)
Dim adapter = New OleDbDataAdapter(Cmd)
Data = New DataSet()
adapter.Fill(Data, "Emp")
With NameBox
.DataSource = Data.Tables("Emp")
.DisplayMember = "EmpFrontName"
.ValueMember = "IDEmp"
End With
End Sub
Private Sub empdetial()
On Error Resume Next
Dim sql As String = "SELECT * FROM Employee WHERE IDEmp = ?"
cmd = New OleDbCommand(sql, con)
cmd.Parameters.AddWithValue("", NameBox.SelectedValue)
adapter = New OleDbDataAdapter(cmd)
Data.Clear()
adapter.Fill(Data, "Fnameinfo")
EmpID.Text = Data.Tables("Fnameinfo").Rows(0)("IDEmp")
name1.Text = Data.Tables("Fnameinfo").Rows(0)("EmpLastName")
name2.Text = Data.Tables("Fnameinfo").Rows(0)("EmpNickName")
positioning.Text = Data.Tables("Fnameinfo").Rows(0)("EmpPosition")
duty.Text = Data.Tables("Fnameinfo").Rows(0)("EmpJob")
Bdate.Text = Data.Tables("Fnameinfo").Rows(0)("EmpBeginDate")
Money.Text = Data.Tables("Fnameinfo").Rows(0)("EmpSalary")
StatusBox.Text = Data.Tables("Fnameinfo").Rows(0)("StatusEmp")
End Sub
Private Sub EmpInfo()
Dim sql As String = "SELECT IDEmp,EmpFrontName FROM Employee"
Cmd = New OleDbCommand(sql, con)
Dim adapter = New OleDbDataAdapter(Cmd)
Data = New DataSet()
adapter.Fill(Data, "Emp")
With NameBox
.DataSource = Data.Tables("Emp")
.DisplayMember = "EmpFrontName"
.ValueMember = "IDEmp"
End With
End Sub
Private Sub empdetial()
Try
Dim sql As String = "SELECT * FROM Employee WHERE IDEmp = @IDEmp"
cmd = New OleDbCommand(sql, con)
cmd.Parameters.AddWithValue("@IDEmp", NameBox.SelectedValue)
adapter = New OleDbDataAdapter(cmd)
Data.Clear()
adapter.Fill(Data, "Fnameinfo")
EmpID.Text = Data.Tables("Fnameinfo").Rows(0)("IDEmp")
name1.Text = Data.Tables("Fnameinfo").Rows(0)("EmpLastName")
name2.Text = Data.Tables("Fnameinfo").Rows(0)("EmpNickName")
positioning.Text = Data.Tables("Fnameinfo").Rows(0)("EmpPosition")
duty.Text = Data.Tables("Fnameinfo").Rows(0)("EmpJob")
Bdate.Text = Data.Tables("Fnameinfo").Rows(0)("EmpBeginDate")
Money.Text = Data.Tables("Fnameinfo").Rows(0)("EmpSalary")
StatusBox.Text = Data.Tables("Fnameinfo").Rows(0)("StatusEmp")
Catch ex as Exception
Messagebox.Show(ex.Message)
End Try
End Sub