hello sir i want to calculate total working hours of employee in c#.
like IN=10:00
OUT=12:00
IN:1:00
OUT:5:00
duration=2+5=7;
below code calculate only last in and out duration i want all in and out dueation time.
if (dt1.Rows.Count > 0)
{
for (int j = 0; j < dt1.Rows.Count; j++)
{
DateDay = Convert.ToDateTime(dt1.Rows[j]["emp_ToDate"]);
string st = dt1.Rows[j]["emp_InOut"].ToString();
string time1 = (dt1.Rows[j]["emp_Time"]).ToString();
if (st == ("IN"))
{
Input = Convert.ToString((time1));
}else
if (st == "OUT")
{
Output = Convert.ToString((time1));
}
try
{
duration2 = duration + (DateTime.Parse(Input).Subtract(DateTime.Parse(Output)).Duration());
}
catch { }
}

Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 12:19 AM EST
AmitRank #9,090 · 211 reputationPosted Feb 18, 2015, 12:30 AM EST
when employee in and out in company many times and calculate total duration he work in company from in and out time .
if IN=10 out=12 duration is 2
IN=1 out=5 duration 5
total duration is 5+2 in one variable .if number of time in and out in database i want to calculate the total duration. my code code ony give me a last in and out time.
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 1:19 AM EST
AmitRank #9,090 · 211 reputationPosted Feb 24, 2015, 12:59 AM EST
when my second loop get second IN that time add previous out time also i dont want this .i want only first in and out + second in and out + third In and Out.when i get second in then first out get clear.
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 24, 2015, 2:13 AM EST
if (dt1.Rows.Count > 0)
Input = Output = null;
AmitRank #9,090 · 211 reputationPosted Feb 24, 2015, 7:14 PM EST
Thanku sir...
AmitRank #9,090 · 211 reputationPosted Feb 24, 2015, 8:49 PM EST
hello
Piyush Pansuriya
i have multiple IN and OUT in my same row column .i want to fetch first In and compare with my maintime=10:00 .If IN is grater than my maintime save late mark in database . i have this code . i want first in from column. when i use this code he get last In from table and compare.
My IN time is in 10:30 PM format i have split this in following format.
string[] PT = Input.Split(Convert.ToChar(" "));
string T=PT[0];
string w = T.Split(Convert.ToChar(":"));
string IT =Convert.ToInt32( w[0]);
if(IT>10)
{
status=LATE;
}
PradeepRank #6,279 · 271 reputationPosted Feb 24, 2015, 10:20 PM EST
if (dt1.Rows.Count > 0)
AmitRank #9,090 · 211 reputationPosted Feb 26, 2015, 11:35 PM EST
i want to add message when employee click on OUT radio button and display message your input entry is not present first in then out .how to check in in database and display message..
i have following code.
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 27, 2015, 12:13 AM EST
if It is not exist than you have to give message.