今天在使用Reporting Services製作服務端報表,碰到了需要設置可選參數的問題
花了不少時間才弄好,做個備忘錄,下面是一些設置.
Code
select a.fSaleOrdeNo ,
a.fcustomerName,a.flinkphone,a.fdeliverdate,a.fdeliverAddress,a.fbuiltDate,
a.foperaterman,a.fcheckman,a.fupno,a.foriginSaleNo,a.fremark, c.itemno,c.ftype,c.fgoodsbarcode,
c.code,c.enname,c.supperitem,c.fremark as fremarkDetail,c.fSumcount,c.fprice,c.fsummoney,
c.cnname,c.status from Sal_SaleOrdeA a inner join(select fSaleOrdeNo, Case fType
when 1 then '換貨' when 2 then '換補件' when 3 then '跟進' when 4 then '補貨'
when 5 then '補補件' when 6 then '後補' when 7 then '收回' when 8 then '補安裝'
Else '' end as fType,ItemNo,Replace(fGoodsBarCode,'*','') as fGoodsBarCode, b.Code,b.Enname,
b.SupperItem,fRemark,'' as ColorSName,'' as SizeSName, fSumCount,Case Isnull(fSumCount,0) when 0
then 0 else Convert(Decimal(18,2),fSumMoney/fSumCount) end as fPrice,fSumMoney,Cnname,a.Status
from Sal_SaleOrdeB a
left join BSC_Goods b on (a.fGoodsBarCode=b.BarCode)) as c on a.fSaleOrdeNo=c.fSaleOrdeNo
Where Isnull(flag,0)=1
and (a.fSaleOrdeNo like '%'+isnull(@fsaleOrdeNo,'')+'%' )
and Isnull(fOriginSaleNo,'') like '%'+isnull(@fOriginSaleNo,'')+'%'
and (Isnull(fUpNo,'')= @fUpNo or isnull(@fUpNo,'')='')
and Isnull(fWriteNo,'') like '%'+isnull(@fWriteNo,'')+'%'
and (c.SupperItem Like '%'+isnull(@SupperItem,'')+'%' )
and (Isnull(fOrdeStatus,'')=@fOrdeStatus or isnull(@fOrdeStatus,'ALL')='ALL')
and Isnull(fCustomerName,'') like '%'+isnull(@fCustomerName,'')+'%'
and a.fOperateDate>=Convert(varchar(10),@StartDate,21) and a.fOperateDate<=Convert(varchar(10),@EndDate,21)
其中狀態參數需要多選,要使多選參數能夠允許空值,那么有效值(Available Value)中必須包含空值
如數據集Status的SQL語句如下
Code
Select b.ListA as disName,b.ListCode as SValue from BSC_OtherDefineA a
inner join BSC_OtherDefineB b
on a.ID=b.ItemNo where a.ItemCode='BillStatusDefine'
union
select '全部' as disName,
SValue=null
那么參數"狀態(fOrdeStatus)"字段可以做如下設置
報表運行效果如下: