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