1 |
// ***** BEGIN LICENSE BLOCK *****
|
2 |
// * Version: MPL 1.1
|
3 |
// *
|
4 |
// * The contents of this file are subject to the Mozilla Public License Version
|
5 |
// * 1.1 (the "License"); you may not use this file except in compliance with
|
6 |
// * the License. You may obtain a copy of the License at
|
7 |
// * http://www.mozilla.org/MPL/
|
8 |
// *
|
9 |
// * Software distributed under the License is distributed on an "AS IS" basis,
|
10 |
// * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
11 |
// * for the specific language governing rights and limitations under the
|
12 |
// * License.
|
13 |
// *
|
14 |
// * The Original Code is TurboPower SysTools
|
15 |
// *
|
16 |
// * The Initial Developer of the Original Code is
|
17 |
// * TurboPower Software
|
18 |
// *
|
19 |
// * Portions created by the Initial Developer are Copyright (C) 1996-2002
|
20 |
// * the Initial Developer. All Rights Reserved.
|
21 |
// *
|
22 |
// * Contributor(s):
|
23 |
// *
|
24 |
// * ***** END LICENSE BLOCK *****
|
25 |
//---------------------------------------------------------------------------
|
26 |
#include <vcl.h>
|
27 |
#pragma hdrstop
|
28 |
|
29 |
#include "gridfil0.h"
|
30 |
#pragma link "sttxtdat"
|
31 |
//---------------------------------------------------------------------------
|
32 |
#pragma package(smart_init)
|
33 |
#pragma resource "*.dfm"
|
34 |
TForm1 *Form1;
|
35 |
//---------------------------------------------------------------------------
|
36 |
__fastcall TForm1::TForm1(TComponent* Owner)
|
37 |
: TForm(Owner)
|
38 |
{
|
39 |
}
|
40 |
//---------------------------------------------------------------------------
|
41 |
void __fastcall TForm1::ClearGrid(bool ClearCaptions)
|
42 |
{
|
43 |
if (ClearCaptions) {
|
44 |
StringGrid1->Rows[0]->Clear();
|
45 |
}
|
46 |
for (int i = 1; i < StringGrid1->RowCount; i++) {
|
47 |
StringGrid1->Rows[i]->Clear();
|
48 |
}
|
49 |
}
|
50 |
//---------------------------------------------------------------------------
|
51 |
void __fastcall TForm1::FillCaptions(void)
|
52 |
{
|
53 |
StringGrid1->ColCount = Schema->Captions->Count;
|
54 |
StringGrid1->Rows[0]->Assign(Schema->Captions);
|
55 |
}
|
56 |
//---------------------------------------------------------------------------
|
57 |
void __fastcall TForm1::FillCells(void)
|
58 |
{
|
59 |
StringGrid1->RowCount = DataSet->Count;
|
60 |
int i = 1;
|
61 |
DataSet->First();
|
62 |
while (!DataSet->EOF()) {
|
63 |
StringGrid1->Rows[i]->Assign(DataSet->CurrentRecord->Values);
|
64 |
DataSet->Next();
|
65 |
i++;
|
66 |
}
|
67 |
}
|
68 |
//---------------------------------------------------------------------------
|
69 |
void __fastcall TForm1::FormDestroy(TObject *Sender)
|
70 |
{
|
71 |
delete Schema;
|
72 |
delete DataSet;
|
73 |
}
|
74 |
//---------------------------------------------------------------------------
|
75 |
|
76 |
void __fastcall TForm1::Button1Click(TObject *Sender)
|
77 |
{
|
78 |
if (OpenDialog1->Execute()) {
|
79 |
ClearGrid(true);
|
80 |
delete Schema;
|
81 |
Schema = new TStTextDataSchema;
|
82 |
Schema->LoadFromFile(OpenDialog1->FileName);
|
83 |
FillCaptions();
|
84 |
}
|
85 |
}
|
86 |
//---------------------------------------------------------------------------
|
87 |
void __fastcall TForm1::Button2Click(TObject *Sender)
|
88 |
{
|
89 |
if (OpenDialog2->Execute()) {
|
90 |
ClearGrid(false);
|
91 |
delete DataSet;
|
92 |
DataSet = new TStTextDataRecordSet;
|
93 |
DataSet->Schema = Schema;
|
94 |
DataSet->LoadFromFile(OpenDialog2->FileName);
|
95 |
FillCells();
|
96 |
}
|
97 |
}
|
98 |
//---------------------------------------------------------------------------
|