using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;


public partial class Login : System.Web.UI.Page
{
    EasyAccess AccessHelp = new EasyAccess();
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(txtUserName.Text) || !string.IsNullOrEmpty(txtUserPassword.Text))
        {
            string sql = "select uid,upwd from admin where uid='" + txtUserName.Text.Trim().checkHtml() + "' and upwd='" + txtUserPassword.Text.Trim().DESEncrypt().checkHtml() + "'";
            
            DataSet ds = AccessHelp.ExecuteDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                string UserName = ds.Tables[0].Rows[0]["uid"].ToString().Trim();
                string UserPwd = ds.Tables[0].Rows[0]["upwd"].ToString().Trim().DESDecrypt();
                if (txtUserName.Text.Trim().Equals(UserName) && txtUserPassword.Text.Trim().Equals(UserPwd))
                {
                    BasePage bp = new BasePage();
                    bp.SetSession(txtUserName.Text.Trim(), txtUserPassword.Text);
                    Response.Redirect("Main.aspx");
                }
                else
                {
                    JWindow.ShowDialog("管理员帐号或密码错误！");
                }
            }
        }
        else
        {
            JWindow.ShowDialog("管理员帐号或密码不可为空！");
        }
      

    }
}
