 - [code]CREATE PROCEDURE ACCOUNT_LOGIN
- @AccountID varchar(21),
- @Password varchar(13),
- @nRet smallint OUTPUT
- AS
- select @nRet = count(straccountid) from tb_user where straccountid = @AccountID
- if @nRet = 0
- begin
- RETURN
- end
- select @nRet = strAuthority from tb_user where straccountid = @AccountID
- if @nRet = 255
- begin
- set @nRet=4
- return
- end
- DECLARE @Nation tinyint, @CharNum smallint
- SET @Nation = 0
- SET @CharNum = 0
- DECLARE @pwd varchar(13)
- set @pwd=null
- SELECT @pwd = strPasswd FROM [dbo].[TB_USER] WHERE strAccountID = @AccountID and idays>0
- IF @pwd IS null
- BEGIN
- --SET @nRet = 0
- SET @nRet = 4
- RETURN
- END
- ELSE IF @pwd <> @Password
- BEGIN
- --SET @nRet = 0
- SET @nRet = 3
- RETURN
- END
- SELECT @Nation = bNation, @CharNum = bCharNum FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID
- IF @@ROWCOUNT = 0
- BEGIN
- SET @nRet = 1
- RETURN
- END
- IF @CharNum = 0
- BEGIN
- SET @nRet = 1
- RETURN
- END
- ELSE
- BEGIN
- SET @nRet = @Nation+1
- END
- DECLARE @premiumExpire datetime,@nDays int
- DELETE FROM PREMIUM_SERVICE WHERE strAccountID = @AccountID
- SELECT @premiumExpire=premiumExpire FROM TB_USER WHERE strAccountID = @AccountID
- IF @premiumExpire IS NOT NULL
- BEGIN
- SET @nDays = DateDiff(d, getDate(), @premiumExpire)
- IF @nDays>0
- INSERT INTO PREMIUM_SERVICE(strAccountID,strType,nDays) VALUES(@AccountID,4,@nDays)
- END
- GO
复制代码 [/code] |