using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Odbc;        //ODBC命名空间

namespace ckgl
{
    public partial class login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text == "" || TextBox2.Text == "")
            {
                Response.Write("<script language=javascript> alert('对不起，用户名或密码不得为空！');</script>");
                return;
            }
            OdbcConnection con = DB.Lianjie();  //链接数据库接口文件DB.cs
            con.Open();  //打开数据库 
            string sql = "select *from glyb  where gno='" + TextBox1.Text + "' and gpass='" + TextBox2.Text + "' ";   //定义SQL查询语句
            OdbcCommand mycommand1 = new OdbcCommand(sql, con);   //将SQL查询命令放入到执行缓冲区
            OdbcDataReader sdr1 = mycommand1.ExecuteReader();   //执行SQL查询命令
            if (sdr1.Read())
            {
                Response.Redirect("admin/default.aspx");
            }
            else
            {
                Response.Write("<script language=javascript> alert('对不起，用户名或密码不正确，请重试！');</script>");
                return;
            }
            con.Close();
        }
    }
}