c# - 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 字段的表达式...
我究竟做错了什么?
提前致谢
解决方案
这是一个菜鸟的错误
我做了一个测试程序来说明解决方案
从 8:37 开始的总小时数达到 8.61666666666667 将其转换为 int 为 9 但将其转换为 int 给了我想要的 8
但是当将此应用于 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))
希望这可以帮助某人!
推荐阅读
- plugins - 在 TYPO3 v10.4 中获取当前 pageid
- java - 访问多维字符串数组时在Java中获取ArrayIndexOutOfBoundsException
- unity3d - 自上而下或等距视图中的 Unity Frostrum Culling
- c - 程序在执行通过管道和 fork 给出的 shell 命令期间挂起
- machine-learning - 'TFOptimizer' 对象没有属性 'learning_rate'
- r - 在deseq中如何克服收缩?
- reactjs - 如何处理预检请求?
- php - 通过 AppServiceProvider.php 添加到视图时层次结构类别菜单中断
- javascript - Props 改变后执行一个函数
- sql - 无法运行spring boot程序