大家来围观下,这句什么意思
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Logon : System.Web.UI.Page
{
Operation operation = new Operation(); //声明业务类
Random random = new Random(); //声明随机类对象
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
lblCheckCode.Text = random.Next(1000, 9999).ToString();
txtUser.Focus();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (lblCheckCode.Text.Trim() != txtCheckCode.Text.Trim()) //判断验证码
{
WebMessageBox.Show("输入验证码不正确!", "Logon.aspx");
}
if (operation.Logon(txtUser.Text, txtPwd.Text).Tables[0].Rows.Count > 0) //判断用户是否合法。
{
Session.Add("UserName", txtUser.Text.Trim()); //将用户名称存储在Session中,用于判断非法用户进行后台。
Response.Redirect("BackGround/Default.aspx"); //用户名称或密码正确,进入后台首页
}
else
{
WebMessageBox.Show("用户名称或密码不正确!", "Logon.aspx");
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
txtUser.Text = "";
txtPwd.Text = "";
lblCheckCode.Text = random.Next(1000, 9000).ToString();
txtUser.Focus();
}
}
if (operation.Logon(txtUser.Text, txtPwd.Text).Tables[0].Rows.Count > 0) //判断用户是否合法。
怎么判断?operation是什么? 登录, 类 函数
[解决办法]
Operation operation = new Operation(); //声明业务类
鼠标放在 Operation F12看方法。
[解决办法]
Operation 声明业务类 找一下Operation.cs 类
public static class Operation
{
//这里看到了吗 你写的登录查询
public static DataSet Logon(string userName, string userPassword)
{
///这里就大胆胡写了
string sql = "SELECT * FROM user_table WHERE userName=@LgName AND userPassword=@Lgpsw"; //
try
{
System.Data.SqlClient.SqlParameter usersname =new SqlParameter("@LgName",userName);
System.Data.SqlClient.SqlParameter psw =new SqlParamete("@Lgpsw",userPassword)
DBHelper daal = new DBHelper();
return daal.ExecuteDataSet(sql, username,psw);
}
catch (Exception E)
{
}
}
[解决办法]
operation.Logon(txtUser.Text, txtPwd.Text)貌似是个DataSet,Operation类里面的Logon方法接受两个string参数,该方法返回一个DataSet,这个DataSet的数据内容应该是数据库中用户名密码与接收参数相同的数据。
operation.Logon(txtUser.Text, txtPwd.Text).Tables[0].Rows.Count>0意味着存在数据,也就是用户存在且合法。
[解决办法]
要看你operation里的方法
[解决办法]
就是根据用户名和密码去数据库查找看有没有记录 有说明是合法用户
[解决办法]
应该不是ms的类库吧。。。 大家没法看。。。