//业务逻辑层的登录方法
public int Login(string userName, string password)
{
return DataAccess.UserAccount.Login(userName, password);
}
下面是数据层的登录方法:
//数据访问层的登录方法
public int Login(string userName, string password)
{
SqlParameter[] parameters = new SqlParameter[]{
//
};
return SqlHelper.ExecuteProcedure("Login",parameters);
}
下面是登录的存储过程:
CREATE PROC Login
@userName varchar(20),
@password varchar(20)
AS
IF NOT EXISTS(SELECT * FROM UserAccount WHERE UserName = @userName)
RETURN -1
IF NOT EXISTS(SELECT * FROM UserAccount WHERE UserName = @userName AND password = @password)
RETURN 1
UPDATE UserAccount
SET LoginTimes = LoginTimes + 1
WHERE UserName = @userName