-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathItemDlg.pas
82 lines (70 loc) · 1.96 KB
/
ItemDlg.pas
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
unit ItemDlg;
{
ItemDlg, part of TODJobSchedule Component - general purpose scheduler.
My Power Station Technology (Pty) Ltd - was Orbital Decisions
P.O.Box 1080, Milnerton 7435, South Africa
http://www.orbital.co.za/text/prodlist.htm
Copyright (c) 1998-2019
Use at your own risk!
}
interface
uses
Windows, Messages, SysUtils, Classes, VCL.Graphics, VCL.Controls, VCL.Forms, VCL.Dialogs,
VCL.StdCtrls, VCL.Buttons, ODSched;
type
TODJobItemForm = class(TForm)
OKBtn: TBitBtn;
CancelBtn: TBitBtn;
Label1: TLabel;
AvailList: TListBox;
procedure OKBtnClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure AvailListClick(Sender: TObject);
procedure AvailListDblClick(Sender: TObject);
public
JobItem: TODJobItem;
Job: TODJob;
OnInitDialog: TODInitItemDialogEvent;
end;
var
ODJobItemForm: TODJobItemForm;
implementation
{$R *.DFM}
procedure TODJobItemForm.FormShow(Sender: TObject);
begin
if Assigned(OnInitDialog) then
OnInitDialog(Job.Schedule, Job, JobItem, AvailList.Items);
with AvailList do
begin
MultiSelect := JobItem = nil;
if not MultiSelect then
begin //editing a job item
if Items.IndexOf(JobItem.Caption) = -1 then
Items.Add(JobItem.Caption);
ItemIndex := Items.IndexOf(JobItem.Caption);
end;
end;
end;
procedure TODJobItemForm.OKBtnClick(Sender: TObject);
var
ix: Integer;
begin
with AvailList do
if JobItem <> nil then //editing an existing item
JobItem.Caption := Items[ItemIndex]
else if Job <> nil then //adding new items -
for ix := 0 to Items.Count-1 do
if Selected[ix] then
Job.AddItemFrom(0, Items[ix]);
end;
procedure TODJobItemForm.AvailListClick(Sender: TObject);
begin
OKBtn.Enabled := AvailList.Items.Count > 0;
end;
procedure TODJobItemForm.AvailListDblClick(Sender: TObject);
begin
ModalResult := mrOK;
OKBtnClick(nil);
end;
end.