forked from urgn-zz/school_schedule_generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_dlg.pas
91 lines (75 loc) · 2.63 KB
/
export_dlg.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
83
84
85
86
87
88
89
90
91
unit export_dlg;
interface
uses Winapi.Windows, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Forms,
Vcl.Controls, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, Vcl.Dialogs,
frxExportPDF, frxClass, frxExportXLS, Vcl.ComCtrls, TTimeTable,Data.SqlExpr,Datasnap.DBClient;
type
TExportDlg = class(TForm)
OKBtn: TButton;
CancelBtn: TButton;
ListView1: TListView;
procedure SetData(aTimeTable : T_TimeTable; ds_Load : TClientDataSet);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ExportDlg: TExportDlg;
implementation
{$R *.dfm}
{ TExportDlg }
procedure TExportDlg.SetData(aTimeTable: T_TimeTable; ds_Load : TClientDataSet);
var i : integer;
li : TListItem;
ldi : TLoadItem;
begin
if aTimeTable = nil then exit;
for i := 0 to pred(aTimeTable.FreeLoad.Count) do
begin
li := ListView1.Items.Add;
ldi := aTimeTable.FreeLoad.Items[i] AS TLoadItem;
ds_Load.First;
while not ds_Load.Eof do
begin
if not (ds_Load.FieldByName('load_id').Value = ldi.LoadID) then
begin
ds_Load.Next;
continue;
end;
li.Caption := ds_Load.FieldByName('Subject').Value;
li.SubItems.Add(ds_Load.FieldByName('Lesson Type').Value);
li.SubItems.Add(ds_Load.FieldByName('Teacher').Value);
li.SubItems.Add(ds_Load.FieldByName('Group').Value);
li.SubItems.Add('Time conflict');
ds_Load.Next;
end;
end;
for i := 0 to pred(aTimeTable.AllLessons.Count) do
begin
if not ((aTimeTable.AllLessons.Items[i] AS TLesson).Room = nil) then continue;
ldi := (aTimeTable.AllLessons.Items[i] AS TLesson).LoadItem;
li := ListView1.Items.Add;
ds_Load.First;
while not ds_Load.Eof do
begin
if not (ds_Load.FieldByName('load_id').Value = ldi.LoadID) then
begin
ds_Load.Next;
continue;
end;
li.Caption := ds_Load.FieldByName('Subject').Value;
li.SubItems.Add(ds_Load.FieldByName('Lesson Type').Value);
li.SubItems.Add(ds_Load.FieldByName('Teacher').Value);
li.SubItems.Add(ds_Load.FieldByName('Group').Value);
li.SubItems.Add('No room');
ds_Load.Next;
end;
end;
ListView1.Columns[0].Width := -1 or -2;
ListView1.Columns[1].Width := -1 or -2;
ListView1.Columns[2].Width := -1 or -2;
ListView1.Columns[3].Width := -1 or -2;
ListView1.Columns[4].Width := -1 or -2;
end;
end.