unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, DBTables, Buttons, dxCntner, dxEditor,
dxEdLib;
type
TMainForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Bevel1: TBevel;
Session1: TSession;
EditStyleController: TdxEditStyleController;
DatabaseNameEdit: TdxEdit;
HostNameEdit: TdxEdit;
ChashEdit: TdxEdit;
ServerNameEdit: TdxEdit;
SQLTypeEdit: TdxEdit;
UserNameEdit: TdxEdit;
DeaultSpeedButton: TSpeedButton;
ApplySpeedButton: TSpeedButton;
SaveSpeedButton: TSpeedButton;
CloseSpeedButton: TSpeedButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure CloseSpeedButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure DeaultSpeedButtonClick(Sender: TObject);
procedure SaveSpeedButtonClick(Sender: TObject);
procedure ApplySpeedButtonClick(Sender: TObject);
procedure HostNameEditChange(Sender: TObject);
private
MyList:TStringList;
BDEInfoList:TStringList;
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.FormCreate(Sender: TObject);
begin
MyList:=TStringList.Create;
BDEInfoList:=TStringList.Create;
end;
procedure TMainForm.FormDestroy(Sender: TObject);
begin
MyList.Free;
BDEInfoList.Free;
end;
procedure TMainForm.CloseSpeedButtonClick(Sender: TObject);
begin
MainForm.Close;
end;
procedure TMainForm.FormShow(Sender: TObject);
begin
try
Session1.GetAliasParams('DrugStore',BDEInfoList);
finally
DatabaseNameEdit.Text:=BDEInfoList.Values['DATABASE NAME'];
HostNameEdit.Text:=BDEInfoList.Values['HOST NAME'];
ChashEdit.Text:=BDEInfoList.Values['SCHEMA CACHE DIR'];
ServerNameEdit.Text:=BDEInfoList.Values['SERVER NAME'];
SQLTypeEdit.Text:=BDEInfoList.Values['SQLQRYMODE'];
UserNameEdit.Text:=BDEInfoList.Values['USER NAME'];
end;
end;
procedure TMainForm.DeaultSpeedButtonClick(Sender: TObject);
begin
DatabaseNameEdit.Text:='DrugStore';
HostNameEdit.Text:='server';
ChashEdit.Text:='C:/Program Files/Common Files/Borland Shared/BDE';
ServerNameEdit.Text:='server';
SQLTypeEdit.Text:='server';
UserNameEdit.Text:='sa';
end;
procedure TMainForm.SaveSpeedButtonClick(Sender: TObject);
begin
SaveSpeedButton.Enabled:=False;
Session1.SaveConfigFile;
end;
procedure TMainForm.ApplySpeedButtonClick(Sender: TObject);
begin
ApplySpeedButton.Enabled:=False;
try
Session1.DeleteAlias('DrugStore');
finally
try
with MyList do
begin
Clear;
Add('DATABASE NAME='+DatabaseNameEdit.Text);
Add('HOST NAME='+HostNameEdit.Text);
Add('SCHEMA CACHE DIR='+ChashEdit.Text);
Add('SERVER NAME='+ServerNameEdit.Text);
Add('SQLQRYMODE='+SQLTypeEdit.Text);
Add('USER NAME='+UserNameEdit.Text);
end;
Session1.AddAlias('DrugStore','MSSQL',MyList);
Session1.Active:=True;
finally
end;
end;
SaveSpeedButton.Enabled:=True;
end;
procedure TMainForm.HostNameEditChange(Sender: TObject);
begin
if ApplySpeedButton.Enabled then exit;
ApplySpeedButton.Enabled:=True;
end;
end.