Click here to Skip to main content
15,914,419 members
Home / Discussions / C#
   

C#

 
GeneralRe: reading text file and calculating the working hours for each employee Pin
OriginalGriff27-May-09 1:55
mveOriginalGriff27-May-09 1:55 
GeneralRe: reading text file and calculating the working hours for each employee Pin
OriginalGriff27-May-09 4:29
mveOriginalGriff27-May-09 4:29 
GeneralRe: reading text file and calculating the working hours for each employee Pin
emmy_23200327-May-09 20:58
emmy_23200327-May-09 20:58 
GeneralRe: reading text file and calculating the working hours for each employee Pin
OriginalGriff27-May-09 22:08
mveOriginalGriff27-May-09 22:08 
GeneralRe: reading text file and calculating the working hours for each employee Pin
emmy_23200328-May-09 1:11
emmy_23200328-May-09 1:11 
GeneralRe: reading text file and calculating the working hours for each employee Pin
OriginalGriff28-May-09 1:24
mveOriginalGriff28-May-09 1:24 
GeneralRe: reading text file and calculating the working hours for each employee Pin
emmy_23200328-May-09 1:28
emmy_23200328-May-09 1:28 
GeneralRe: reading text file and calculating the working hours for each employee Pin
OriginalGriff28-May-09 1:59
mveOriginalGriff28-May-09 1:59 
I can't - there are so many of them, and for a complete beginner I really don't know - I came to C# from C++, and all the way back to assembler, so I started with knowledge you don't have and the books I used presummed that knowledge. Anything called step-by-step is probably a good starting point!

Don't think of it in C# terms: try to think "How would I do this if it was on a piece of paper?"

I would:

Call this "The List":
Enroll No,194,date2,30/4/2009,time2,0:3:38,Check Out
Enroll No,78,date2,30/4/2009,time2,0:3:43,Check Out
Enroll No,78,date1,30/4/2009,time1,9:44:47,Check In
Enroll No,107,date1,30/4/2009,time1,9:44:52,Check In
Enroll No,108,date1,30/4/2009,time1,9:57:39,Check In
Enroll No,106,date1,30/4/2009,time1,10:40:47,Check In
Enroll No,109,date1,30/4/2009,time1,15:23:30,Check In
Enroll No,107,date2,30/4/2009,time2,17:6:27,Check Out
Enroll No,194,date1,30/4/2009,time1,17:9:44,Check In
Enroll No,132,date1,30/4/2009,time1,17:32:19,Check In
Enroll No,106,date2,30/4/2009,time2,17:35:31,Check Out
Enroll No,78,date2,30/4/2009,time2,17:35:41,Check Out
Enroll No,132,date1,30/4/2009,time1,17:45:2,Check In
Enroll No,108,date2,30/4/2009,time2,18:33:18,Check Out
Enroll No,109,date2,30/4/2009,time2,22:30:18,Check Out
Enroll No,194,date2,1/5/2009,time2,0:4:18,Check Out
Enroll No,132,date2,1/5/2009,time2,0:4:29,Check Out

Get a blank sheet of paper, and a pen.

Look at the first line of the list, make a note of the Enroll number (194).
Beside this, I would write the date and time (30/4/2009 @ 0:3:38) and that this was a check out.

Look at the next line, and do the same. If the Enroll number is already on my piece of paper, then I would add the information to that, otherwise note it down separately.

Continue through the list doing all the lines.

I would then have:

Enroll No194 30/4/2009 @  0: 3:38,Check Out
Enroll No194 30/4/2009 @ 17: 9:44,Check In
Enroll No194  1/5/2009 @  0: 4:18,Check Out

Enroll No132 30/4/2009 @ 17:32:19,Check In
Enroll No132 30/4/2009 @ 17:45: 2,Check In
Enroll No132  1/5/2009 @  0: 4:29,Check Out

Enroll No109 30/4/2009 @ 15:23:30,Check In
Enroll No109 30/4/2009 @ 22:30:18,Check Out

Enroll No108 30/4/2009 @  9:57:39,Check In
Enroll No108 30/4/2009 @ 18:33:18,Check Out

Enroll No107 30/4/2009 @  9:44:52,Check In
Enroll No107 30/4/2009 @ 17: 6:27,Check Out

Enroll No106 30/4/2009 @ 10:40:47,Check In
Enroll No106 30/4/2009 @ 17:35:31,Check Out

Enroll No 78 30/4/2009 @  0: 3:43,Check Out
Enroll No 78 30/4/2009 @  9:44:47,Check In
Enroll No 78 30/4/2009 @ 17:35:41,Check Out

Now it is easy to see that:
No194 Checked in on 30/4/2009 @ 17: 9:44 and out on 1/5/2009 @  0: 4:18
so he/she was checked in for some 7 hours. 

No132 Checked in on 30/4/2009 @ 17:45: 2 and out on 1/5/2009 @  0: 4:29
so they were in for 6 1/4 hours or so.


All you have to do is translate that into the C# instructions you do know! I can't tell you what those instructions are because I don't know what instructions you do know - please, do not give me a list. Just have a try, it doesn't have to be good (or even work properly to start with) - you obviously know more than you think, since you are correctly using DateTime and TimeSpan structures already!

Post up what you come up with, and I'm sure we can get it working together. Smile | :)

No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.

This message is made of fully recyclable Zeros and Ones

GeneralRe: reading text file and calculating the working hours for each employee Pin
emmy_23200329-May-09 23:02
emmy_23200329-May-09 23:02 
GeneralRe: reading text file and calculating the working hours for each employee Pin
Henry Minute27-May-09 0:39
Henry Minute27-May-09 0:39 
GeneralRe: reading text file and calculating the working hours for each employee Pin
OriginalGriff27-May-09 0:45
mveOriginalGriff27-May-09 0:45 
QuestionViewer Pin
ellllllllie26-May-09 22:07
ellllllllie26-May-09 22:07 
QuestionA Combobox problem Pin
leung wilson26-May-09 21:51
leung wilson26-May-09 21:51 
AnswerRe: A Combobox problem Pin
Vimalsoft(Pty) Ltd26-May-09 22:54
professionalVimalsoft(Pty) Ltd26-May-09 22:54 
AnswerRe: A Combobox problem Pin
jaypatel51227-May-09 0:23
jaypatel51227-May-09 0:23 
QuestionOffice Ribbon functionality Pin
windhopper26-May-09 21:22
windhopper26-May-09 21:22 
QuestionRe: Office Ribbon functionality Pin
mandar77719-Jul-09 20:34
mandar77719-Jul-09 20:34 
QuestionA small problem with Extended GridView in Edit Mode Pin
M S Nayak26-May-09 20:50
M S Nayak26-May-09 20:50 
QuestionHow do I Generate a Number in C# Pin
Mads11526-May-09 20:20
Mads11526-May-09 20:20 
AnswerRe: How do I Generate a Number in C# Pin
stancrm26-May-09 20:39
stancrm26-May-09 20:39 
GeneralRe: How do I Generate a Number in C# Pin
Mads11526-May-09 20:45
Mads11526-May-09 20:45 
GeneralRe: How do I Generate a Number in C# Pin
stancrm26-May-09 20:47
stancrm26-May-09 20:47 
GeneralRe: How do I Generate a Number in C# Pin
Mads11526-May-09 21:09
Mads11526-May-09 21:09 
GeneralRe: How do I Generate a Number in C# Pin
stancrm26-May-09 21:18
stancrm26-May-09 21:18 
GeneralRe: How do I Generate a Number in C# Pin
stancrm26-May-09 22:22
stancrm26-May-09 22:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.