我使用的是crystal report 10. Crystal report 直接调用SQL 2005中的数据,没有任何其他程序。有两个关联表department和worker. 一个department对应多个worker.
worker表中有active和class两个字段。如果active=false说明这个员工已经离职,class是一个string类型字段。主报表显示一个department的信息。在主报表中要显示一个字符串“This department is a RHP department”。显示这个字符串的条件是:
在这个部门中,只要有在职员工的class值是RHP,就要显示这个字符串到主报表。
Display if any of the active workers in the department have a class = 'RHP'
(active = true and class = 'RHP'.)我只能做到显示多个worker的信息到detai section。但不知道如何循环读取每个worker的信息到array,然后再判断条件是否成立。或有别的方法去读取每个worker的信息。请大家帮忙!谢谢!
worker表中有active和class两个字段。如果active=false说明这个员工已经离职,class是一个string类型字段。主报表显示一个department的信息。在主报表中要显示一个字符串“This department is a RHP department”。显示这个字符串的条件是:
在这个部门中,只要有在职员工的class值是RHP,就要显示这个字符串到主报表。
Display if any of the active workers in the department have a class = 'RHP'
(active = true and class = 'RHP'.)我只能做到显示多个worker的信息到detai section。但不知道如何循环读取每个worker的信息到array,然后再判断条件是否成立。或有别的方法去读取每个worker的信息。请大家帮忙!谢谢!
->右键,format object
->选中suppress,再点它右边的公式按钮
->输入if active字段 = true and class字段 = 'RHP' then false else true
自己替换相关字段的正确写法
worker2 active = true, class = 'RHP'
worker3 active = false, class = ''
worker4 active = true, class = 'TPG'我的操作步骤如下:
->将字符串“This department is a RHP department” 放在报告的header中。(要求这个字符串要在header中显示)
->选中suppress,再点它右边的公式按钮
->输入if active字段 = true and class字段 = 'RHP' then false else true worker2符合条件,所以这个字符串应该被打印出来。但是运行测试时,发现永远都只判断worker1的值,不能循环依次读取并判断这个部分所有的worker是否有符合标准的。所以即使worker2符合条件,这个字符串也显示不出来。请大家帮忙想想办法!谢谢!
department:
departmentId,departmentNameworker:
WorkerId,Workername,active,class,departmentId报表加入这两个表后,这两个表的关系应该是department.departmentId=Worker.departmentId现在看数据class有多个值的首先你不能把This department is a RHP department放在header上 。这个逻辑上是不对的
到底你需要显示一个什么效果呢?比如说数据是
worker1 active = true, class = 'TPG'
worker2 active = true, class = 'RHP'
worker3 active = false, class = ''
worker4 active = true, class = 'TPG' 那么是不是应该是
worker1
worker2 This department is a RHP department
worker3
worker4
1. 报表只显示department的信息,不显示worker的信息。
2. 在这个部门中,只要有在职员工的class值是RHP,就要显示"This department is a RHP department" 到报表。
Display "This department is a RHP department" if any of the active workers in the department have a class = 'RHP'。不知道是否有方法能将class值和active的值都存到array中。或者是否能在Crystal Report中使用SQL Query,比如:
select count(workerId)
from department, worker
where department.departmentId=Worker.departmentId
and departmentName = 'Finance'
and worker.active = true
and worker.class = 'RHP'如果SQL Query的返回值>=1则显示字符串。
worker1 active = true, class = 'TPG'
worker2 active = true, class = 'RHP'
worker3 active = false, class = ''
worker4 active = true, class = 'RHP' "This department is a RHP department" 将被打印两次。但按要求这个字符串只能打印一次,所以才不将它放到detail section中。但是放到header中又实现不了功能。真的是难题啊。
请大家再帮忙想想办法,看水晶报表是否能实现这样的功能。谢谢!