首页 > 解决方案 > rdlc 报告行总计字段计算不正确

问题描述

再会

我有一份关于我的考勤解决方案的 rdlc 报告,但总计字段一直给我错误的值...

报告样本

=IIF(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes.ToString().Length=1,string.Format("{0}:0{1}",Convert.ToInt32(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes),string.Format("{0}:{1}",Convert.ToInt32(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes))

这是 Total 字段的表达式...

我究竟做错了什么?

提前致谢

标签: c#timerdlctime-and-attendance

解决方案


这是一个菜鸟的错误

我做了一个测试程序来说明解决方案

测试项目

从 8:37 开始的总小时数达到 8.61666666666667 将其转换为 int 为 9 但将其转换为 int 给了我想要的 8

3个按钮的代码

但是当将此应用于 rdlc 报告时,强制转换(int)不起作用......所以我使用了Math.Truncate

=IIF(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes.ToString().Length=1,string.Format("{0}:0{1}",Math.Truncate(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours).ToString("F0"),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes),string.Format("{0}:{1}",Math.Truncate(((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).TotalHours).ToString("F0"),((TimeSpan.Parse(Fields!HoursNT.Value)+TimeSpan.Parse(Fields!HoursOT1.Value)+TimeSpan.Parse(Fields!HoursOT2.Value)+TimeSpan.Parse(Fields!HoursOT3.Value)+TimeSpan.Parse(Fields!HoursOT4.Value))).Minutes))

希望这可以帮助某人!


推荐阅读