implementation
uses IniFiles,
FileCtrl;
const slniFileName:
String = 'ADODemo.ini';
sEmptyDefDB:
String = 'Database path is empty';
sEmptyFilter:
String = 'Records for filter is not selected';
{$R *.dfm}
procedure TfmMain.FormShow(Sender:
TObject);
begin
with TIniFile.Create(slniFileName)
do
try
DefDBStr :=
ReaDString('DefDB', 'DefDBStr1, ");
edDefDB.Text
:= DefDBStr;
finally
Free; end;
SetLength(Bookmarks,
0);
end;
procedure TfmMain.FormClose(Sender:
TObject; var Action: TCloseAction);
begin
with TIniFile.Create(slniFileName)
do
try
WriteStringCDefDB',
'DefDBStr', edDefDB.Text);
finally
Free ;
end;
end;
procedure TfmMain.sbDefDBClick(Sender:
TObject);
begin
if SelectDirectory(DefDBStr, [], 0)
then edDefDB.Text
:= DefDBStr;
end;
procedure TfmMain.tbConnectClick(Sender:
TObject);
begin
ADOConn.Close;
ADOConn.DefaultDatabase
:= ''; if DefDBStr = '' then
begin
MessageDlg(sEmptyDefDB,
mtError, [mbOK], 0);
Abort;
end
else
begin
ADOConn.DefaultDatabase
:= DefDBStr;
ADOConn.Open;
end;
end;
procedure TfmMain.tbSaveClick(Sender:
TObject);
begin
tbllndustry.UpdateBatch();
end;
procedure TfmMain.tbFilterClick(Sender:
TObject);
var i: Integer;
begin
if dbglndustry.SelectedRows.Count
> 0 then
begin
SetLength(Bookmarks,
dbglndustry.SelectedRows.Count);
for i
:= 0 to dbglndustry.SelectedRows.Count — 1 do
begin
Bookmarks[i].VType
:= vtPointer;
Bookmarks[i].VPointer
:= pointer(dbglndustry.SelectedRows[i]);
end;
tbllndustry.FilterOnBookmarks(Bookmarks);
end else
MessageDlgtsEmptyFilter,
mtWarning, [mbOK], 0);
end;
procedure TfmMain.tbUnFilterClick(Sender:
TObject);
begin
tbllndustry.Filtered
:= False;
dbglndustry.SelectedRows.Clear;
end;
procedure TfmMain.dbglndustryTitleClick(Column:
TColumn);
begin if tbllndustry.Active
then
if (Pos(Column.FieldName,
tbllndustry.Sort) > 0
}and(Pos('ASC',
tbllndustry.Sort) > 0)
then tbllndustry.Sort
:= Column.FieldName + ' DESC' else tbllndustry.Sort := Column.FieldName +
' ASC';
end;
procedure TfmMain.ADOConnAfterConnect(Sender:
TObject);
var i: Integer;
begin
for i := 0
to adoConn.DataSetCount - 1 do ADOConn.DataSets [i] .Open/end;
procedure TfmMain.ADOConnBeforeDisconnect(Sender:
TObject);
var i: Integer;
begin
for i := 0
to adoConn.DataSetCount — 1 do ADOConn.DataSets[i].Close;
end;
end.