
CREATE PROCEDURE [dbo].[Ϲ_ѯ_ҳ] 
@_check bit = null,
@ nvarchar(50) = null,
@ϱ_check bit = null,
@ϱ nvarchar(50) = null,
@ͼ_check bit = null,
@ͼ nvarchar(50) = null,
@_check bit = null,
@ int = null,
@ʱ_check bit = null,
@ʼʱ nvarchar(50) = null,
@ʱ nvarchar(50) = null,
@ int =null,
@ʽ int =null,
@Ͽ_check bit = null,
@Ͽ int = null,

@PageCurrent 	int=1,             --Ҫʾҳ
@PageSize   	int  = 20,         --ÿҳĴС(¼)
@PageCount  	int = '1111' OUTPUT,        --ҳ
@ItemCount	    int = '1111' OUTPUT	       --	
AS

declare @selectStrWhere nvarchar(4000)


set @selectStrWhere = 'Ƿ=0 '


--if(@_check = 1)
--	set @selectStrWhere = @selectStrWhere+' and   like + ''%'' + @ + ''%'' '
--if(@ʱ_check = 1)
--	set @selectStrWhere = @selectStrWhere+' and ޸ >=@ʼʱ and ޸ <=@ʱ '
--if(@ͼ_check = 1)
--	set @selectStrWhere = @selectStrWhere+' and   like + ''%'' + @ͼ + ''%''  '
--if(@_check = 1)
--	set @selectStrWhere = @selectStrWhere+' and   = @  '


if (@_check = 1)
     if(@ is not null)
		set @selectStrWhere = @selectStrWhere+' and  like '+N'''%'+@+N'%'''

if (@ϱ_check = 1)
     if(@ϱ is not null)
		set @selectStrWhere = @selectStrWhere+' and ϱ like '+N'''%'+@ϱ+N'%'''
 

if (@ʱ_check = 1)
    if(@ʼʱ is not null and @ʱ is not null)
          set  @selectStrWhere = @selectStrWhere+' and ' + N''''+@ʼʱ+N'''' + '<=޸' + ' and '+ N''''+@ʱ+N'''' + '>=޸'
 
if (@ͼ_check = 1)
    if(@ͼ is not null)
             set  @selectStrWhere = @selectStrWhere+' and  like '+N'''%'+@ͼ+N'%'''
 
if (@_check = 1)
    if(@ is not null)
           set  @selectStrWhere = @selectStrWhere+' and  = '+str(@)

---if (@Ͽ_check = 1)
   -- if(@Ͽ is not null)
        --   set  @selectStrWhere = @selectStrWhere+' and Ͽˮ = '+ str(@Ͽ)

 
declare @tbname		sysname --Ҫҳʾı
declare @fieldkey	sysname --ڶλ¼(Ωһ)ֶ,ֻǵֶ
declare @where		nvarchar(4000)	--ѯ
declare @fieldshow	nvarchar(1000) --ԶŷָҪʾֶб,ָ,ʾֶ
declare @fieldOrder	nvarchar(1000) ----Զŷֶָб,ֶָκָDESC/ASC  --ָ˳

set @tbname = 'ͼ'
set @fieldkey = 'ˮ'
set @where = @selectStrWhere
set @fieldshow =' [], [޸], [޸], [λ], [λˮ],[], [λ], [λˮ], [],[ļ],[ļ׺], [],[Ͽˮ],
[Ƿ], [Ƿ], [], [ˮ], 
[ˮ], [ϱ], [], [], [˵],[],[ϱ],[Expr1]'
if @ = 1
begin
  if @ʽ = 1 
		begin
			set @fieldOrder =' DESC'
		end
	else
		begin
			set @fieldOrder = ' ASC'
		end
end
else if @ = 2
begin
  if @ʽ = 1
		begin
			set @fieldOrder = ' DESC'
		end
	else
		begin
			set @fieldOrder = ' ASC'
		end
end
else
begin
     set @fieldOrder = ' DESC'
end

exec sp_xt_pagesplit @tbname,@fieldkey,@where,@fieldshow,@fieldOrder,'',@PageCurrent,@PageSize,@PageCount out,@ItemCount out

