http://www.iloveyou10000.com

新blogs地址 http://itares.cnblogs.com

博客园 首页 新随笔 联系 订阅 管理

/**************************************
           用户注册
**************************************/
CREATE PROCEDURE RegAccount1 

@PlayerAccount char(20), ---用户名
@PlayerName char (20),   ---用户呢称
@PlayerPassword char (20),---用户密码
@PlayerQuestion1 int,---用户问题
@PlayerAnswer1 char(50),----用户答案
@PlayerSex  int,---用户性别
@PlayerBirthday char(30),---用户出生日期
@PlayerPostcard int,---
@PlayerPostcode char(20),
@PlayerEmail char (30),----用户Email
@PlayerUserPwd char(20),----用户密码
@getclientip char(20),----用户IP
@GiftCoupon int,    -------新手包
@RetuValue int output--返回值

as

declare
@MaxPlayerID bigint,
@CheckAccount char(20),
@CheckName char(20),
@TimeNow datetime,
@UIDIncreaseOffset int,
@MaxRegCount bigint

begin
    set @PlayerPassword = rtrim(@PlayerPassword);
    select @TimeNow = GETDATE();
    select @MaxPlayerID = IdValue + 1 from SumTable where IndexId = 501; --查找当前用户的最大的PlayerUID号
   
    if exists(select PlayerUID from PlayerID where UPPER(Account) = UPPER(@PlayerAccount)) --判断用户注册的用户名是否被注册过
    begin  
        set @RetuValue = -1
        return ; --the Account Exists
    end

    update SumTable set IdValue = @MaxPlayerID where IndexId = 501;
   
    begin Transaction
    insert into PlayerID (Account,                                          
                          PlayerUID
                         )
    values(@PlayerAccount,
           @MaxPlayerID);
    IF @@RowCount <> 1 GOTO Error
    insert into PlayerAccount (PlayerUID, --保存用户信息
                               [Name],
                               Sex,
                               Birthday,
                               --Province,
                               --Addr1,
                               Email,
                               IDNo,
                               IDCase,
                               --PhoneNo,
                               RegistTime,
                               UserPassword,
                               PlayerIP

                               )
    values (@MaxPlayerID,
            @PlayerName,
            @PlayerSex,
            convert(datetime,@PlayerBirthday),
            --@PlayerProvince,
            --@PlayerAddr1,
            @PlayerEmail,
            @PlayerPostcode,
            @PlayerPostcard,          --@PlayerIDNo,
            --@PlayerPhoneNo,
            @TimeNow,
            rtrim(@PlayerUserPwd),
            @getclientip
            );
      IF @@RowCount <> 1 GOTO Error
    insert into PlayerSecureQA(PlayerUID,
                               Question,
                               Answer)
    values (@MaxPlayerID,
            @PlayerQuestion1,
            @PlayerAnswer1);
  IF @@RowCount <> 1 GOTO Error

  Declare @date datetime

--set @date = getdate()

--select @date =DateAdd(Hour,16,) --加16个小时
select @date =dateAdd(minute,1000,getdate()) --加40分钟

    insert into PlayerCardPoint(PlayerUID,--初始化用户游戏信息
                                CardPoint,
                                [Password],
                                FirstLogin,
                                CardType
                               --bactq modify at 2005-07-21
                               ,CardAvailableTime
                               ,GiftCoupon
                                 )
    values (@MaxPlayerID,
            0,
            rtrim(@PlayerPassword),
            convert(datetime, '1905-03-16'),
            0,
           --bactq modify at 2005-07-21  
           @date
            ,@GiftCoupon
            );
 IF @@RowCount <> 1 GOTO Error
   Commit
    set @RetuValue = 1
    return;
 Error:
  BEGIN
      ROLLBACK TRANSACTION
      SET @RetuValue = -1
      RETURN
  END
end
GO

posted on 2006-05-31 09:25  fanrsh  阅读(398)  评论(0编辑  收藏  举报