Commit 712d5a6c authored by Sandro Camata Santana's avatar Sandro Camata Santana

Ajuste para utilizar função listar Drivers ODBC multiplataforma

parent cf84fcec
object DataBaseLogin: TDataBaseLogin
Left = 2368
Height = 294
Top = 542
Width = 335
Left = 2241
Height = 543
Top = 255
Width = 442
BorderIcons = [biSystemMenu]
BorderStyle = bsDialog
Caption = 'Connect to Database Server'
ClientHeight = 294
ClientWidth = 335
ClientHeight = 543
ClientWidth = 442
Color = clBtnFace
Font.Color = clWindowText
Font.Height = -13
......@@ -17,90 +17,144 @@ object DataBaseLogin: TDataBaseLogin
Position = poOwnerFormCenter
LCLVersion = '2.0.0.4'
object Bevel1: TBevel
Left = 16
Left = 21
Height = 8
Top = 240
Width = 304
Top = 494
Width = 400
Shape = bsTopLine
end
object Button1: TButton
Left = 164
Left = 265
Height = 25
Top = 256
Top = 504
Width = 75
Caption = 'Ok'
Default = True
OnClick = Button1Click
TabOrder = 4
TabOrder = 9
end
object Button2: TButton
Left = 245
Left = 346
Height = 25
Top = 256
Top = 504
Width = 75
Cancel = True
Caption = 'Cancel'
OnClick = Button2Click
TabOrder = 5
TabOrder = 10
end
object cbODBCD_DSN: TComboBox
Left = 16
Left = 37
Height = 26
Top = 31
Width = 304
Top = 56
Width = 384
ItemHeight = 18
OnChange = cbODBCD_DSNChange
Style = csDropDownList
TabOrder = 0
TabOrder = 1
end
object edtUsuario: TLabeledEdit
Left = 16
Left = 21
Height = 26
Top = 144
Width = 304
Top = 398
Width = 400
EditLabel.Height = 18
EditLabel.Width = 304
EditLabel.Width = 400
EditLabel.Caption = 'Usuário'
EditLabel.ParentColor = False
TabOrder = 2
TabOrder = 7
end
object edtPassword: TLabeledEdit
Left = 16
Left = 21
Height = 26
Top = 200
Width = 304
Top = 454
Width = 400
EchoMode = emPassword
EditLabel.Height = 18
EditLabel.Width = 304
EditLabel.Width = 400
EditLabel.Caption = 'Senha'
EditLabel.ParentColor = False
PasswordChar = '*'
TabOrder = 3
end
object Label1: TLabel
Left = 16
Height = 18
Top = 12
Width = 59
Caption = 'ODBC DSN'
ParentColor = False
TabOrder = 8
end
object cbDialect: TComboBox
Left = 16
Left = 21
Height = 26
Top = 85
Width = 304
Top = 339
Width = 400
ItemHeight = 18
OnChange = cbODBCD_DSNChange
Style = csDropDownList
TabOrder = 1
TabOrder = 6
end
object Label2: TLabel
Left = 16
Left = 21
Height = 18
Top = 66
Top = 320
Width = 41
Caption = 'Dialeto'
ParentColor = False
end
object rbDSN: TRadioButton
Left = 21
Height = 22
Top = 24
Width = 107
Caption = 'Selecionar DSN'
Checked = True
OnClick = rbDSNClick
TabOrder = 0
TabStop = True
end
object rbPersonalizado: TRadioButton
Left = 21
Height = 22
Top = 96
Width = 100
Caption = 'Personalizado'
OnClick = rbPersonalizadoClick
TabOrder = 2
end
object cbODBCD_DRIVERS: TComboBox
Left = 40
Height = 26
Top = 128
Width = 384
Enabled = False
ItemHeight = 18
OnChange = cbODBCD_DSNChange
Style = csDropDownList
TabOrder = 3
end
object edtDatabaseName: TLabeledEdit
Left = 37
Height = 26
Top = 240
Width = 384
EditLabel.Height = 18
EditLabel.Width = 384
EditLabel.Caption = 'Nome do Banco de Dados'
EditLabel.ParentColor = False
Enabled = False
TabOrder = 5
end
object edtServerName: TLabeledEdit
Left = 37
Height = 26
Top = 184
Width = 384
EditLabel.Height = 18
EditLabel.Width = 384
EditLabel.Caption = 'Servidor'
EditLabel.ParentColor = False
Enabled = False
TabOrder = 4
end
object Bevel2: TBevel
Left = 21
Height = 8
Top = 296
Width = 400
Shape = bsTopLine
end
end
......@@ -15,19 +15,26 @@ type
TDataBaseLogin = class(TForm)
Bevel1: TBevel;
Bevel2: TBevel;
Button1: TButton;
Button2: TButton;
cbODBCD_DSN: TComboBox;
cbDialect: TComboBox;
Label1: TLabel;
cbODBCD_DRIVERS: TComboBox;
edtServerName: TLabeledEdit;
edtUsuario: TLabeledEdit;
edtPassword: TLabeledEdit;
edtDatabaseName: TLabeledEdit;
Label2: TLabel;
rbDSN: TRadioButton;
rbPersonalizado: TRadioButton;
procedure cbODBCD_DSNChange(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure rbDSNClick(Sender: TObject);
procedure rbPersonalizadoClick(Sender: TObject);
private
FProjectFileName: string;
procedure SetProjectFileName(const Value: string);
......@@ -57,6 +64,9 @@ begin
lReg.RootKey := HKEY_CURRENT_USER;
lReg.OpenKey(cPROJECT_SAVE_OPTIONS_PATH + ProjectFileName + '\Explorer', true);
lReg.WriteString('DEFAULT_DSN', cbODBCD_DSN.Caption);
lReg.WriteString('DEFAULT_DRIVER', cbODBCD_DRIVERS.Caption);
lReg.WriteString('DEFAULT_SERVER', edtServerName.Text);
lReg.WriteString('DEFAULT_DATABASE', edtServerName.Text);
lReg.WriteString('DEFAULT_DSN_USER', edtUsuario.Text);
lReg.WriteString('DEFAULT_SQL_DIALECT', cbDialect.Caption);
finally
......@@ -82,11 +92,12 @@ end;
procedure TDataBaseLogin.FormShow(Sender: TObject);
var lReg: TRegistry;
lDSN, lDialect: string;
lDSN, lDriver, lDialect: string;
lObj: acObject;
begin
GetSystemDSNList(cbODBCD_DSN.Items);
GetUserDSNList(cbODBCD_DSN.Items);
GetDriverList(cbODBCD_DRIVERS.Items);
for lObj in gSQLDialectManager.InstancedObjects do
begin
......@@ -100,7 +111,23 @@ begin
lReg.OpenKey(cPROJECT_SAVE_OPTIONS_PATH + ProjectFileName + '\Explorer', true);
lDSN := lReg.ReadString('DEFAULT_DSN');
if lDSN <> '' then cbODBCD_DSN.ItemIndex := cbODBCD_DSN.Items.IndexOf(lDSN);
if lDSN <> '' then
begin
rbDSN.Checked := True;
rbDSNClick(rbDSN);
cbODBCD_DSN.ItemIndex := cbODBCD_DSN.Items.IndexOf(lDSN);
end
else
begin
lDriver := lReg.ReadString('DEFAULT_DRIVER');
if lDriver <> '' then
begin
rbPersonalizado.Checked := True;
rbPersonalizadoClick(rbPersonalizado);
edtServerName.Text := lReg.ReadString('DEFAULT_SERVER');
edtDatabaseName.Text := lReg.ReadString('DEFAULT_DATABASE');
end;
end;
edtUsuario.Text := lReg.ReadString('DEFAULT_DSN_USER');
......@@ -114,6 +141,22 @@ begin
then edtPassword.SetFocus;
end;
procedure TDataBaseLogin.rbDSNClick(Sender: TObject);
begin
cbODBCD_DSN.Enabled := True;
cbODBCD_DRIVERS.Enabled := False;
edtDatabaseName.Enabled := False;
edtServerName.Enabled := False;
end;
procedure TDataBaseLogin.rbPersonalizadoClick(Sender: TObject);
begin
cbODBCD_DSN.Enabled := False;
cbODBCD_DRIVERS.Enabled := True;
edtDatabaseName.Enabled := True;
edtServerName.Enabled := True;
end;
procedure TDataBaseLogin.SetProjectFileName(const Value: string);
begin
FProjectFileName := Value;
......
......@@ -3,9 +3,9 @@ unit ituExplorerV2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Clipbrd, Dialogs, ExtCtrls, StdCtrls, ComCtrls, StdActns, ActnList, ToolWin,
LCLType, acuSQLDialectManager, ImgList, acuframework, DB,
LCLIntf, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Clipbrd, Dialogs, ExtCtrls, StdCtrls, ComCtrls, ActnList,
LCLType, acuSQLDialectManager, ImgList, acuframework,
IntegracaoDelphiSUML, acuObjectExplorer, Menus, Buttons, SynEdit,
SynHighlighterSQL, SynCompletion, acuModel, acuRepositorySQL;
......@@ -414,9 +414,22 @@ begin
lModalResult := lDataBaseLogin.ShowModal;
if lModalResult = mrok then
begin
fConnectionString := format('DSN=%s;UID=%s;PWD=%s',[lDataBaseLogin.cbODBCD_DSN.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.edtPassword.Text]);
fSQLDialect := lDataBaseLogin.cbDialect.Items.Objects[lDataBaseLogin.cbDialect.ItemIndex] as acAbstractSQLDialect;
sbDB.Panels[0].Text := Format('DSN: %s UID: %s Dialect: %s', [lDataBaseLogin.cbODBCD_DSN.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.cbDialect.Caption]);
if lDataBaseLogin.rbDSN.Checked then
begin
fConnectionString := format('DSN=%s;UID=%s;PWD=%s',[lDataBaseLogin.cbODBCD_DSN.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.edtPassword.Text]);
fSQLDialect := lDataBaseLogin.cbDialect.Items.Objects[lDataBaseLogin.cbDialect.ItemIndex] as acAbstractSQLDialect;
sbDB.Panels[0].Text := Format('DSN:%s UID:%s Dialect:%s', [lDataBaseLogin.cbODBCD_DSN.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.cbDialect.Caption]);
end
else
begin
if lDataBaseLogin.edtDatabaseName.Text <> ''
then fConnectionString := format('DRIVER=%s;Server=%s;Database=%s;UID=%s;PWD=%s',[lDataBaseLogin.cbODBCD_DRIVERS.Text, lDataBaseLogin.edtServerName.Text, lDataBaseLogin.edtDatabaseName.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.edtPassword.Text])
else fConnectionString := format('DRIVER=%s;Server=%s;Database=%s;UID=%s;PWD=%s',[lDataBaseLogin.cbODBCD_DRIVERS.Text, lDataBaseLogin.edtServerName.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.edtPassword.Text]);
fSQLDialect := lDataBaseLogin.cbDialect.Items.Objects[lDataBaseLogin.cbDialect.ItemIndex] as acAbstractSQLDialect;
if lDataBaseLogin.edtDatabaseName.Text <> ''
then sbDB.Panels[0].Text := Format('Server:%s Database:%s UID:%s Dialect:%s', [lDataBaseLogin.edtServerName.Text, lDataBaseLogin.edtDatabaseName.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.cbDialect.Caption])
else sbDB.Panels[0].Text := Format('Server:%s UID:%s Dialect:%s', [lDataBaseLogin.edtServerName.Text, lDataBaseLogin.edtUsuario.Text, lDataBaseLogin.cbDialect.Caption]);
end;
end
else exit;
end;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment