| 2263 |
kivins |
1 |
//---------------------------------------------------------------------------
|
|
|
2 |
|
|
|
3 |
#include <vcl.h>
|
|
|
4 |
#pragma hdrstop
|
|
|
5 |
|
|
|
6 |
#include "Login.h"
|
|
|
7 |
#include "Registry.hpp"
|
|
|
8 |
|
|
|
9 |
//---------------------------------------------------------------------------
|
|
|
10 |
#pragma package(smart_init)
|
|
|
11 |
#pragma resource "*.dfm"
|
|
|
12 |
TLoginForm *LoginForm;
|
|
|
13 |
//---------------------------------------------------------------------------
|
|
|
14 |
__fastcall TLoginForm::TLoginForm(TComponent* Owner)
|
|
|
15 |
: TForm(Owner)
|
|
|
16 |
{
|
|
|
17 |
}
|
|
|
18 |
//---------------------------------------------------------------------------
|
|
|
19 |
void __fastcall TLoginForm::FormShow(TObject *Sender)
|
|
|
20 |
{
|
|
|
21 |
TRegistry *registry = NULL;
|
|
|
22 |
|
|
|
23 |
try
|
|
|
24 |
{
|
|
|
25 |
registry = new TRegistry();
|
|
|
26 |
registry->RootKey = HKEY_CURRENT_USER;
|
|
|
27 |
|
|
|
28 |
// True because we want to create it if it doesn't exist
|
|
|
29 |
registry->OpenKey("Software\\ERG\\TxnTestManager", true);
|
|
|
30 |
AnsiString last_user = registry->ReadString("LastUser");
|
|
|
31 |
AnsiString database = registry->ReadString("Database");
|
|
|
32 |
|
|
|
33 |
if (last_user.IsEmpty())
|
|
|
34 |
{
|
|
|
35 |
last_user = "tsb";
|
|
|
36 |
}
|
|
|
37 |
|
|
|
38 |
if (database.IsEmpty())
|
|
|
39 |
{
|
|
|
40 |
database = "";
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
UsernameEdit->Text = last_user;
|
|
|
44 |
DatabaseEdit->Text = database;
|
|
|
45 |
PasswordEdit->Text = last_user;
|
|
|
46 |
PasswordEdit->SetFocus();
|
|
|
47 |
}
|
|
|
48 |
__finally
|
|
|
49 |
{
|
|
|
50 |
delete registry;
|
|
|
51 |
}
|
|
|
52 |
}
|
|
|
53 |
//---------------------------------------------------------------------------
|
|
|
54 |
void __fastcall TLoginForm::LoginOKBtnClick(TObject *Sender)
|
|
|
55 |
{
|
|
|
56 |
TRegistry *registry = NULL;
|
|
|
57 |
|
|
|
58 |
try
|
|
|
59 |
{
|
|
|
60 |
registry = new TRegistry();
|
|
|
61 |
registry->RootKey = HKEY_CURRENT_USER;
|
|
|
62 |
|
|
|
63 |
// True because we want to create it if it doesn't exist
|
|
|
64 |
registry->OpenKey("Software\\ERG\\TxnTestManager", true);
|
|
|
65 |
registry->WriteString("LastUser", UsernameEdit->Text);
|
|
|
66 |
registry->WriteString("Database", DatabaseEdit->Text);
|
|
|
67 |
}
|
|
|
68 |
__finally
|
|
|
69 |
{
|
|
|
70 |
delete registry;
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
//---------------------------------------------------------------------------
|
|
|
74 |
|