tvplanit: Add datastore method DeleteResource.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8351 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2022-07-16 16:38:36 +00:00
parent 6b91b30c26
commit beb0481d33
5 changed files with 51 additions and 5 deletions

View File

@ -23,7 +23,7 @@ object Form1: TForm1
AnchorSideLeft.Control = Panel1
Left = 4
Height = 23
Top = 5
Top = 4
Width = 208
DataStore = VpIniDatastore1
Style = csDropDownList
@ -61,6 +61,19 @@ object Form1: TForm1
OnClick = BtnEditResClick
TabOrder = 2
end
object BtnDeleteRes: TButton
AnchorSideLeft.Control = BtnEditRes
AnchorSideLeft.Side = asrBottom
Left = 416
Height = 25
Top = 4
Width = 107
AutoSize = True
BorderSpacing.Left = 4
Caption = 'Delete resource'
OnClick = BtnDeleteResClick
TabOrder = 3
end
end
object PageControl1: TPageControl
Left = 0

View File

@ -17,6 +17,7 @@ type
TForm1 = class(TForm)
BtnNewRes: TButton;
BtnEditRes: TButton;
BtnDeleteRes: TButton;
PageControl1: TPageControl;
Panel1: TPanel;
Panel2: TPanel;
@ -36,6 +37,7 @@ type
VpResourceEditDialog1: TVpResourceEditDialog;
VpTaskList1: TVpTaskList;
VpWeekView1: TVpWeekView;
procedure BtnDeleteResClick(Sender: TObject);
procedure BtnNewResClick(Sender: TObject);
procedure BtnEditResClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
@ -65,6 +67,22 @@ begin
VpResourceEditDialog1.AddNewResource;
end;
procedure TForm1.BtnDeleteResClick(Sender: TObject);
var
res: TVpResource;
begin
res := VpControlLink1.Datastore.Resource;
if res = nil then
exit;
if MessageDlg('Do you really want to delete the resource "' + res.Description + '"?',
mtConfirmation, [mbYes, mbNo], 0) <> mrYes
then
exit;
VpControlLink1.Datastore.DeleteResource(res);
end;
// Edits the currently selected resource
procedure TForm1.BtnEditResClick(Sender: TObject);
begin

View File

@ -4,11 +4,12 @@ object MainForm: TMainForm
Top = 134
Width = 959
Caption = 'Turbo Power VisualPlanIt Demo'
ClientHeight = 596
ClientHeight = 576
ClientWidth = 959
Menu = MainMenu1
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
LCLVersion = '2.3.0.0'
object Panel1: TPanel
Left = 125
Height = 596
@ -58,7 +59,7 @@ object MainForm: TMainForm
Height = 548
Top = 48
Width = 834
PageIndex = 4
PageIndex = 0
Align = alClient
TabOrder = 1
TabStop = True

View File

@ -363,7 +363,7 @@ begin
if MessageDlg(Format(RSConfirmDeleteRes, [res.Description]), mtConfirmation, [mbYes, mbNo], 0) = mrYes then
begin
VpControlLink1.Datastore.PurgeResource(res);
VpControlLink1.Datastore.DeleteResource(res);
UpdateOtherResourcesList;
end;
end;