34,590
社区成员
发帖
与我相关
我的任务
分享
declare @qz int,@wz int,@rq datetime,@bch char(4)
/*@qz 启始座位
@wz 结束座位
@rq 日期
@bch 班次号
*/
if @rq>=convert(char(10),getdate() ,102)
begin
declare @bj int
select @bj=patindex('%1%',substring(zw,@qz,@wz)) from zw where bch=@bch and bcrq=@rq
if @bj!=0
begin
select '存在售票,不予更改' as '提示' ,bch,zw from zw where bch=@bch and bcrq=@rq
return
end
else
begin
select '改之前' as '状态',bch,zw,bcrq,clbh from zw where bch=@bch and bcrq=@rq
select * from spqk where bch=@bch and bcrq=@rq
declare @ws int,@tj char(20)
declare @zs char(10),@sy char(10)
select @ws=len(zw) from zw where bch=@bch and bcrq=@rq
if @qz>@ws
begin
select @tj=@wz-@ws
update zw set zw=zw+replicate('3',@tj) where bch=@bch and bcrq=@rq
while @qz<=@wz
begin
update zw set zw=stuff(zw,@qz,1,'0') where bcrq=@rq and bch=@bch
select @qz=@qz+1
end
end
else
while @qz<=@wz
begin
update zw set zw=stuff(zw,@qz,1,'0') where bcrq=@rq and bch=@bch
select @qz=@qz+1
end
end
select @zs= (len(zw)-len(replace(zw,'0',''))+len(zw)-len(replace(zw,'1',''))) ,@sy=len(zw)-len(replace(zw,'0','')) from zw where bcrq=@rq and bch=@bch
update spqk set syps=@sy ,zsps=@zs where bch=@bch and bcrq=@rq
end
else
begin
print'日期不对,Today is '+convert(char(10),getdate(),102)
return
end
select '改之后' as '状态',bch,zw,bcrq,clbh from zw where bch=@bch and bcrq=@rq
----select '统计' as '统计', (len(zw)-len(replace(zw,'0',''))+len(zw)-len(replace(zw,'1',''))) as '准售',len(zw)-len(replace(zw,'0','')) as '剩余票',len(zw)-len(replace(zw,'1','')) as '已售' from zw where bch=@bch and bcrq=@rq
select * from spqk where bch=@bch and bcrq=@rq