Imports System.Data
Imports System.Drawing
Imports BaseFunction.PublicMethod

Partial Class Admin_Login
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Buffer = True
        Response.ExpiresAbsolute = Now().AddDays(-1)
        Response.Expires = 0
        Response.CacheControl = "no-cache"
        txtUserName.Focus()
    End Sub

    Protected Sub ibLogin_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibLogin.Click
        Dim strScript As String = ""
        If Trim(txtUserName.Text) <> "" And Trim(txtPassWord.Text) <> "" And Trim(txtCode.Text <> "") Then
            Dim SiteKey As String = BaseFunction.PublicMethod.GetApplication("SiteKey")
            Dim strCode As String = Request.Cookies("CodeCookie").Value
            If txtCode.Text = strCode Then
                If BaseFunction.SiteUser.LoginVerification(txtUserName.Text, txtPassWord.Text, True) Then
                    Response.Redirect("/Manager/Admin_Index.aspx")
                    Exit Sub
                Else
                    strScript = "<script>window.alert('用户名或密码错误！');window.location='Login.aspx';</script>"
                End If
            Else
                strScript = "<script>window.alert('验证码错误！');window.location='Login.aspx';</script>"
            End If
        Else
            strScript = "<script>window.alert('所有输入项不能为空！');window.location='Login.aspx';</script>"
        End If
        For Each mCookie As String In Request.Cookies.AllKeys
            Response.Cookies(mCookie).Expires = Now.AddDays(-1)
        Next
        Response.Write(strScript)
    End Sub
End Class
