1 | unit UFormItemSelect;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, EditBtn,
|
---|
9 | ComCtrls, StdCtrls, USystem;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TItemSelectForm }
|
---|
14 |
|
---|
15 | TItemSelectForm = class(TForm)
|
---|
16 | ButtonSelect: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | ListView1: TListView;
|
---|
19 | procedure FormCreate(Sender: TObject);
|
---|
20 | procedure FormDestroy(Sender: TObject);
|
---|
21 | procedure FormShow(Sender: TObject);
|
---|
22 | procedure ListView1Data(Sender: TObject; Item: TListItem);
|
---|
23 | procedure ListView1Resize(Sender: TObject);
|
---|
24 | private
|
---|
25 | function GetSelectedId: Integer;
|
---|
26 | { private declarations }
|
---|
27 | public
|
---|
28 | Report: TReport;
|
---|
29 | ObjectId: Integer;
|
---|
30 | ListObject: TChronisObject;
|
---|
31 | procedure LoadList;
|
---|
32 | property SelectedId: Integer read GetSelectedId;
|
---|
33 | end;
|
---|
34 |
|
---|
35 | var
|
---|
36 | ItemSelectForm: TItemSelectForm;
|
---|
37 |
|
---|
38 | implementation
|
---|
39 |
|
---|
40 | {$R *.lfm}
|
---|
41 |
|
---|
42 | uses
|
---|
43 | UCore;
|
---|
44 |
|
---|
45 | { TItemSelectForm }
|
---|
46 |
|
---|
47 | procedure TItemSelectForm.ListView1Data(Sender: TObject; Item: TListItem);
|
---|
48 | var
|
---|
49 | I: Integer;
|
---|
50 | begin
|
---|
51 | if Item.Index < Report.Count then
|
---|
52 | with TReportLine(Report[Item.Index]) do begin
|
---|
53 | Item.Caption := Items[0];
|
---|
54 | Item.Data := Pointer(Id);
|
---|
55 | for I := 1 to Items.Count - 1 do
|
---|
56 | if not TReportColumn(Report.Columns[I]).VirtualItem then
|
---|
57 | Item.SubItems.Add(Items[I]);
|
---|
58 | end;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TItemSelectForm.ListView1Resize(Sender: TObject);
|
---|
62 | var
|
---|
63 | I: Integer;
|
---|
64 | begin
|
---|
65 | for I := 0 to ListView1.Columns.Count - 1 do
|
---|
66 | ListView1.Columns[I].Width := ListView1.Width div ListView1.Columns.Count;
|
---|
67 | end;
|
---|
68 |
|
---|
69 | function TItemSelectForm.GetSelectedId: Integer;
|
---|
70 | begin
|
---|
71 | if Assigned(ListView1.Selected) then Result := Integer(ListView1.Selected.Data)
|
---|
72 | else Result := -1;
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TItemSelectForm.LoadList;
|
---|
76 | begin
|
---|
77 | // SelectedObjectId := 0;
|
---|
78 | with ListView1 do begin
|
---|
79 | ListObject.Load(ObjectId);
|
---|
80 | Report.Load(ListObject); //, '`' + PropertyName + '`=' + IntToStr(TabObjectList[TabControl1.TabIndex]));
|
---|
81 |
|
---|
82 | Report.FillListColumns(Columns);
|
---|
83 | Items.Count := Report.Count;
|
---|
84 | Refresh;
|
---|
85 | end;
|
---|
86 | ListView1Resize(Self);
|
---|
87 | end;
|
---|
88 |
|
---|
89 | procedure TItemSelectForm.FormCreate(Sender: TObject);
|
---|
90 | begin
|
---|
91 | Report := TReport.Create;
|
---|
92 | Report.Base := Core.System;
|
---|
93 | ListObject := TChronisObject.Create;
|
---|
94 | ListObject.Base := Core.System;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | procedure TItemSelectForm.FormDestroy(Sender: TObject);
|
---|
98 | begin
|
---|
99 | Report.Free;
|
---|
100 | ListObject.Free;
|
---|
101 | end;
|
---|
102 |
|
---|
103 | procedure TItemSelectForm.FormShow(Sender: TObject);
|
---|
104 | begin
|
---|
105 | LoadList;
|
---|
106 | end;
|
---|
107 |
|
---|
108 | end.
|
---|
109 |
|
---|