2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPTASKEDITDLG.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (the "License"); you may not use this file except in *}
|
|
|
|
{* compliance with the License. You may obtain a copy of the License at *}
|
|
|
|
{* http://www.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
2016-06-07 15:09:01 +00:00
|
|
|
{$I vp.inc}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
unit VpTaskEditDlg;
|
|
|
|
{ default task editing dialog }
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-07 16:34:18 +00:00
|
|
|
LMessages, LCLProc, LCLType, LCLIntf, LResources,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
|
|
|
Windows,
|
|
|
|
{$ENDIF}
|
|
|
|
Messages, SysUtils,
|
|
|
|
{$IFDEF VERSION6} Variants, {$ENDIF}
|
|
|
|
Classes, Graphics, Controls, Forms, Dialogs, VpData, StdCtrls, ExtCtrls,
|
2016-06-09 15:25:29 +00:00
|
|
|
VpEdPop, VpDateEdit, VpBase, VpSR, VpDlg, ComCtrls, EditBtn;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
{ forward declarations }
|
|
|
|
TVpTaskEditDialog = class;
|
|
|
|
|
2016-06-09 15:25:29 +00:00
|
|
|
{ TTaskEditForm }
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
TTaskEditForm = class(TForm)
|
|
|
|
Panel2: TPanel;
|
|
|
|
OKBtn: TButton;
|
|
|
|
CancelBtn: TButton;
|
|
|
|
PageControl1: TPageControl;
|
|
|
|
tabTask: TTabSheet;
|
|
|
|
DescriptionEdit: TEdit;
|
|
|
|
DueDateLbl: TLabel;
|
2016-06-09 15:25:29 +00:00
|
|
|
DueDateEdit: TDateEdit;
|
2008-02-03 12:05:55 +00:00
|
|
|
CompleteCB: TCheckBox;
|
|
|
|
CreatedOnLbl: TLabel;
|
|
|
|
CompletedOnLbl: TLabel;
|
|
|
|
DetailsMemo: TMemo;
|
|
|
|
ResourceNameLbl: TLabel;
|
|
|
|
Bevel1: TBevel;
|
|
|
|
Bevel2: TBevel;
|
|
|
|
imgCalendar: TImage;
|
|
|
|
imgCompleted: TImage;
|
|
|
|
procedure FormCreate(Sender: TObject);
|
|
|
|
procedure OnChange(Sender: TObject);
|
|
|
|
procedure OKBtnClick(Sender: TObject);
|
|
|
|
procedure CancelBtnClick(Sender: TObject);
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
private
|
|
|
|
FReturnCode: TVpEditorReturnCode;
|
|
|
|
FTask: TVpTask;
|
|
|
|
FResource: TVpResource;
|
|
|
|
public
|
|
|
|
procedure PopulateSelf;
|
|
|
|
procedure DePopulateSelf;
|
|
|
|
property Task: TVpTask
|
|
|
|
read FTask write FTask;
|
|
|
|
property Resource: TVpResource
|
|
|
|
read FResource write FResource;
|
|
|
|
property ReturnCode: TVpEditorReturnCode
|
|
|
|
read FReturnCode;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TVpTaskEditDialog = class(TVpBaseDialog)
|
|
|
|
protected {private}
|
2016-06-18 21:03:53 +00:00
|
|
|
teEditDlg: TTaskEditForm;
|
|
|
|
teTask: TVpTask;
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
2016-06-18 21:03:53 +00:00
|
|
|
constructor Create(AOwner: TComponent); override;
|
2008-02-03 12:05:55 +00:00
|
|
|
function Execute(Task: TVpTask): Boolean; reintroduce;
|
|
|
|
function AddNewTask: Boolean;
|
|
|
|
published
|
|
|
|
{properties}
|
|
|
|
property DataStore;
|
|
|
|
property Options;
|
|
|
|
property Placement;
|
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2016-06-10 16:12:14 +00:00
|
|
|
uses
|
|
|
|
VpMisc;
|
|
|
|
|
2016-06-07 16:34:18 +00:00
|
|
|
{$IFDEF LCL}
|
|
|
|
{$R *.lfm}
|
2016-06-07 15:09:01 +00:00
|
|
|
{$ELSE}
|
2016-06-07 16:34:18 +00:00
|
|
|
{$R *.dfm}
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
|
|
|
|
|
|
|
{ TTaskEditForm }
|
|
|
|
|
|
|
|
procedure TTaskEditForm.FormCreate(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FReturnCode := rtAbandon;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TTaskEditForm.DePopulateSelf;
|
|
|
|
begin
|
|
|
|
Task.Description := DescriptionEdit.Text;
|
|
|
|
Task.DueDate := DueDateEdit.Date;
|
|
|
|
Task.Details := DetailsMemo.Text;
|
|
|
|
Task.Complete := CompleteCB.Checked;
|
|
|
|
DueDateLbl.Caption := RSDueDate;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TTaskEditForm.PopulateSelf;
|
|
|
|
begin
|
|
|
|
ResourceNameLbl.Caption := Resource.Description;
|
2016-06-10 16:12:14 +00:00
|
|
|
CompleteCB.Caption := RSTaskComplete;
|
2008-02-03 12:05:55 +00:00
|
|
|
DueDateLbl.Caption := RSDueDate;
|
|
|
|
OKBtn.Caption := RSOKBtn;
|
|
|
|
CancelBtn.Caption := RSCancelBtn;
|
|
|
|
|
|
|
|
DescriptionEdit.Text := Task.Description;
|
|
|
|
DueDateEdit.Date := Task.DueDate;
|
|
|
|
DetailsMemo.Text := Task.Details;
|
|
|
|
CompleteCB.Checked := Task.Complete;
|
|
|
|
if Task.CompletedOn <> 0 then
|
2016-06-18 21:03:53 +00:00
|
|
|
CompletedOnLbl.Caption := RSCompletedOn + ' ' + FormatDateTime(ShortDateFormat, Task.CompletedOn)
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
|
|
|
CompletedOnLbl.Visible := False;
|
|
|
|
CompletedOnLbl.Visible := CompleteCB.Checked;
|
2016-06-18 21:03:53 +00:00
|
|
|
CreatedOnLbl.Caption := RSCreatedOn + ' ' + FormatDateTime(ShortDateFormat, Task.CreatedOn);
|
2016-06-10 16:12:14 +00:00
|
|
|
|
|
|
|
DueDateEdit.Left := DueDateLbl.Left + GetLabelWidth(DueDateLbl) + 8;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TTaskEditForm.OnChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Task.Changed := true;
|
|
|
|
end;
|
2016-06-09 23:49:35 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TTaskEditForm.OKBtnClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FReturnCode := rtCommit;
|
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TTaskEditForm.CancelBtnClick(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Close;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
procedure TTaskEditForm.FormShow(Sender: TObject);
|
|
|
|
begin
|
|
|
|
DescriptionEdit.SetFocus;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
{ TVpTaskEditDialog }
|
|
|
|
|
|
|
|
constructor TVpTaskEditDialog.Create(AOwner : TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
2016-06-18 21:03:53 +00:00
|
|
|
FPlacement.Height := 340;
|
|
|
|
FPlacement.Width := 545;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpTaskEditDialog.Execute(Task: TVpTask): Boolean;
|
|
|
|
var
|
|
|
|
TaskEditForm: TTaskEditForm;
|
|
|
|
begin
|
|
|
|
Result := false;
|
|
|
|
teTask := Task;
|
2016-06-18 21:03:53 +00:00
|
|
|
if (teTask <> nil) and (DataStore <> nil) and (DataStore.Resource <> nil) then
|
|
|
|
begin
|
2008-02-03 12:05:55 +00:00
|
|
|
Application.CreateForm(TTaskEditForm, TaskEditForm);
|
|
|
|
try
|
|
|
|
DoFormPlacement(TaskEditForm);
|
|
|
|
SetFormCaption(TaskEditForm, Task.Description, RSDlgTaskEdit);
|
|
|
|
TaskEditForm.Task := Task;
|
|
|
|
TaskEditForm.Resource := DataStore.Resource;
|
|
|
|
TaskEditForm.PopulateSelf;
|
|
|
|
TaskEditForm.ShowModal;
|
|
|
|
Result := (TaskEditForm.ReturnCode = rtCommit);
|
|
|
|
Task.Changed := Result;
|
|
|
|
if Result then begin
|
|
|
|
TaskEditForm.DePopulateSelf;
|
2016-06-18 19:45:43 +00:00
|
|
|
// DataStore.PostTasks;
|
|
|
|
// DataStore.NotifyDependents;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
finally
|
|
|
|
TaskEditForm.Release;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
|
|
|
|
|
|
|
function TVpTaskEditDialog.AddNewTask: Boolean;
|
|
|
|
begin
|
|
|
|
result := false;
|
|
|
|
if DataStore <> nil then begin
|
|
|
|
teTask := DataStore.Resource.Tasks.AddTask(DataStore.GetNextID('Tasks'));
|
|
|
|
if teTask <> nil then begin
|
|
|
|
Result := Execute(teTask);
|
|
|
|
if not Result then
|
|
|
|
teTask.Free;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
{=====}
|
2016-06-07 16:34:18 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
end.
|
|
|
|
|