Zazpe – attendance management

Some time ago, the director of the Monseñor Zazpe choir, from the San José parish, asked me for something to manage choir member attendance. I started developing a program in Mono with Gtk#. After some difficulties I had getting it to work well on Windows, I decided on a safer path: Windows.Forms. He (the person who asked me for this program) works on Windows, so that definitely pushed me toward that toolkit.

Zazpe main window

Now I regret it :( Later, after the interface was quite advanced, I realized why those tests with Gtk on Windows didn’t work. But oh well… it’s done, maybe I’ll do something about it later.

UPDATE: You can visit this page for more information about it

With Zazpe (that’s the name I gave the little program) we can enter people and events, then record attendance at those occasions, and also generate reports for printing. This last feature is not fully implemented yet, and I still need to choose a convenient way to set attendance.

A few weeks ago, when I sat down for a while to continue with this, I wondered about a quick way to fix bugs in the program. No matter how much you test what you make, the person who ends up using it always finds a way to blow everything up. Surely when I send them some revision, an exception will pop up and the program will close. I can’t ask them to write an error report, to tell me what they were doing at the time of the error, because it’s too much hassle for them.

Zazpe - Enter person

Copying a bit of the system from Windows and Ubuntu, what I do is build a report as the application progresses through its execution. So, I record the data that was entered, the forms that were loaded, etc. All of this gets saved to a plain text file. When an uncaught exception occurs, it informs the user that an error has occurred, and asks them to send the report file to my email. This way, I can verify exactly (well, almost) what was happening, the data entered, the exception that was thrown and its stacktrace. For more serious software, this might be too “spyware-like”.

To do this, what I did was declare a class (a subclass of Windows.Forms.Form), FormLogging, from which all forms inherit. This is the class responsible for all the logging of what happens in the form. It handles setting up event handlers for the controls I’m interested in (like TextBoxes, ComboBoxes, etc.) to record what happens. All this work is completely transparent to the forms that are subclasses.

An example of a log would be the following:

Load: MainForm
Load: IngresarPersona
   txtDNI: 123456
   cmbSexo: Hombre
   txtApellido: Pividori
   txtNombre: Milton
   btnCancelar pressed
Exit: IngresarPersona
Load: AcercaDe
Exit: AcercaDe
Load: IngresarEvento
   btnCancelar pressed
Exit: IngresarEvento
Load: IngresarPersona
   txtDNI: 1111
   cmbSexo: Hombre
   txtApellido: Pividori
   txtNombre: Milton
   btnAceptar pressed
Uncaught exception:
   Type: Zazpe.Personas.PersonaExistenteException
   Message: Attempting to enter a person
      that already exists in the database.
   Source: ControladorPersonas
   StackTrace:
   ...

In it we see that the user wanted to enter a person, added some data, but then changed their mind and closed the window with the Cancel button. Then they took a peek at the About form. They thought about entering an event, but changed their mind afterward. After going to answer the doorbell (they had ordered a pizza, because they had nothing in the fridge to eat) :D, they thought it was a good idea to add me, after all, to the list of people, but they forgot they had already done it before… and I forgot to catch the PersonaExistenteException when trying to enter a person into the database.

Going back to the Gtk# topic, it wouldn’t be difficult to port it to GNU/Linux. I developed most of it on this system, with Mono. I also used NUnit for unit testing, and SQLite as the database.

Soon I’m going to add a page to this blog with more information about Zazpe, and a link to download the source code.

If later I wanted to develop another CRUD application, I would have to take a lot of what I did in Zazpe, and modify it, since it’s very similar. Do you know of any framework to automate this? Someone told me something about Turbo Gears and I read about Ruby on Rails, but I’m more interested in the final result being a desktop application, not a web one.

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus