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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TWAPanels,Unitplanning, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
UnPlanning:TPlanning;
end;
var
Form1: TForm1;
implementation
uses DateUtils;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
UnPlanning:=TPlanning.Create;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnPlanning.Free;
end;
procedure TForm1.Button1Click(Sender: TObject);
var UneFiche:TFiche;
i:integer;
begin
UneFiche:=TFiche.Create; //NouvelleFiche
UneFiche.Debut:=EncodeDateTime(2006,11,6,8,0,0,0); //le 6/11/2006 entre 8h00
UneFiche.Fin:=EncodeDateTime(2006,11,6,9,30,0,0); // et 9h30
UneFiche.Titre:='RDV';
uneFiche.Description.Add('Aller chez le médecin');
uneFiche.Description.Add('Ne pas oublier la carte vitale');
UnPlanning.Add(UneFiche); //Enregistrement de la fiche
UneFiche:=TFiche.Create;
UneFiche.Debut:=EncodeDateTime(2006,11,15,21,0,0,0); //le 15/11/2006 entre 21h00
UneFiche.Fin:=EncodeDateTime(2006,11,15,23,30,0,0); // et 23h30
UneFiche.Titre:='Cinoche';
uneFiche.Description.Add('On va voir quel film ?');
UnPlanning.Add(UneFiche);
UneFiche:=TFiche.Create;
UneFiche.Debut:=EncodeDateTime(2006,11,7,12,0,0,0); //le 7/11/2006 entre 12h00
UneFiche.Fin:=EncodeDateTime(2006,11,7,13,30,0,0); // et 13h30
UneFiche.Titre:='Repas';
uneFiche.Description.Add('Resto avec le patron');
UnPlanning.Add(UneFiche);
//Sauvegarde du planning
UnPlanning.SaveToFile('MonPlanning.pla');
//Recherche d'une Fiche en particulier :
//Que fais-je le 15/11/2006 à 22h00 ?
i:=UnPlanning.IndexOf(EncodeDateTime(2006,11,15,22,0,0,0));
if i>-1 then begin
UnPlanning.IndexCourant:=i;
ShowMessage(UnPlanning.FicheCourante.Titre);
end;
//affichage de toutes les fiches entre le 1er novembre et le 10 novembre
for i:=0 to UnPlanning.Count-1 do
begin
UnPlanning.IndexCourant:=i;
if UnPlanning.FicheCourante.isBetween(EncodeDateTime(2006,11,1,0,0,0,0),EncodeDateTime(2006,11,11,0,0,0,0))
then ShowMessage(UnPlanning.FicheCourante.Titre);
end;
//Supprimer un rendez-vous
UnPlanning.Delete(0);
end;
end. |
Partager