protected void Login_Click(object sender, EventArgs e)
    {
        if (UserNum.Text == string.Empty)//如果用户名为空
        {
            Response.Write("<script>alert('用户名不能为空!');</script>");
            return;
        }
        if (Password.Text== string.Empty)
        {
            Response.Write("<script>alert('密码不能为空!');</script>");
        }
        int i = 0;//设定数据库查找变量
        string connString = @"Data Source=;Initial Catalog=****;Integrated Security=True;";
        string sql = "select count (*) from UserInfo where user='" + User.Text+ "' and password='" + Password.Text + "'";//sql语句
        SqlConnection conn = new SqlConnection(connString);
        conn.Open();//打开数据库
        using (SqlCommand cmd = conn.CreateCommand())
        {
            cmd.CommandText = sql;
            i = (int)cmd.ExecuteScalar();
        }
        if (i > 0)
        {
             Response.Write("<script>alert('登录成功!');</script>");
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误,请检查用户名和密码!');</script>");
         }
        conn.Close();//关闭数据库
    }