Friday, April 18, 2008

Project 1: Time Sheet Calculator

Okay, so this whole thing started the other day when I got sick of doing payroll. At my workplace, the staff members clock in and clock out with and old-fashioned time card system, once which prints the time on a piece of card stock. Every other Thursday, I have to go through every single card, calculate the shift times in my head, and then add them all up on my own. It's a tedious and pointless process. I could spend a couple hundred bucks to buy an electronic system that would make it automatic. That, OR--!!!

I downloaded Visual C# Express, since I heard every retard on the planet is using C# these days. I learned what I needed to know from the in-program documentation, and start to finish spent about 30 or 40 minutes. Here's what I ended up with:


It's ugly, right? But it gets the job done. I spend about 2 hours per payroll adding all that up--with this, I'll probably spend 15 minutes.

Here's the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PayrollMcGee
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void TotalLabel_Update()
{
TotalLabel.Text = ((dateTimePicker2.Value - dateTimePicker1.Value) +
(dateTimePicker4.Value - dateTimePicker3.Value) +
(dateTimePicker6.Value - dateTimePicker5.Value) +
(dateTimePicker8.Value - dateTimePicker7.Value) +
(dateTimePicker10.Value - dateTimePicker9.Value) +
(dateTimePicker12.Value - dateTimePicker11.Value) +
(dateTimePicker14.Value - dateTimePicker13.Value) +
(dateTimePicker16.Value - dateTimePicker15.Value) +
(dateTimePicker18.Value - dateTimePicker17.Value) +
(dateTimePicker20.Value - dateTimePicker19.Value) +
(dateTimePicker22.Value - dateTimePicker21.Value) +
(dateTimePicker24.Value - dateTimePicker23.Value) +
(dateTimePicker26.Value - dateTimePicker25.Value) +
(dateTimePicker28.Value - dateTimePicker27.Value)).ToString();
}

private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
{
TotalLabel_Update();
}

private void dateTimePicker2_ValueChanged(object sender, EventArgs e)
{
TotalLabel_Update();
}

...

private void dateTimePicker28_ValueChanged(object sender, EventArgs e)
{
TotalLabel_Update();
}
}
}

Tedious, right? Just like always. It's super ghett0, completely taped together, and probably looks like something somebody would do if they'd just discovered visual programming interfaces.

So, um, yeah. That's me.

No comments: