100% found this document useful (1 vote)
4K views2 pages

C# Program To Maintain Attendance Record

this is a simple code in c# which is used in offices to keep record of employees login and logout... copy the code and run in Microsoft visual c# any edition to see its functionality... i've given the std login time as 11 o'clock...but u can change it to any time u want..... the program uses delegates and events which might help you in understanding DELEGATES and EVENTS better...

Uploaded by

Shashank
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
4K views2 pages

C# Program To Maintain Attendance Record

this is a simple code in c# which is used in offices to keep record of employees login and logout... copy the code and run in Microsoft visual c# any edition to see its functionality... i've given the std login time as 11 o'clock...but u can change it to any time u want..... the program uses delegates and events which might help you in understanding DELEGATES and EVENTS better...

Uploaded by

Shashank
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.IO;

namespace deleevenattenapp
{
public class delegateevent
{
public delegate void attendanceloghandler(string message);
public event attendanceloghandler eventlog;
public void logprocess()
{
string reason=null;
Console.WriteLine("enter ur name:");
string usrname=Console.ReadLine();
DateTime t = DateTime.Now;
int hr= t.Hour;
int mm= t.Minute;
if (!(hr >= 11 && hr < 12 || (hr == 12 && mm == 0)))
{

Console.WriteLine("enter the reason for not comin witin right


time:");
reason=Console.ReadLine();
}
oneventlog("loggin the info:"+usrname);
if(hr>=11&&hr<12||(hr==12&&mm==0))
if(mm<10)
oneventlog("loggedin at:"+hr.ToString()+":0"+mm.ToString()
+" within time");
else
oneventlog("logged in at: "+hr.ToString()
+":"+mm.ToString()+" within time");
else
if(mm<10)
oneventlog("logged in at:"+hr.ToString()
+":0"+mm.ToString()+" not witin time because:"+reason);
else
oneventlog("logged in at:"+hr.ToString()+":"+mm.ToString()
+" not witin time because:"+reason);
oneventlog(" ");
}
protected void oneventlog(string message)
{
if(eventlog != null)
{
eventlog(message);
}
}
}
public class attendancelogger
{
FileStream filestr;
StreamWriter streamwrtr;
public attendancelogger(string filename)
{
filestr = new FileStream(filename, FileMode.Append,
FileAccess.Write);
streamwrtr = new StreamWriter(filestr);
}
public void logger(string loginfo)
{
streamwrtr.WriteLine(loginfo);
}
public void close()
{
streamwrtr.Close();
filestr.Close();
}
}

class recordattendance
{
static void logger(string loginfo)
{
Console.WriteLine(loginfo);
}
static void Main(string[] args)
{
attendancelogger filelog = new
attendancelogger("c:\\process.log");
delegateevent devent= new delegateevent();
devent.eventlog += new delegateevent.attendanceloghandler(logger);
devent.eventlog += new
delegateevent.attendanceloghandler(filelog.logger);
devent.logprocess();
Console.ReadLine();
filelog.close();
}
}
}

You might also like