CREATE PROCEDURE Prc_Ad_Login
@AdName varchar(32),
@AdPwd nchar(32),
@Count int output,
@Err varchar(64) output
AS
if exists(select intsuid from sysuser where varsuname=@AdName)
begin
declare @suid int
declare @dteErrs datetime
declare @npwd nchar(32)
declare @Lock bit
declare @intErr int
declare @Errpart int
declare @ErrCount int
select @suid=intsuid, @dteErrs=dteErr,@intErr=intErrCount,@npwd=narsupwd,@lock=bitLock from sysuser where varsuname=@Adname
select @ErrCount=intsuerrcount,@Errpart=intsuerrminute from sysbasic
if(@npwd=@Adpwd)
begin
if(@Lock=1)
begin
select @Count=2
select @Err='你的帳戶已被鎖定,請聯系站長!'
end
else
begin
select @Count=0
end
end
else
begin
if(@Lock=0)
begin
if(datediff(n,@dteErrs,getdate())<@Errpart)
begin
if(@intErr<@ErrCount)
begin
update sysuser set intErrCount=intErrCount+1,dteErr=getdate() where intsuid=@suid
if(@intErr=(@ErrCount-1))
begin
select @Count=4
select @Err='登錄錯誤過多,你的帳號被系統暫時鎖定!'
end
else
begin
select @Count=1
select @Err='用戶名或密碼錯誤!'
end
end
else
begin
update sysuser set dteErr=getdate() where intsuid=@suid
select @Count=3
select @Err='你的帳號在一定時間內不允許登錄!'
end
end
else
begin
update sysuser set dteErr=getdate(),intErrCount=1 where intsuid=@suid
select @Count=1
select @Err='用戶名或密碼錯誤!'
end
end
end
end
else
begin
select @Count=1
select @Err='用戶名或密碼錯誤!'
end
GO