Solved

Time tracking for sportsevent

Posted on 2013-11-18
7
245 Views
Last Modified: 2013-11-20
Hi,

I need to build an application that will register all participants of a sportsevent race (swimming or running a fixed distance). Every participant will have a registrationnumber to identify the person.
At the finish the registrationnumber of the finished participant will be registrered in the application and the endtime will be set.

Based on the number of participants, buttons will be created and placed on a form showing the registrationnumber. Clicking the individual button will set the endtime for the participant.
The form must be organised in such a way that alle buttons will be presented in increasing registrationnumber (1 -> 999).
The form has a vertical scrollbar to access currently non visible buttons.
Clicking a button will make it invisible on the from, so only remaining buttons (of non-finished participants) are available. Remaining buttons will be reorganised, so the buttons are presented as compact as possible (less scrolling).

What would be a good approach to accomplish this?
In stead of buttons any other approach is welcome (maybe a grid).

Maybe there is also some free open source that already has this functionality?
0
Comment
Question by:Delphiwizard
  • 4
  • 2
7 Comments
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39658495
can multiple people work with this system ?

when 100 or more competitors go to inscribe, will there be 1 or more people to register them ?

same for noting down the arrivals
arrivals can be very intense ... a mass of 100 people arriving for example
when registering, you need to be able to enter the exact time, or afterwards alter it.
scanning system ?

i've never actually written this for a competition, but i know there is a limit for people waiting on a system
0
 

Author Comment

by:Delphiwizard
ID: 39658636
It's gonna be a stand-alone single user system.

I'm aware of the complecity, but the idea is to make it as basic as can be.
Scanning with chips would be great in the furute, but customer has no budget for it. The race takes place once a year.
0
 
LVL 1

Accepted Solution

by:
livestuff earned 500 total points
ID: 39663796
This can easily be done with buttons.

Just as a quick demo, drop a TScrollbox on the form, set its align to alClient.

Then in the form's onActivate event you can Clear all buttons from Scrollbox and then recreate them, assigning the same event to them. Then use the one event to do the processing.  The trick here is knowing what button was clicked. So when you create the buttons, set the tag to the number of button

Let me write you up an example



unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm2 = class(TForm)
    ScrollBox1: TScrollBox;
    procedure ButtonClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure FormResize(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure ClearScrollbox;
    procedure CreateButtons;
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure  TForm2.ButtonClick(Sender: TObject);
begin
 ShowMessage(TButton(Sender).Caption);
 case TButton(Sender).tag of
  0: begin end;
  1: begin end;
  {etc}
 end;
end;

procedure TForm2.FormActivate(Sender: TObject);
begin
 ClearScrollBox;
 CreateButtons;
end;


procedure TForm2.FormResize(Sender: TObject);
begin
 ClearScrollBox;
 CreateButtons;
end;

procedure TForm2.ClearScrollbox;
var
 I: Integer;
begin
 for I:= Scrollbox1.ControlCount-1 downto 0 do
  if Scrollbox1.Controls[I] is TButton then
  begin
   TButton(Scrollbox1.Controls[I]).Free;
  end;
end;


procedure TForm2.CreateButtons;
var
 I, Pad, x,y: Integer;
 btn: TButton;
begin
// ClearScrollBox;
 pad:= 5;
 x:= 5;
 y:= 5;
 for I:= 0 to 99 do  //100 buttons
 begin
  btn:= TButton.Create(Scrollbox1);
  btn.Parent:= Scrollbox1;
  btn.Width:= 25;
  btn.Height:= 25;
  btn.Left:= x;
  btn.Top:= y;
  btn.Tag:= I;
  btn.OnClick:=  ButtonClick;
  btn.Caption:= intToStr(I);
  x:= x + btn.Width + Pad;
  if X >= Scrollbox1.width then
  begin
   X:= 5; Y:= Y + btn.Height + Pad;
  end;
 end;
end;

end.

Open in new window




There are a number of things you could do to impove upon this. Make a setting sdialog box to change the width and height of buttons, etc.

You can also lock screen befoe and clearling and drawing to prevent the flickering event. But I think this will get you going


Are you using a database with the name ans ID as the participants number? If so, you could set the endtime int he database at the buttons onclick event as well

procedure  TForm2.ButtonClick(Sender: TObject);
begin
  //Set endtime here and store it against the users number in database
end;
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Delphiwizard
ID: 39663993
This is very promissing.
One thing I need to solve with this is the following:
The last button in a row is often partly shown on screen.

How to make sure the buttons will always be shown fully on screen? Otherwise the button will start a new row.
0
 
LVL 1

Expert Comment

by:livestuff
ID: 39664009
Just play around with the create buttons routine. Sorry, I didn't save the code on my end. Send me a screenshot of what it is doing. I think particularly, you  should try changing the If then statement

if X >= Scrollbox1.width then

Open in new window


try something like

if X >= Scrollbox1.width - Pad then

Open in new window

0
 

Author Comment

by:Delphiwizard
ID: 39664166
This works fine:
if X >= Scrollbox1.width - 50 {button.width} then
0
 

Author Closing Comment

by:Delphiwizard
ID: 39664167
Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now