You've already forked lazarus-ccr
tvplanit: Remove OnSetFilterCriteria handler from FlexDatastore examples (not needed any more).
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5035 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -76,10 +76,6 @@ Step-by-step instructions for creating a new application
|
|||||||
- In OnDestroy set
|
- In OnDestroy set
|
||||||
ODBCConnection.Connected := false
|
ODBCConnection.Connected := false
|
||||||
|
|
||||||
- Write an event handler for the datastore's OnSetFilterCriteria. Copy the
|
|
||||||
code used in the demo. In case of date-filtering it is important to use
|
|
||||||
the dbf syntax DTOS(dateField).
|
|
||||||
|
|
||||||
- Double-click on the VpFlexDatastore in Form1 to open the field mapper.
|
- Double-click on the VpFlexDatastore in Form1 to open the field mapper.
|
||||||
|
|
||||||
- Select "Resources" in the combobox. Click a database field in the left listbox
|
- Select "Resources" in the combobox. Click a database field in the left listbox
|
||||||
@ -98,6 +94,10 @@ Step-by-step instructions for creating a new application
|
|||||||
|
|
||||||
- Close the field mapper.
|
- Close the field mapper.
|
||||||
|
|
||||||
|
- After the field mappings have been established the absolute database path can
|
||||||
|
be removed from the Params of the ODBCConnection and replaced by a relative
|
||||||
|
path or can be set at runtime.
|
||||||
|
|
||||||
- Done.
|
- Done.
|
||||||
|
|
||||||
|
|
||||||
|
@ -367,7 +367,6 @@ object Form1: TForm1
|
|||||||
DataSources.ContactsDataSource = DsContacts
|
DataSources.ContactsDataSource = DsContacts
|
||||||
DataSources.TasksDataSource = DsTasks
|
DataSources.TasksDataSource = DsTasks
|
||||||
ResourceID = 0
|
ResourceID = 0
|
||||||
OnSetFilterCriteria = VpFlexDataStore1SetFilterCriteria
|
|
||||||
left = 136
|
left = 136
|
||||||
top = 101
|
top = 101
|
||||||
ResourceFieldMappings = (
|
ResourceFieldMappings = (
|
||||||
|
@ -65,9 +65,6 @@ type
|
|||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure PageControl1Change(Sender: TObject);
|
procedure PageControl1Change(Sender: TObject);
|
||||||
procedure TabControl1Change(Sender: TObject);
|
procedure TabControl1Change(Sender: TObject);
|
||||||
procedure VpFlexDataStore1SetFilterCriteria(aTable: TDataset;
|
|
||||||
aUseDateTime: Boolean; aResourceID: Integer; aStartDateTime,
|
|
||||||
aEndDateTime: TDateTime);
|
|
||||||
private
|
private
|
||||||
{ private declarations }
|
{ private declarations }
|
||||||
public
|
public
|
||||||
@ -177,31 +174,5 @@ begin
|
|||||||
Grid.Columns[i].Width := 100;;
|
Grid.Columns[i].Width := 100;;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ This event handler is used by the planner to filter those records from the
|
|
||||||
specified table which belong to the requested resource ID and are within
|
|
||||||
the requested time interval.
|
|
||||||
Note that SQLDB uses the DBF syntax for filtering dates, i.e.
|
|
||||||
- Convert DateTime field values to strings using DTOS()
|
|
||||||
- Date parameters must be formatted as yyyymmdd and quoted.
|
|
||||||
See: http://forum.lazarus.freepascal.org/index.php?topic=23077.0 }
|
|
||||||
procedure TForm1.VpFlexDataStore1SetFilterCriteria(ATable: TDataset;
|
|
||||||
AUseDateTime: Boolean; AResourceID: Integer; AStartDateTime,
|
|
||||||
AEndDateTime: TDateTime);
|
|
||||||
begin
|
|
||||||
if AUseDateTime then
|
|
||||||
ATable.Filter := Format(
|
|
||||||
'(ResourceID = %d) AND (' +
|
|
||||||
'((DTOS(StartTime) >= "%s") and (DTOS(EndTime) <= "%s")) OR ' +
|
|
||||||
'((RepeatCode > 0) and (DTOS(RepeatRangeEnd) >= "%s")) )', [
|
|
||||||
AResourceID,
|
|
||||||
FormatDateTime('yyyymmdd', AStartDateTime),
|
|
||||||
FormatDateTime('yyyymmdd', AEndDateTime),
|
|
||||||
FormatDateTime('yyyymmdd', AStartDateTime)
|
|
||||||
])
|
|
||||||
else
|
|
||||||
ATable.Filter := Format('ResourceID = %d', [AResourceID]);
|
|
||||||
ATable.Filtered := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -307,7 +307,6 @@ object Form1: TForm1
|
|||||||
DataSources.ContactsDataSource = DsContacts
|
DataSources.ContactsDataSource = DsContacts
|
||||||
DataSources.TasksDataSource = DsTasks
|
DataSources.TasksDataSource = DsTasks
|
||||||
ResourceID = 0
|
ResourceID = 0
|
||||||
OnSetFilterCriteria = VpFlexDataStore1SetFilterCriteria
|
|
||||||
left = 136
|
left = 136
|
||||||
top = 101
|
top = 101
|
||||||
ResourceFieldMappings = (
|
ResourceFieldMappings = (
|
||||||
|
@ -51,9 +51,6 @@ type
|
|||||||
procedure Button1Click(Sender: TObject);
|
procedure Button1Click(Sender: TObject);
|
||||||
procedure FormCreate(Sender: TObject);
|
procedure FormCreate(Sender: TObject);
|
||||||
procedure FormDestroy(Sender: TObject);
|
procedure FormDestroy(Sender: TObject);
|
||||||
procedure VpFlexDataStore1SetFilterCriteria(aTable: TDataset;
|
|
||||||
aUseDateTime: Boolean; aResourceID: Integer; aStartDateTime,
|
|
||||||
aEndDateTime: TDateTime);
|
|
||||||
private
|
private
|
||||||
procedure CreateContacts;
|
procedure CreateContacts;
|
||||||
procedure CreateDB(AFileName: String);
|
procedure CreateDB(AFileName: String);
|
||||||
@ -298,31 +295,5 @@ begin
|
|||||||
Sqlite3Connection1.Connected := false;
|
Sqlite3Connection1.Connected := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ This event handler is used by the planner to filter those records from the
|
|
||||||
specified table which belong to the requested resource ID and are within
|
|
||||||
the requested time interval.
|
|
||||||
Note that SQLDB uses the DBF syntax for filtering dates, i.e.
|
|
||||||
- Convert DateTime field values to strings using DTOS()
|
|
||||||
- Date parameters must be quoted and formatted as "yyyymmdd".
|
|
||||||
See: http://forum.lazarus.freepascal.org/index.php?topic=23077.0 }
|
|
||||||
procedure TForm1.VpFlexDataStore1SetFilterCriteria(ATable: TDataset;
|
|
||||||
AUseDateTime: Boolean; AResourceID: Integer; AStartDateTime,
|
|
||||||
AEndDateTime: TDateTime);
|
|
||||||
begin
|
|
||||||
if AUseDateTime then
|
|
||||||
ATable.Filter := Format(
|
|
||||||
'(ResourceID = %d) AND (' +
|
|
||||||
'((DTOS(StartTime) >= "%s") and (DTOS(EndTime) <= "%s")) OR ' +
|
|
||||||
'((RepeatCode > 0) and (DTOS(RepeatRangeEnd) >= "%s")) )', [
|
|
||||||
AResourceID,
|
|
||||||
FormatDateTime('yyyymmdd', AStartDateTime),
|
|
||||||
FormatDateTime('yyyymmdd', AEndDateTime),
|
|
||||||
FormatDateTime('yyyymmdd', AStartDateTime)
|
|
||||||
])
|
|
||||||
else
|
|
||||||
ATable.Filter := Format('ResourceID = %d', [AResourceID]);
|
|
||||||
ATable.Filtered := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user