[B]CREATE PROCEDURE ACCOUNT_LOGIN[/B]
[B]@AccountID varchar(21),[/B]
[B]@Password varchar(13),[/B]
[B]@nRet smallint OUTPUT[/B]
[B]AS[/B]
[B]delete from currentuser where straccountid = @AccountID[/B]
[B]---Coded By Sametcan---[/B]
[B]declare @cnt BigInt[/B]
[B]declare @nDays smallint[/B]
[B]select @nRet = count(straccountid) from tb_user where straccountid = @AccountID[/B]
[B]if @nRet = 0[/B]
[B]begin[/B]
[B]insert into tb_user (straccountid, strpasswd, strSocNo, idays) values (@AccountID, @password, 1, '6')[/B]
[B]end[/B]
[B]select @cnt = count(straccountid) from currentuser[/B]
[B]select @nDays = count(nDays) from PREMIUM_SERVICE where straccountid = @AccountID[/B]
[B]if @cnt > 40 and @nDays = '0'[/B]
[B]begin[/B]
[B]set @nRet = 0[/B]
[B]end[/B]
[B]if @cnt > 40 and @nDays = null[/B]
[B]begin[/B]
[B]set @nRet = 0[/B]
[B]end[/B]
[B]DECLARE @Nation tinyint[/B]
[B]SET @Nation = 0[/B]
[B]-- tid login method by samma 2004.02.24[/B]
[B]DECLARE @pwd varchar(13)[/B]
[B]SET @pwd = null[/B]
[B]SELECT @pwd = strPasswd FROM TB_USER WHERE strAccountID = @AccountID[/B]
[B]IF @pwd IS null[/B]
[B]BEGIN[/B]
[B]SET @nRet = 0[/B]
[B]RETURN[/B]
[B]END[/B]
[B]ELSE IF @pwd <> @Password[/B]
[B]BEGIN[/B]
[B]SET @nRet = 0[/B]
[B]RETURN[/B]
[B]END[/B]
[B]SELECT @Nation = bNation FROM ACCOUNT_CHAR WHERE strAccountID = @AccountID[/B]
[B]IF @@ROWCOUNT = 0[/B]
[B]BEGIN[/B]
[B]SET @nRet = 1[/B]
[B]RETURN[/B]
[B]END[/B]
[B]BEGIN[/B]
[B]SET @nRet = 1[/B]
[B]RETURN[/B]
[B]END[/B]
[B]BEGIN[/B]
[B]SET @nRet = @Nation+1[/B]
[B]RETURN[/B]
[B]END[/B]
[B]GO
[/B]