TvPlanIt: Deletion of a resource deletes also the associated events, contacts and tasks. Tested with all database datastores. Update datastore sample projects.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8947 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-10-10 22:24:46 +00:00
parent f54a1641df
commit f0d8344fee
19 changed files with 611 additions and 692 deletions

View File

@@ -6,7 +6,7 @@ interface
uses
SysUtils, Classes, DB,
VpBaseDS, VpDBDS,
VpData, VpBaseDS, VpDBDS,
ZCompatibility, ZConnection, ZDataset;
type
@@ -30,6 +30,9 @@ type
function GetEventsTable: TDataset; override;
function GetResourceTable: TDataset; override;
function GetTasksTable: TDataset; override;
procedure InternalPurgeContacts(Res: TVpResource); override;
procedure InternalPurgeEvents(Res: TVpResource); override;
procedure InternalPurgeTasks(Res: TVpResource); override;
procedure Loaded; override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetConnected(const AValue: Boolean); override;
@@ -507,6 +510,33 @@ begin
Result := FTasksTable;
end;
{ Removes all contacts of the specified resource from the database. }
procedure TVpZeosDataStore.InternalPurgeContacts(Res: TVpResource);
var
sql: String;
begin
sql := Format('DELETE FROM Contacts WHERE ResourceID = %d', [Res.ResourceID]);
FConnection.ExecuteDirect(sql);
end;
{ Removes all events of the specified resource from the database. }
procedure TVpZeosDatastore.InternalPurgeEvents(Res: TVpResource);
var
sql: String;
begin
sql := Format('DELETE FROM Events WHERE ResourceID = %d', [Res.ResourceID]);
FConnection.ExecuteDirect(sql);
end;
{ Removes all tasks of the specified resource from the database. }
procedure TVpZeosDatastore.InternalPurgeTasks(Res: TVpResource);
var
sql: String;
begin
sql := Format('DELETE FROM Tasks WHERE ResourceID = %d', [Res.ResourceID]);
FConnection.ExecuteDirect(sql);
end;
procedure TVpZeosDatastore.Loaded;
begin
inherited;