简体   繁体   English

rdlc报告行总计字段未正确计算

[英]rdlc report row totals field not calculating correctly

Good Day 美好的一天

I have a rdlc report on my time and attendance solution, but the totals field keeps giving me the wrong value... 我有一份关于我的时间和出勤解决方案的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))

This is the expression for the Total field... 这是总计字段的表达式...

What am I doing wrong? 我究竟做错了什么?

Thanks in advance 提前致谢

It was a noob mistake 😅 这是一个菜鸟的错误😅

I made a test program to illustrate The solution 我做了一个测试程序来说明解决方案

测试项目

the total hours from 8:37 came to 8.61666666666667 converting it to an int came to 9 but casting it to an int gave me the desired 8 从8:37的总小时数变为8.61666666666667,将其转换为int时得出9,但将其强制转换为int给了我所需的8

3个按钮的代码

But when applying this to rdlc report, casting (int) wouldn't work... So I used Math.Truncate 但是,当将其应用于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))

Hope This Could Help Someone! 希望这可以帮助到别人!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM