1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
procedure Tfrecherche.BcalculClick(Sender: TObject);
var
texte : string; // Utilisé pour la construction du resultat
Delta : TJJMMAA; // retourné par la fonction CalculEcart
begin
Delta := CalculEcart(DateTimePicker1.date, DateTimePicker2.date); // appel de la fonction
// mise en forme du résultat
texte := '';
with Delta do begin
case JJ of // si au moins un jour on l'affiche en l'accordant en nombre
0 : ;
1 : texte := '1 jour';
else
texte := format('%2d jours', [JJ]);
end;
if MM > 0 then // si au moins un mois on l'affiche, 'mois' se terminant par
un 's' pose moins de problème!
if texte = '' then
texte := format('%2d mois', [MM])
else
texte := format('%2d mois, ', [MM]) + texte;
if (AA > 0) and
(Texte <> '') then
Texte := ', ' + Texte;
case AA of // si au moins un an on l'affiche en l'accordant en nombre
0 : ;
1 : texte := '1 an' + Texte;
else
texte := format('%2d ans', [AA]) + Texte;
end;
if CompareDate(DateTimePicker1.date, DateTimePicker2.date) > 0 then // si la 1ère date est
postérieure à la seconde
Label1.Caption := 'Dépassé depuis ' + Texte
else
Label1.Caption := 'Il s''est écoulé ' + Texte;
// edit1.text := 'Il s''est écoulé ' + Texte;
end;
end; |
Partager