如何获得时间跨度所有的datetime数据在我的DataGridView [英] How to get the time-span of all the datetime data in my datagridview

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

问题描述

SAMPLE数据库设计

场景去的样子,上面这;我有一个数据库,这是我显示我的DataGridView。我已经添加每一行的时间内( timeIn和超时的),并将其存储在一个文本框。仅使用文本框的每一行的现在,我想补充和显示所有的总时间跨度(,我已经有了每个行的时间跨度timeIn和超时的)。

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作为其在所有三个行值。问题总结:我怎样才能得到ROW1 + ROW2 +排3的时间跨度的时间跨度的时间跨度和一个文本框显示。 '正在考虑使用一个循环的,但是我没有对如何做到这一点的想法。这就是为什么我在这里张贴。

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.

输入图像的描述在这里

这是我的前端,我没有后台为这个呢。当我preSS计算,它会显示总时间的所有数据,在DataGridView(timeIn和超时的时间跨度),并击穿totalhours到白班和夜班

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

推荐答案

你有你在和超时时间,所以创建一个时间跨度和运行一个循环:

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);
//

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

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