-
Notifications
You must be signed in to change notification settings - Fork 43
/
Import_FromComponents.pas
96 lines (77 loc) · 1.99 KB
/
Import_FromComponents.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
92
93
94
95
96
unit Import_FromComponents;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls, VCLBI.Grid,
Vcl.ComCtrls, Data.DB, Datasnap.DBClient, VCLBI.DataControl;
type
TFromComponents = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Button4: TButton;
PageControl1: TPageControl;
TabMemo: TTabSheet;
Memo1: TMemo;
BIGrid1: TBIGrid;
TabDataset: TTabSheet;
ClientDataSet1: TClientDataSet;
BIGrid2: TBIGrid;
procedure Button4Click(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure PageControl1Change(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
procedure ImportDataset;
public
{ Public declarations }
class procedure Show(const AOwner: TComponent); static;
end;
implementation
{$R *.dfm}
uses
BI.DataSource, BI.DB, BI.CSV;
procedure TFromComponents.Button4Click(Sender: TObject);
begin
Close;
end;
procedure TFromComponents.FormCreate(Sender: TObject);
begin
PageControl1.ActivePage:=TabMemo;
// Start demo importing Memo1 contents
Memo1Change(Self);
end;
procedure TFromComponents.FormDestroy(Sender: TObject);
begin
BIGrid1.DestroyData;
BIGrid2.DestroyData;
end;
procedure TFromComponents.ImportDataset;
begin
BIGrid2.DestroyData;
BIGrid2.Data:=TBIDB.From(ClientDataSet1);
end;
procedure TFromComponents.Memo1Change(Sender: TObject);
begin
BIGrid1.DestroyData;
BIGrid1.Data:=TBICSV.FromStrings(Memo1.Lines);
end;
procedure TFromComponents.PageControl1Change(Sender: TObject);
begin
if PageControl1.ActivePage=TabMemo then
Memo1Change(Self)
else
if PageControl1.ActivePage=TabDataset then
ImportDataset;
end;
class procedure TFromComponents.Show(const AOwner: TComponent);
begin
with TFromComponents.Create(AOwner) do
try
ShowModal;
finally
Free;
end;
end;
end.