如何获取datagridview中所有datetime数据的时间 [英] How to get the time-span of all the datetime data in my datagridview

查看:484
本文介绍了如何获取datagridview中所有datetime数据的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景如上所述,我有一个数据库,我显示在我的datagridview。我已经添加了每行( timeIn和timeOut )的时间间隔,并将其存储在文本框中。现在,我想添加并显示所有的总时间段(我已经拥有每行的timepan和timeOut 的时间间隔)只有那个文本框。

The scenario go's like that, above and this; I have a database, which I displayed on my datagridview. I already added the timespan of each row (timeIn and timeOut) and stored it on a textbox. Now, I wanted to add and display all the total timespans (which I already have the timespan of each rows timeIn and timeOut) of every row using only that textbox.

我猜我的例子是错误的,应该假设所有的emp_Code只有'1'作为它所有三行的值。问题的总结:如何获得第3行的row2 + timespan的row1 + timespan的时间间隔,并将其显示在文本框上。 我正在考虑使用循环,但是我不知道怎么做。这就是为什么要在这里发布的。

I guess my example is wrong, that should suppose to be all the emp_Code's has only '1' as its values in all three rows. Summary of the question: How can I get the timespan of row1 + timespan of row2 + timespan of row 3 and display it on a textbox. 'am thinking of using a loop, however I don't have any idea on how to do it. That's why am posting it here.

是我的前端,我还没有后台。当我按Compute时,它将显示datagridview中所有数据的总时数(timeIn和timeOut的时间间隔),并将总时数显示为日班和夜班

This is my front end, I don't have backend for this yet. When I press Compute, it'll display the total hours of all data in the datagridview(timespan of timeIn and timeOut) and breakdown the totalhours to Day shift and Night shift

推荐答案

你有时间和时间,所以创建一个TimeSpan并运行循环:

You have your time in and time out, so create a TimeSpan and run a loop:

TimeSpan timeSpan = new TimeSpan(0);
// for each data grid row calculate and add the timespan:
    timeSpan =+ time_Out.Subtract(time_In);
//

这篇关于如何获取datagridview中所有datetime数据的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆