Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL-Server-2008
I have a table in my database namely EmpAttendance.
 
This table has some columns likely empid,c_Date,intime,outtime,status.
 
How can is send these details as an attachment via email for every half an hour(i have created a windows application in c#).
 
also how can i calculate difference between outtime AND INTIME.
Posted 5-Mar-13 1:41am
Comments
choudhary.sumit at 5-Mar-13 6:52am
   
i can understand you like this:
1. You want a email program written in c#.
2. You also want a timer code.
3. You are failed to make me understood what is outtime and intime here.
elaborate.
Harsha24 at 5-Mar-13 7:01am
   
Here I am developing an windows application which stores the intime and outtime of an employee using Employee Id. status is used to know whether employeee is IN or OUT.
I have done all this stuff.
Now i need to send an email which carries the details where status is equal to IN. and this process should be done for evrey 30 min.
 
Also i need to calculate the differene between Outtime and intime that is total working hours.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Your best option for this is to use a windows scheduler or using a windows service.
Example links for Win Scheduler:
Link 1[^]
Link 2[^]
How to create a Win Service:
Creating a Basic Windows Service in C#[^]
http://tech.pro/tutorial/895/creating-a-simple-windows-service-in-csharp[^]
 
Sending email with attachments:
MSDN MailMessage.Attachment property[^]
Example code[^]
 
Good luck,
OI
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Set up a timer, probably one minute intervals is fine, then have a counter which gives you the half hour. In the timer Tick event handler deal with the counter, and when it expires read the data from the DB.
 
Format the data into HTML and send it as an HTML email: Sending an Email in C# with or without attachments: generic routine.[^] should help.
 
Time differences are also easy:
DateTime inTime = (DateTime) reader["intime"];
DateTime outTime = (DateTime) reader["outtime"];
TimeSpan diff = inTime - outTime;
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 544
2 Maciej Los 325
3 DamithSL 223
4 Mathew Soji 195
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 5 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100