Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2265 kivins 1
//---------------------------------------------------------------------------
2
 
3
#include <vcl.h>
4
#pragma hdrstop
5
 
6
#include "ImportTransactionParameters.h"
7
#include <Registry.hpp>
8
 
9
//---------------------------------------------------------------------------
10
#pragma package(smart_init)
11
#pragma link "AdvDirectoryEdit"
12
#pragma link "AdvEdBtn"
13
#pragma link "AdvEdit"
14
#pragma link "FlCtrlEx"
15
#pragma resource "*.dfm"
16
TImportTransactionParametersForm *ImportTransactionParametersForm;
17
const char * TImportTransactionParametersForm::g_importKey = "Software\\ERG\\TxnTestManager\\Import";
18
//---------------------------------------------------------------------------
19
__fastcall TImportTransactionParametersForm::TImportTransactionParametersForm(TComponent* Owner)
20
	: TForm(Owner)
21
{
22
}
23
//---------------------------------------------------------------------------
24
 
25
void __fastcall TImportTransactionParametersForm::FormShow(TObject *Sender)
26
{
27
	TRegistry * registry = 0;
28
 
29
	try
30
	{
31
		registry = new TRegistry();
32
		registry->RootKey = HKEY_CURRENT_USER;
33
 
34
		// Create the key if it doesn't exist.
35
		registry->OpenKey( g_importKey, true );
36
 
37
		AnsiString profile;
38
 
39
		profile = registry->ReadString( "Profile" );
40
		if ( profile.IsEmpty() )
41
		{
42
			profile = "TDS";
43
		}
44
 
45
		ImportProfileComboBox->Text = profile;
46
		ImportProfileComboBox->ItemIndex = -1;
47
		for ( int index = 0; index < ImportProfileComboBox->Items->Count; ++index )
48
		{
49
			if ( ImportProfileComboBox->Items->Strings[ index ] == profile )
50
			{
51
				ImportProfileComboBox->ItemIndex = index;
52
				break;
53
			}
54
		}
55
 
56
		readProfile( *registry, profile );
57
	}
58
	__finally
59
	{
60
		delete registry;
61
	}
62
}
63
//---------------------------------------------------------------------------
64
 
65
void __fastcall TImportTransactionParametersForm::OKClick(TObject *Sender)
66
{
67
	TRegistry * registry = 0;
68
 
69
	try
70
	{
71
		registry = new TRegistry();
72
		registry->RootKey = HKEY_CURRENT_USER;
73
 
74
		// Create the key if it doesn't exist.
75
		registry->OpenKey( g_importKey, true );
76
 
77
		writeProfile( *registry, ImportProfileComboBox->Text );
78
	}
79
	__finally
80
	{
81
		delete registry;
82
	}
83
}
84
//---------------------------------------------------------------------------
85
 
86
void __fastcall TImportTransactionParametersForm::readProfile( TRegistry & registry, const AnsiString & profile )
87
{
88
	if ( registry.OpenKey( profile, true ) )
89
	{
90
		AnsiString folder = registry.ReadString( "Folder" );
91
		if ( folder.IsEmpty() )
92
		{
93
			folder = GetCurrentDir();
94
		}
95
 
96
		ImportFolderDirectoryEdit->Text = folder;
97
		ImportFileListBox->ApplyFilePath( folder );
98
	}
99
}
100
//---------------------------------------------------------------------------
101
 
102
void __fastcall TImportTransactionParametersForm::writeProfile( TRegistry & registry, const AnsiString & profile )
103
{
104
	registry.WriteString( "Profile", profile );
105
 
106
	if ( registry.OpenKey( profile, true ) )
107
	{
108
		registry.WriteString( "Folder", ImportFolderDirectoryEdit->Text );
109
	}
110
}
111
//---------------------------------------------------------------------------
112
 
113
void __fastcall TImportTransactionParametersForm::ImportFolderDirectoryEditChange(
114
	  TObject *Sender)
115
{
116
	ImportFileListBox->ApplyFilePath( ImportFolderDirectoryEdit->Text );
117
}
118
//---------------------------------------------------------------------------
119
 
120
void __fastcall TImportTransactionParametersForm::ImportProfileComboBoxChange(
121
	  TObject *Sender)
122
{
123
	TRegistry * registry = 0;
124
 
125
	try
126
	{
127
		registry = new TRegistry();
128
		registry->RootKey = HKEY_CURRENT_USER;
129
 
130
		// Create the key if it doesn't exist.
131
		registry->OpenKey( g_importKey, true );
132
 
133
		readProfile( *registry, ImportProfileComboBox->Text );
134
	}
135
	__finally
136
	{
137
		delete registry;
138
	}
139
}
140
//---------------------------------------------------------------------------
141