exec setScores 'test','test'


          alter proc setScores (@userName varchar(120),@password varchar(120))
          as
          begin
          declare @count int
          declare @lastDate datetime
          declare @gid varchar(60)
          declare @sum int
          declare @level varchar(60)
          ---年度變量
          declare @regDate datetime
          declare @yearCount int
          ---函數主題
          select @gid=Gid from CusUsers where [User_Name]=@userName
          select @count=count(1) from CusUsers where [User_Name]=@userName and User_Pass=@password
          if(@count>0)
          begin
          select @lastDate=gdate from UserScrores where uid=@gid and stype=1 order by gdate desc
          set @lastDate=isnull(@lastDate,getdate()-1)
          if(datediff(day,@lastDate,getdate())>=1)
          begin
          --添加登陸日志
          insert into UserScrores(stype,uid,Scores) select '1',@gid,10

          end
          --年度分設置
          select @regDate=Gdate from CusUsers where  Gid=@gid
          set @yearCount=datediff(year,@regDate,getdate())
          if(@yearCount>=0)
          begin
          print '10'
          update UserScrores set Scores=50 where uid=@gid and stype=10
          if(@@rowcount<=0)
          insert into UserScrores(stype,uid,Scores) select '10',@gid,50
          end
          else if (@yearCount>=1 and @yearCount<=2)
          begin
          update UserScrores set Scores=50 where uid=@gid and stype=11
          if(@@rowcount<=0)
          insert into UserScrores(stype,uid,Scores) select '11',@gid,50
          end
          else if(@yearCount>=3)
          begin
          update UserScrores set Scores=50 where uid=@gid and stype=12
          if(@@rowcount<=0)
          insert into UserScrores(stype,uid,Scores) select '12',@gid,50
          end

          ---設置級別
          select @sum=sum(isnull(Scores,0)) from UserScrores where uid=@gid
          select @level=levelMark from LevelTable where @sum between SStart and SEnd
          update CusUsers set ULevel=@level where Gid=@gid
          --設置結束
          end

          end

          GO


          select * from LevelTable

          posted on 2010-11-06 18:37 sanmao 閱讀(166) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 高平市| 且末县| 天水市| 罗田县| 青田县| 德保县| 榆中县| 饶阳县| 黑龙江省| 张家口市| 肥城市| 屏山县| 汉阴县| 北宁市| 教育| 辽阳县| 东阿县| 青冈县| 辛集市| 大化| 开远市| 成武县| 堆龙德庆县| 进贤县| 建德市| 桑日县| 西乌珠穆沁旗| 项城市| 大同市| 宜阳县| 金平| 开原市| 广元市| 合作市| 陵川县| 新安县| 德庆县| 大悟县| 新郑市| 民县| 石城县|