ReportingServies报表开发实例教程

文章目录

ReportingServies报表开发实例教程

ReportingServies——SQLServer报表开发综合实例

效果图如下:

1、我们先完成sql语句的编写,以下是各表和关键字段:

--t:hx_t_waterusedamount--用水水量 hx_t_waterusedamountid

--f:hx_frecorder(抄表员),hx_fzone(区段),hx_fmeterid(水表),hx_fpayamount(结算水量),hx_fdepartmentid(收费部门)

 

--t:hx_t_receivable--应收水费

--f:hx_fcollchargesreceivable4(污水处理费),hx_freceivablefee(应收水费),hx_fusedamountid(水量信息)

--hx_fstate(水量状态计划:100000000),

 

--hx_frecordtype(抄表类型):正常,000,000  估水,000,001 未抄见,000,002

--hx_festimateamountreason(估水原因):不用水,000,000 无表,000,001 防冻,000,002 表停,000,003

--hx_fnotrecordreason(未抄见原因):未见表,000,000 有水,000,001 表埋,000,002 锁门,000,003 表不清,000,004

--hx_freading(本次抄表止度)

以下是SQL正文:

declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()

--count(w.hx_t_waterusedamountid) as '应抄表数',
declare @hx_ClosingAccountInfoId uniqueidentifier
set @hx_ClosingAccountInfoId='08AFEF9F-E174-46F2-855A-32F26BE38F3B'
declare @BusinessunitId uniqueidentifier
set @BusinessunitId='6FE6FE55-5945-E411-9402-6CAE8B22702D'

-----------------SQL正文----------------------------------------------------------执行时间:
declare @FMonth int
declare @FYear int
select @FYear=t.hx_FYear,@FMonth=t.hx_FMonth from hx_ClosingAccountInfo t where hx_ClosingAccountInfoId=@hx_ClosingAccountInfoId
--select @FYear,@FMonth

if @BusinessunitId is null
begin
select s.fullname fullname,
w.hx_fzone hx_fzone,
1 as AllCounts,
case when w.hx_frecordtype='100000000' then 1 else 0 end Normal,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000000' then 1 else 0 end NotUseWater,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000001' then 1 else 0 end NoMeterWater,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000002' then 1 else 0 end antifreeze,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000003' then 1 else 0 end MeterStop,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason not in('100000000','100000001','100000002','100000003') then 1 else 0 end OtherWater,

case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000000' then 1 else 0 end NotSeeMeterWater,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000001' then 1 else 0 end HaveWater,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000002' then 1 else 0 end MeterWaterBuried,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000003' then 1 else 0 end LockDoor,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000004' then 1 else 0 end MeterWaterFuzzy,

case when w.hx_freading is null then 1 else 0 end hx_freading,

w.hx_fpayamount hx_fpayamount,
r.hx_freceivablefee hx_freceivablefee,
r.hx_fcollchargesreceivable4 hx_fcollchargesreceivable4
from hx_t_waterusedamount w inner join hx_t_receivable r
on w.hx_t_waterusedamountid=r.hx_fusedamountid and w.hx_frecorder is not null 
and w.hx_fstate='100000006' and w.hx_FYear=@FYear and w.hx_FMonth=@FMonth --and
inner join systemuser s on w.hx_frecorder=s.systemuserid
end
else
begin

select s.fullname fullname,
w.hx_fzone hx_fzone,
1 as AllCounts,
case when w.hx_frecordtype='100000000' then 1 else 0 end Normal,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000000' then 1 else 0 end NotUseWater,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000001' then 1 else 0 end NoMeterWater,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000002' then 1 else 0 end antifreeze,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason='100000003' then 1 else 0 end MeterStop,
case when w.hx_frecordtype='100000001' and w.hx_festimateamountreason not in('100000000','100000001','100000002','100000003') then 1 else 0 end OtherWater,

case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000000' then 1 else 0 end NotSeeMeterWater,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000001' then 1 else 0 end HaveWater,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000002' then 1 else 0 end MeterWaterBuried,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000003' then 1 else 0 end LockDoor,
case when w.hx_frecordtype='100000002' and w.hx_fnotrecordreason='100000004' then 1 else 0 end MeterWaterFuzzy,

case when w.hx_freading is null then 1 else 0 end hx_freading,

w.hx_fpayamount hx_fpayamount,
r.hx_freceivablefee hx_freceivablefee,
r.hx_fcollchargesreceivable4 hx_fcollchargesreceivable4
from hx_t_waterusedamount w inner join hx_t_receivable r
on w.hx_t_waterusedamountid=r.hx_fusedamountid and w.hx_fdepartmentid=@BusinessunitId and w.hx_frecorder is not null 
and w.hx_fstate='100000006' and w.hx_FYear=@FYear and w.hx_FMonth=@FMonth --and
inner join systemuser s on w.hx_frecorder=s.systemuserid

end

---------------------------------------------------------------------------
--group by s.fullname, w.hx_fzone,w.hx_fpayamount,r.hx_freceivablefee,r.hx_fcollchargesreceivable4

select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'
--and w.hx_fdepartmentid=@BusinessunitId

2、使用报表开发工具


右键单击解决方案管理器中的报表,选择“新建报表”

由于我们要按照用户名fullname、区段(hxfzone)进行分组统计,我们可以这样设置


这样就可以实现如下效果:


我们可以看到查询条件

这个是从数据库中查询出来的,我们可以通过如下配置来实现


同样,关于查询条件 部门

接下来,要配置查询参数了


最后再配置查询的主数据集



  • 1
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

邹琼俊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值