using System;
using System.Data;
using System.Data.SqlClient;
using CRM.DBUtility;
using CRM.Common;

public partial class _Default : System.Web.UI.Page
{
    protected void Button1_Click(object sender, EventArgs e)
    {
        //if (txtValidator.Text.Trim().ToLower() ==Session["CheckCode"].ToString().Trim().ToLower())
        //{
        if (txtUsername.Text.Trim() == "" || txtPassword.Text.Trim() == "") {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "Login", "<script>alert('用户名或密码不能为空！');</script>");
            return;
        }
            string temp = CRM.Common.Login.CheckLogin(txtUsername.Text.Trim(),txtPassword.Text.Trim());
            if (temp == "")
            {
                //Panel1.Visible = false;
            }
            else {
                 ClientScript.RegisterClientScriptBlock(this.GetType(),"Login", "<script>alert('" + temp + "');</script>");
            }     
        //else {
            //ClientScript.RegisterClientScriptBlock(this.GetType(),"errorvalidator", "<script>alert('验证码错误');window.location.href='Default.aspx'</script>");
        
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //Panel1.Visible = false;
            string checkCode = CRM.Common.Validator.Validator.GetStringInt(4);
            Session["CheckCode"] = checkCode;
            //HyperLink1.NavigateUrl = "Default.aspx";
        }
    }
}
