i have two textbox..TimeInTextbox that contains time in for example(8:00 am) and TimeOutTextbox that contains time out for example(5:00 pm), i want to add TimeInTextbox and TimeOutTextbox to get the total working hours but how am i suppposed to do that?

Recommended Answers

All 6 Replies

Use datetime picker and set as you need to get only date or time. Show the selected time in text box. Is this what you were expecting?

i want to add the content of the two textbox

To get the total working hours you need to subtract the intime from the outtime.To get the difference,.net have datetime.subtract method and it takes argument as timespan and returns the result in int.

for more info visit :
Click Here

jhedonghae Are you using datetime pickker to select the date or time and filling the text boxes? If yes then CodeFive is in right way..

when the user clicks the log in button the date will be added to the datetextbox and timein will be added to the timeintextbox, and when log out is click timeout will be added to the timeouttextbox.. i had attach an image so that you can understand me more..
now what i want is to fill the totalhourswork by adding the timeintextbox and timeouttextbox and subtract 1 hour for the break time
and for the overtime by subtracting the timeintextbox and timeouttextbox and subtract 1 hour for the break time
hope you understand me..please help!

I will suggest you a simple approach.Its up to you to use it or not.
1.Create Property 5 properties.Save Lunch time in database.when form loads update LunchTime property.

  1. login
  2. logout
  3. LunchTime
  4. OverTime
  5. WrkHrs

2.When User Login Save login time in login porperty.
3.Same for logout
4.At logout call your method to calculate workinh hrs.

example:
datetime _dtlgout=logout;
int wrkHrs=_dtlgout.subtract(login);
if(wrkHrs>0)
WrkHrs=wrkHrs-LunchTime;
else
WrkHrs=wrkHrs

5.Updatae database with latest values.

Note
I will suggest you to use lunchtime time instead of duration.
Forexample : 1pm -2pm
This will help you to find out the half day and fullday of employee.Consider a scenario if user logins after 2 then you will able to save it as half day and with little bit more coding.

Hope this will help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.