/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/CBuilder/dbexprt0.cpp
ViewVC logotype

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/examples/CBuilder/dbexprt0.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (show annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 3879 byte(s)
Added tpsystools component
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 "dbexprt0.h"
30 #pragma link "stexport"
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::SetCaption(String FN)
42 {
43 Caption = DefaultCaption;
44 if (FN != "") {
45 Caption = Caption + " - [" + FN + "]";
46 }
47 }
48 //---------------------------------------------------------------------------
49 void __fastcall TForm1::Button1Click(TObject *Sender)
50 {
51 SchemaMaker = new TStDbSchemaGenerator;
52
53 try {
54 SchemaMaker->FieldDelimiter = StDeEscape(Edit1->Text);
55
56 SchemaMaker->DataSet = Table1;
57
58 SaveDialog1->FileName = ChangeFileExt(ExtractFileName(CurrentDb), ".sch");
59 SaveDialog1->DefaultExt = "sch";
60 SaveDialog1->Filter = "Schema Files /*.sch)|*.sch|All Files /*.*/|*.*";
61 SaveDialog1->Title = "Save Schema";
62 if (SaveDialog1->Execute()) {
63 SchemaMaker->SchemaName = ChangeFileExt(ExtractFileName(SaveDialog1->FileName), "");
64 SchemaMaker->ExportToFile(SaveDialog1->FileName);
65 Memo1->Lines->LoadFromFile(SaveDialog1->FileName);
66 }
67 }
68 __finally {
69 delete SchemaMaker;
70 }
71 }
72 //---------------------------------------------------------------------------
73 void __fastcall TForm1::Button2Click(TObject *Sender)
74 {
75 if (OpenDialog1->Execute()) {
76 Table1->Close();
77 CurrentDb = OpenDialog1->FileName;
78 Table1->TableName = CurrentDb;
79 Table1->Open();
80 SetCaption(CurrentDb);
81 }
82 }
83 //---------------------------------------------------------------------------
84
85 void __fastcall TForm1::Button3Click(TObject *Sender)
86 {
87 Exporter = new TStDBtoCSVExport;
88
89 try {
90 Exporter->DataSet = Table1;
91 Exporter->IncludeHeader = CheckBox1->Checked;
92 Exporter->FieldDelimiter = StDeEscape(Edit1->Text);
93
94 SaveDialog1->FileName = ChangeFileExt(ExtractFileName(CurrentDb), ".csv");
95 SaveDialog1->DefaultExt = "csv";
96 SaveDialog1->Filter = "CSV Files /*.csv)|*.csv|All Files /*.*/|*.*";
97 SaveDialog1->Title = "Save Table Data";
98 if (SaveDialog1->Execute()) {
99 Exporter->ExportToFile(SaveDialog1->FileName);
100 Memo1->Lines->LoadFromFile(SaveDialog1->FileName);
101 }
102 }
103 __finally {
104 delete Exporter;
105 }
106 }
107 //---------------------------------------------------------------------------
108
109 void __fastcall TForm1::Button4Click(TObject *Sender)
110 {
111 CurrentDb = "";
112 Table1->Close();
113 Table1->TableName = CurrentDb;
114 Memo1->Lines->Clear();
115 SetCaption(CurrentDb);
116 }
117 //---------------------------------------------------------------------------
118

  ViewVC Help
Powered by ViewVC 1.1.20