| 2265 |
kivins |
1 |
//---------------------------------------------------------------------------
|
|
|
2 |
|
|
|
3 |
#include <vcl.h>
|
|
|
4 |
#pragma hdrstop
|
|
|
5 |
|
|
|
6 |
#include "TestDirectorLogin.h"
|
|
|
7 |
//---------------------------------------------------------------------------
|
|
|
8 |
#pragma package(smart_init)
|
|
|
9 |
#pragma resource "*.dfm"
|
|
|
10 |
TTestDirectorLoginForm *TestDirectorLoginForm;
|
|
|
11 |
//---------------------------------------------------------------------------
|
|
|
12 |
__fastcall TTestDirectorLoginForm::TTestDirectorLoginForm(TComponent* Owner)
|
|
|
13 |
: TForm(Owner)
|
|
|
14 |
{
|
|
|
15 |
}
|
|
|
16 |
//---------------------------------------------------------------------------
|
|
|
17 |
|
|
|
18 |
bool TTestDirectorLoginForm::Login( TADOConnection *connection )
|
|
|
19 |
{
|
|
|
20 |
bool result = false;
|
|
|
21 |
|
|
|
22 |
m_connection = connection;
|
|
|
23 |
|
|
|
24 |
if (ShowModal() == mrOk)
|
|
|
25 |
{
|
|
|
26 |
if (m_connection->Connected)
|
|
|
27 |
{
|
|
|
28 |
result = true;
|
|
|
29 |
}
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
return result;
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
//---------------------------------------------------------------------------
|
|
|
36 |
|
|
|
37 |
void __fastcall TTestDirectorLoginForm::FormShow(TObject *Sender)
|
|
|
38 |
{
|
|
|
39 |
UseDomainLogin->Checked = true;
|
|
|
40 |
GroupBox1->Enabled = false;
|
|
|
41 |
Username->ReadOnly = true;
|
|
|
42 |
Username->Text = "";
|
|
|
43 |
|
|
|
44 |
Password->ReadOnly = true;
|
|
|
45 |
Password->Text = "";
|
|
|
46 |
|
|
|
47 |
DatabaseComboBox->ItemIndex = 0;
|
|
|
48 |
}
|
|
|
49 |
//---------------------------------------------------------------------------
|
|
|
50 |
|
|
|
51 |
void __fastcall TTestDirectorLoginForm::UseDomainLoginClick(
|
|
|
52 |
TObject *Sender)
|
|
|
53 |
{
|
|
|
54 |
GroupBox1->Enabled = !UseDomainLogin->Checked;
|
|
|
55 |
|
|
|
56 |
Username->ReadOnly = UseDomainLogin->Checked;
|
|
|
57 |
Password->ReadOnly = UseDomainLogin->Checked;
|
|
|
58 |
}
|
|
|
59 |
//---------------------------------------------------------------------------
|
|
|
60 |
|
|
|
61 |
void __fastcall TTestDirectorLoginForm::LoginBtnClick(TObject *Sender)
|
|
|
62 |
{
|
|
|
63 |
AnsiString connection_string;
|
|
|
64 |
|
|
|
65 |
if (UseDomainLogin->Checked)
|
|
|
66 |
{
|
|
|
67 |
connection_string.sprintf("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=%s;Data Source=%s",
|
|
|
68 |
DatabaseComboBox->Text.c_str(),
|
|
|
69 |
ServerComboBox->Text.c_str()
|
|
|
70 |
);
|
|
|
71 |
}
|
|
|
72 |
else
|
|
|
73 |
{
|
|
|
74 |
connection_string.sprintf("Provider=SQLOLEDB.1;Password=%s;Persist Security Info=False;User ID=%s;Initial Catalog=%s;Data Source=%s",
|
|
|
75 |
Password->Text.c_str(),
|
|
|
76 |
Username->Text.c_str(),
|
|
|
77 |
DatabaseComboBox->Text.c_str(),
|
|
|
78 |
ServerComboBox->Text.c_str()
|
|
|
79 |
);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
m_connection->ConnectionString = connection_string;
|
|
|
83 |
|
|
|
84 |
m_connection->Connected = true;
|
|
|
85 |
|
|
|
86 |
if (m_connection->Connected)
|
|
|
87 |
{
|
|
|
88 |
ModalResult = mrOk;
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
//---------------------------------------------------------------------------
|
|
|
92 |
|
|
|
93 |
|