Protected Sub btnimglogin_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnimglogin.Click
Dim strusertype$ = ""
Try
Condb()
cm = New SqlCommand("select uid,pwd,usertype from tbl_user where uid=@user and pwd=@pass ", con)
cm.Parameters.Clear()
cm.Parameters.Add(New SqlParameter("user", txtusername.Text.Trim))
cm.Parameters.Add(New SqlParameter("pass", txtpassword.Text.Trim))
dr = cm.ExecuteReader
If dr.HasRows Then
dr.Read()
Session("username") = dr.GetString(dr.GetOrdinal("uid"))
strusertype = dr.Item("usertype")
Dim ck1 As New HttpCookie("username", Session("username"))
ck1.Expires = Now.AddDays(30)
Response.Cookies.Add(ck1)
dr.Close()
Page.Culture = "en-US"
cm = New SqlCommand("insert into tbl_logon(uid,dd)values('" & Session("username") & "','" & Now & "')", con)
cm.ExecuteNonQuery()
Select Case strusertype
Case 1
Response.Redirect("default.aspx")
Case 3
Response.Redirect("supperadmin.aspx")
End Select
Else
dr.Close()
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "Popupscript", "alert('username หรือ password ไม่ถูกต้อง!!!');", True)
End If
Catch ex As Exception
Response.Write(Err.Description)
End Try
End Sub