Imports System.Data
Imports MySql.Data.MySqlClient
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblTitle.Text = "ยินดีต้อนรับสู่ TMN Billing"
Me.Title = "TMN Bill"
Call condef()
Dim ds1 As New DataSet
Dim da1 As New MySqlDataAdapter
da1.SelectCommand = New MySqlCommand("select * from tblemployee", MyCon)
da1.Fill(ds1, "tblemployee")
DropDownList1.DataSource = ds1.Tables("tblemployee")
DropDownList1.DataTextField = "EmpName"
DropDownList1.DataValueField = "EmpID"
DropDownList1.DataBind()
End Sub
'Public EmpName As String = ""
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLog.Click
If txtPass.Text = "" Or DropDownList1.Text = "" Then
lblAlert.Text = "กรุณากรอกข้อมูล"
Exit Sub
End If
condef()
Dim ds As New DataSet
Dim da As New MySqlDataAdapter
da.SelectCommand = New MySqlCommand("select * from tblemployee where EmpID='" & DropDownList1.SelectedItem.Text & "' and Password='" & txtPass.Text & "'", MyCon)
da.Fill(ds, "tblemployee")
If ds.Tables("tblemployee").Rows.Count < 1 Then
lblAlert.Text = "User / Password Is wrong! ชื่อผู้ใช้ หรือ รหัสผ่านไม่ถูกต้อง"
EmpName = ""
txtPass.Text = ""
KeeperID = ""
'DropDownList1.Text = ""
Else
EmpName = ds.Tables("tblemployee").Rows(0).Item("EmpName").ToString
KeeperID = ds.Tables("tblemployee").Rows(0).Item("KeeperID").ToString
lblAlert.Text = "ยินดีต้อนรับ " & EmpName
Me.Title = "ยินต้อนรับคุณ " & EmpName
Response.Redirect("LoginSucess.aspx")
txtPass.Text = ""
'DropDownList1.Text = ""
End If
End Sub
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles DropDownList1.SelectedIndexChanged
End Sub
End Class