Hi all
I'm doing a web application in VS2008 with Sql server database, and I do not seem to find a solution to my problem.
I have two textboxes where I enter from date and to date, and when I push the button it will populate a couple of labels with information like how many hits and total time. The employee enter his working hours in this system and it will be saved to the database. (For the employee it looks like this: Begin at work: 2010-04-08 07:00:00 and end of work: 2010-04-08 17:00:00 then he saves it).
When I search between let's say 1 march to 31 march then I will see the total hours for 1 person and how many days he has worked in that range.
Is there a way to handle overtime, if this person works between 6 pm and 6 am I need to populate a third label with this hours. Cause this will give him more money per hour.
And if he works on weekends I need to populate a fourth label with this information.
I use a datareader to get the total hours and how many days, is there a way to write code that will get this information as well? I would rather let the program do this then having the employees doing it. The less manual work the less errors I believe.

3 answers
Hi again
I got no responses from anyone, is my question unclear or is it too hard to manage?
Please comment so I know...
answered one year ago by:
60
If you had two more textboxes where the user enters 'overtime from date' and 'overtime to date', then you could populate the third label with the total overtime.
It would be possible to deduce how much of his/her 'normal' time or overtime is worked at weekends from the dates entered in the textboxes so you don't really need to get any additional input from the user to cover this point.
It's possible to work out programatically how much time has been worked using the DateTime and TimeSpan classes. Here's some 'rough and ready' code - in practice, you'd need to add code to check for invalid or unlikely dates:
I haven't done anything about weekends at this stage in case I haven't understood the question correctly :)
answered one year ago by:
17279
60
Thank You Vulpes. It can be hard to explain sometimes, basically I just want a person to enter his time when beginning at work and when ending the work. If this person end work later than 6 pm or begin before 6 am this is overtime and I want that separatly. If this person works at a weekend it is also overtime but with different pay. That is why I need to separate the two overtimes, and my thought was that this person should only enter his time when beginning at work and ending work to minimize errors. If this person must enter time, overtime and weekend overtime the possibility of human errors increase...let the program handle it instead...
OK, I think I'm clear now what you're trying to do :)
The code to do this is rather involved, and I haven't had time to test it thoroughly, but try the following:
I've assumed that nobody will work continuously for more than 24 hours and so the 'shift' will either end on the same day or the next day:
answered one year ago by:
17279
60
Thank you very much, I will try this right away. Yes correct, nobody will work as much as 24 hours at one time. But they do work at various times.