RxDBGrid - Find Next now working

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2685 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
alexs75
2013-02-15 06:46:24 +00:00
parent 966669d138
commit 40cb0c1012
4 changed files with 110 additions and 54 deletions

View File

@ -48,6 +48,9 @@ const
StringTypes = [ftString, {ftMemo,} ftFixedChar, ftWideString, ftFixedWideChar, ftWideMemo]; StringTypes = [ftString, {ftMemo,} ftFixedChar, ftWideString, ftFixedWideChar, ftWideMemo];
type
TRxSearchDirection = (rsdAll, rsdForward, rsdBackward);
type type
{ TLocateObject } { TLocateObject }
@ -107,7 +110,8 @@ procedure InternalRestoreFields(DataSet: TDataSet; IniFile: TObject;
const Section: string; RestoreVisible: Boolean);} const Section: string; RestoreVisible: Boolean);}
function DataSetLocateThrough(DataSet: TDataSet; const KeyFields: string; function DataSetLocateThrough(DataSet: TDataSet; const KeyFields: string;
const KeyValues: Variant; Options: TLocateOptions): Boolean; const KeyValues: Variant; Options: TLocateOptions; SearchOrigin:TRxSearchDirection = rsdAll): Boolean;
procedure SaveFieldsReg(DataSet: TDataSet; IniFile: TRegIniFile); procedure SaveFieldsReg(DataSet: TDataSet; IniFile: TRegIniFile);
procedure RestoreFieldsReg(DataSet: TDataSet; IniFile: TRegIniFile; procedure RestoreFieldsReg(DataSet: TDataSet; IniFile: TRegIniFile;
RestoreVisible: Boolean); RestoreVisible: Boolean);
@ -379,7 +383,7 @@ end;
{ DataSet locate routines } { DataSet locate routines }
function DataSetLocateThrough(DataSet: TDataSet; const KeyFields: string; function DataSetLocateThrough(DataSet: TDataSet; const KeyFields: string;
const KeyValues: Variant; Options: TLocateOptions): Boolean; const KeyValues: Variant; Options: TLocateOptions; SearchOrigin:TRxSearchDirection = rsdAll): Boolean;
var var
FieldCount: Integer; FieldCount: Integer;
Fields: TList; Fields: TList;
@ -430,20 +434,40 @@ begin
try try
DataSet.GetFieldList(Fields, KeyFields); DataSet.GetFieldList(Fields, KeyFields);
FieldCount := Fields.Count; FieldCount := Fields.Count;
Result := CompareRecord;
if Result then Exit; if SearchOrigin = rsdAll then
begin
Result := CompareRecord;
if Result then Exit;
end;
DataSet.DisableControls; DataSet.DisableControls;
try try
Bookmark := DataSet.GetBookmark; Bookmark := DataSet.GetBookmark;
try try
with DataSet do begin if SearchOrigin in [rsdAll, rsdForward] then
First; begin
while not EOF do begin if SearchOrigin = rsdAll then
DataSet.First;
while not DataSet.EOF do
begin
Result := CompareRecord; Result := CompareRecord;
if Result then Break; if Result then Break;
Next; DataSet.Next;
end;
end
else
if SearchOrigin = rsdBackward then
begin
//DataSet.Last;
while not DataSet.BOF do
begin
Result := CompareRecord;
if Result then Break;
DataSet.Prior;
end; end;
end; end;
finally finally
{$IFDEF NoAutomatedBookmark} {$IFDEF NoAutomatedBookmark}
if not Result and DataSet.BookmarkValid(PChar(Bookmark)) then if not Result and DataSet.BookmarkValid(PChar(Bookmark)) then

View File

@ -1,7 +1,7 @@
object rxDBGridFindForm: TrxDBGridFindForm object rxDBGridFindForm: TrxDBGridFindForm
Left = 969 Left = 688
Height = 225 Height = 225
Top = 314 Top = 327
Width = 493 Width = 493
ActiveControl = Edit1 ActiveControl = Edit1
Caption = 'Find' Caption = 'Find'
@ -19,7 +19,7 @@ object rxDBGridFindForm: TrxDBGridFindForm
Left = 6 Left = 6
Height = 15 Height = 15
Top = 6 Top = 6
Width = 66 Width = 69
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Text to find' Caption = 'Text to find'
FocusControl = Edit1 FocusControl = Edit1
@ -34,7 +34,7 @@ object rxDBGridFindForm: TrxDBGridFindForm
Left = 6 Left = 6
Height = 15 Height = 15
Top = 58 Top = 58
Width = 68 Width = 73
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Find at filed' Caption = 'Find at filed'
ParentColor = False ParentColor = False
@ -44,9 +44,9 @@ object rxDBGridFindForm: TrxDBGridFindForm
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 347 Left = 347
Height = 35 Height = 33
Top = 184 Top = 186
Width = 79 Width = 81
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -54,7 +54,7 @@ object rxDBGridFindForm: TrxDBGridFindForm
Caption = 'Find more' Caption = 'Find more'
Default = True Default = True
OnClick = BtnFindClick OnClick = BtnFindClick
TabOrder = 4 TabOrder = 2
end end
object Button2: TButton object Button2: TButton
AnchorSideTop.Control = BtnFind AnchorSideTop.Control = BtnFind
@ -63,10 +63,10 @@ object rxDBGridFindForm: TrxDBGridFindForm
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 432 Left = 434
Height = 35 Height = 33
Top = 184 Top = 186
Width = 55 Width = 53
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Top = 8 BorderSpacing.Top = 8
@ -75,7 +75,7 @@ object rxDBGridFindForm: TrxDBGridFindForm
Cancel = True Cancel = True
Caption = 'Close' Caption = 'Close'
OnClick = Button2Click OnClick = Button2Click
TabOrder = 5 TabOrder = 3
end end
object Edit1: TEdit object Edit1: TEdit
AnchorSideLeft.Control = ComboBox1 AnchorSideLeft.Control = ComboBox1
@ -98,7 +98,7 @@ object rxDBGridFindForm: TrxDBGridFindForm
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 12 Left = 12
Height = 29 Height = 27
Top = 79 Top = 79
Width = 475 Width = 475
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
@ -107,33 +107,25 @@ object rxDBGridFindForm: TrxDBGridFindForm
Style = csDropDownList Style = csDropDownList
TabOrder = 1 TabOrder = 1
end end
object CheckBox1: TCheckBox
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 114
Width = 118
BorderSpacing.Around = 6
Caption = 'Case sensetive'
TabOrder = 2
end
object RadioGroup1: TRadioGroup object RadioGroup1: TRadioGroup
AnchorSideLeft.Control = CheckBox1 AnchorSideLeft.Control = Panel1
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = ComboBox1 AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 130 AnchorSideBottom.Control = Panel1
Height = 51 AnchorSideBottom.Side = asrBottom
Top = 114 Left = 146
Width = 357 Height = 62
Anchors = [akTop, akLeft, akRight] Top = 112
Width = 341
Anchors = [akTop, akLeft, akRight, akBottom]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6
BorderSpacing.Right = 6
Caption = 'Direction' Caption = 'Direction'
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
ChildSizing.TopBottomSpacing = 6 ChildSizing.TopBottomSpacing = 6
@ -143,27 +135,51 @@ object rxDBGridFindForm: TrxDBGridFindForm
ChildSizing.ShrinkVertical = crsScaleChilds ChildSizing.ShrinkVertical = crsScaleChilds
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3 ChildSizing.ControlsPerLine = 3
ClientHeight = 34 ClientHeight = 45
ClientWidth = 353 ClientWidth = 337
Columns = 3 Columns = 3
Items.Strings = ( Items.Strings = (
'All' 'All'
'Forward' 'Forward'
'Backward' 'Backward'
) )
TabOrder = 6 TabOrder = 4
Visible = False
end end
object CheckBox2: TCheckBox object Panel1: TPanel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = CheckBox1 AnchorSideTop.Control = ComboBox1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 6 Left = 6
Height = 22 Height = 62
Top = 142 Top = 112
Width = 84 Width = 134
AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Partial key' ClientHeight = 62
TabOrder = 3 ClientWidth = 134
TabOrder = 5
object CheckBox2: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = CheckBox1
AnchorSideTop.Side = asrBottom
Left = 7
Height = 21
Top = 34
Width = 88
BorderSpacing.Around = 6
Caption = 'Partial key'
TabOrder = 0
end
object CheckBox1: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
Left = 7
Height = 21
Top = 7
Width = 120
BorderSpacing.Around = 6
Caption = 'Case sensetive'
TabOrder = 1
end
end end
end end

View File

@ -52,6 +52,7 @@ type
Edit1: TEdit; Edit1: TEdit;
Label1: TLabel; Label1: TLabel;
Label2: TLabel; Label2: TLabel;
Panel1: TPanel;
RadioGroup1: TRadioGroup; RadioGroup1: TRadioGroup;
procedure BtnFindClick(Sender: TObject); procedure BtnFindClick(Sender: TObject);
procedure Button2Click(Sender: TObject); procedure Button2Click(Sender: TObject);
@ -103,6 +104,8 @@ begin
RadioGroup1.Items.Add(sRxDbGridFindRangeBack); RadioGroup1.Items.Add(sRxDbGridFindRangeBack);
BtnFind.Caption:=sRxFindMore; BtnFind.Caption:=sRxFindMore;
Button2.Caption:=rsMbClose; Button2.Caption:=rsMbClose;
RadioGroup1.ItemIndex:=0;
end; end;
procedure TrxDBGridFindForm.FormShow(Sender: TObject); procedure TrxDBGridFindForm.FormShow(Sender: TObject);
@ -114,6 +117,9 @@ procedure TrxDBGridFindForm.BtnFindClick(Sender: TObject);
var var
FieldName:string; FieldName:string;
LOptions: TLocateOptions; LOptions: TLocateOptions;
SearchOrigin:TRxSearchDirection;
P:TBookMark;
R:boolean;
begin begin
if Edit1.Text<>'' then if Edit1.Text<>'' then
begin begin
@ -125,8 +131,18 @@ begin
if CheckBox2.Checked then if CheckBox2.Checked then
LOptions:=LOptions+[loPartialKey]; LOptions:=LOptions+[loPartialKey];
DataSetLocateThrough(FDataSet, FieldName, Edit1.Text, LOptions);
SearchOrigin:=TRxSearchDirection(RadioGroup1.ItemIndex);
P:=FDataSet.Bookmark;
if SearchOrigin = rsdForward then
FDataSet.Next
else
if SearchOrigin = rsdBackward then
FDataSet.Prior;
R:=DataSetLocateThrough(FDataSet, FieldName, Edit1.Text, LOptions, SearchOrigin);
finally finally
if not R then
FDataSet.Bookmark:=P;
end; end;
end; end;
end; end;

View File

@ -26,7 +26,7 @@ Copyright (c) 1998 Master-Bank
translate to Lazarus by alexs in 2005 - 2012 translate to Lazarus by alexs in 2005 - 2012
"/> "/>
<License Value="LGPL"/> <License Value="LGPL"/>
<Version Major="2" Minor="4" Release="2" Build="120"/> <Version Major="2" Minor="4" Release="5" Build="130"/>
<Files Count="67"> <Files Count="67">
<Item1> <Item1>
<Filename Value="autopanel.pas"/> <Filename Value="autopanel.pas"/>