Click here to Skip to main content
Click here to Skip to main content

Tagged as

A Simple Punch Clock Applet

, 15 Dec 2012 CPOL
Rate this:
Please Sign up or sign in to vote.

Introduction

A couple years ago I wrote a piece of code that counted down to a particular event - you can read the article here.  After my current gig full time ended in September, I ended up getting involved in several different projects, all at the same time, and realized I really need a simple to use punch-clock application that would simply count how much time I'm spending on each project.  It seemed reasonable to use the same code base for the "Countdown Reminders" and modify it slightly to work as a punch clock instead.

Yes, this is a ridiculously short article, but you perhaps you'll find the application useful or give me some ideas on what you'd like to see added.  I have a few ideas that I discuss at the end.

Under the Hood

This section discusses the changes made to the Countdown Reminder code.

The User Interface

You can read the Countdown Reminders article for how the UI works - I made some minor modifications, eliminating the option to select fields, which resulted in a more brute force way of initializing the counter groups:

protected void CreateCounterGroups()
{
  int pos = 0;
  dayGroup = new Group("Days");
  hourGroup = new Group("Hours");
  minuteGroup = new Group("Minutes");
  secondGroup = new Group("Seconds");

  foreach (Group group in new List<Group>() { dayGroup, hourGroup, minuteGroup, secondGroup })
  {
    group.Location = new Point(pos, 0);
    pos += group.Width;
    Controls.Add(group);
  }

  Width = 6 * Group.GroupWidth;
}

However, everything else is the same with regards to the presentation of the timers.

I did change the popup menu to include a "start" and "stop" option:

I also modified the data structure which is reflected in the Setup UI:

The Data Structure

The underlying data structure just has a description and time:

private static void CreateTable()
{
  counterTable = new DataTable("Counters");
  counterTable.Columns.Add("Index", typeof(Int32));
  counterTable.Columns.Add("Description", typeof(string));
  counterTable.Columns.Add("Time", typeof(long));

  counterView = new DataView(Program.counterTable);
  counterView.Sort = "Index";
}

Ideally, a DataSet should be used to support a second child table to record the start & stop date-time activity, but that's for a future version.

One Project at a Time

This hard-coded feature:

private void startToolStripMenuItem_Click(object sender, EventArgs e)
{
  Program.StopCounters();
  Program.StartCurrentCounter();
}

ensures that only one project at a time can be "punched in" - having time charged against it.

What Next ?

While there doesn't appear to be any applications like this on Code Project, there are nifty punch clock apps one can download for the smart phone as well as regular desktop apps, but I don't necessarily have my phone next to me all the time.  That said, there are a few features that are definitely needed:

  • Reports and charts of daily / weekly / monthly activity
  • Summary reports over a period of time for billing purposes
  • Merging data with other devices - for example, if I am working on my laptop on the train, I want to merge that information with the desktop app.  Hmmm...cloud based data?

So, it's a start, we'll see where it goes.

License

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

Share

About the Author

Marc Clifton

United States United States
Marc is the creator of two open source projects, MyXaml, a declarative (XML) instantiation engine and the Advanced Unit Testing framework, and Interacx, a commercial n-tier RAD application suite.  Visit his website, www.marcclifton.com, where you will find many of his articles and his blog.
 
Marc lives in Philmont, NY.

Comments and Discussions

 
Questionsmall codechange, big result PinmemberMrDebug6522-Dec-12 22:20 
AnswerRe: small codechange, big result PinprotectorMarc Clifton27-Dec-12 4:12 
BugProcessing the hours PinmemberFranz Babener20-Dec-12 0:53 
GeneralRe: Processing the hours PinprotectorMarc Clifton27-Dec-12 4:13 
Franz Babener wrote:
For me I fixed that changing the line to

 
Thanks for finding that!
 
Marc

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 15 Dec 2012
Article Copyright 2012 by Marc Clifton
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid