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
          ---函數(shù)主題
          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
          --年度分設(shè)置
          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

          ---設(shè)置級(jí)別
          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
          --設(shè)置結(jié)束
          end

          end

          GO


          select * from LevelTable

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

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 栾城县| 嘉鱼县| 祥云县| 南部县| 叙永县| 德江县| 邯郸市| 梁山县| 曲沃县| 宁海县| 定日县| 东阳市| 龙南县| 芦山县| 松潘县| 德钦县| 平利县| 静乐县| 鹿泉市| 吴忠市| 大姚县| 黄平县| 广水市| 阿尔山市| 崇义县| 舒兰市| 博湖县| 花莲县| 衡阳县| 丰镇市| 盐边县| 永嘉县| 通江县| 博客| 电白县| 历史| 阜南县| 益阳市| 海晏县| 东辽县| 昆山市|