Hi,
This is the datagrid I have:-
when I press a button the the datagrid fill with the data as following
|
EmpName |
Status |
Firsttime |
Lasttime |
Minuts late |
Hours between last and first time |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The status is a checked box if selected disable the datagridview row if not calculate the hours between lasttime and firsttime for every datagrid row
Please help me in solving the problem using winform and c#
thanks
Hemant SrivastavaPosted Oct 28, 2012, 11:44 PM
class Emp_Records
{
public string Employee_Name {get; set;}
public bool Status {get; set;}
public DateTime FirstTime{get; set;}
public DateTime LastTime {get; set;}{get; set;}public int MinuteLate
{get; set;}public int HourBtwTime
}
Then create a list of Emp_Records as
List<
Emp_Records> listEmp = new List<Emp_Records>();
and filled some data in the list. MinuteLate and HoursBtwTime variables, you can easily calculate using TimeSpan class by differencing the FirstTime and LastTime. In TimeSpan class, you can get the Hours, Minutes, Seconds etc. parts individually...
Then bind your DataGridView control data source to this list of Emp_Records
datagridview1.DataSource = listEmp;
Attach events with datagridview too... like select
In that event handler, perform calculation to get the minutes and hours OR disable the entire row( depending upon your if-else condition)
Hope this could help you!