2019-08-07 15:55:11 +00:00
|
|
|
{******************************************************************
|
|
|
|
|
|
|
|
JEDI-VCL Demo
|
|
|
|
|
|
|
|
Copyright (C) 2002 Project JEDI
|
|
|
|
|
|
|
|
Original author:
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
|
|
|
You may retrieve the latest version of this file at the JEDI-JVCL
|
|
|
|
home page, located at http://jvcl.delphi-jedi.org
|
|
|
|
|
|
|
|
The contents of this file are used with permission, 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/MPL-1_1Final.html
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
******************************************************************}
|
|
|
|
|
|
|
|
unit tfShare;
|
|
|
|
|
2019-08-07 17:29:39 +00:00
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
|
2019-08-07 15:55:11 +00:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2019-08-07 17:29:39 +00:00
|
|
|
SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
|
|
|
StdCtrls, Buttons, checklst, ButtonPanel;
|
2019-08-07 15:55:11 +00:00
|
|
|
|
|
|
|
type
|
2019-08-07 17:29:39 +00:00
|
|
|
|
|
|
|
{ TShare }
|
|
|
|
|
2019-08-07 15:55:11 +00:00
|
|
|
TShare = class(TForm)
|
2019-08-07 17:29:39 +00:00
|
|
|
ButtonPanel1: TButtonPanel;
|
2019-08-07 15:55:11 +00:00
|
|
|
ResourcesCheckList: TCheckListBox;
|
|
|
|
procedure FormShow(Sender: TObject);
|
|
|
|
procedure FormClose(Sender: TObject; var TheAction: TCloseAction);
|
|
|
|
private
|
|
|
|
{ Private declarations }
|
|
|
|
public
|
|
|
|
{ Public declarations }
|
|
|
|
end;
|
|
|
|
|
|
|
|
var
|
|
|
|
Share: TShare;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
tfMain, JvTFManager;
|
|
|
|
|
|
|
|
{$R *.lfm}
|
|
|
|
|
|
|
|
procedure TShare.FormShow(Sender: TObject);
|
|
|
|
var
|
|
|
|
Appt : TJvTFAppt;
|
|
|
|
I : Integer;
|
|
|
|
begin
|
|
|
|
// First, get the selected appointment
|
2019-08-07 17:29:39 +00:00
|
|
|
Appt := MainForm.JvTFDays1.SelAppt;
|
2019-08-07 15:55:11 +00:00
|
|
|
|
|
|
|
// now roll through the resource list and check all resources
|
|
|
|
// that are found in the appointment's list of schedules.
|
2019-08-07 17:29:39 +00:00
|
|
|
with ResourcesCheckList do
|
|
|
|
for I := 0 to Items.Count - 1 do
|
2019-08-07 15:55:11 +00:00
|
|
|
Checked[I] := Appt.IndexOfSchedule(Items[I]) > -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TShare.FormClose(Sender: TObject; var TheAction: TCloseAction);
|
|
|
|
var
|
|
|
|
TempList : TStringList;
|
|
|
|
I : Integer;
|
|
|
|
begin
|
|
|
|
If ModalResult = mrOK Then
|
|
|
|
Begin
|
|
|
|
// create and populate a temporary list of the selected resources
|
|
|
|
// from the checklistbox.
|
|
|
|
TempList := TStringList.Create;
|
|
|
|
Try
|
|
|
|
With ResourcesCheckList do
|
|
|
|
For I := 0 to Items.Count - 1 do
|
|
|
|
If Checked[I] Then
|
|
|
|
TempList.Add(Items[I]);
|
|
|
|
|
|
|
|
// Enforce a business rule where removing all resources from an
|
|
|
|
// appointment causes the appointment to be deleted.
|
|
|
|
// NOTE: This is NOT a requirement. Feel free to implement any
|
|
|
|
// business rules as you see fit.
|
|
|
|
If TempList.Count > 0 Then
|
|
|
|
// If at least one resource then change the appointment's
|
|
|
|
// schedule list to match the temp list.
|
2019-08-07 17:29:39 +00:00
|
|
|
MainForm.JvTFDays1.SelAppt.AssignSchedules(TempList)
|
2019-08-07 15:55:11 +00:00
|
|
|
Else
|
|
|
|
If MessageDlg('You have removed this appointment from all schedules.' +
|
|
|
|
' This will cause the appointment to be deleted.' + #13#10 +
|
|
|
|
'Are you sure this is what you want to do?',
|
|
|
|
mtConfirmation, [mbYes, mbNo], 0) = mrYes Then
|
2019-08-07 17:29:39 +00:00
|
|
|
With MainForm.JvTFDays1 do
|
2019-08-07 15:55:11 +00:00
|
|
|
// Delete the appointment if that is what the user wants to do.
|
|
|
|
ScheduleManager.dbDeleteAppt(SelAppt)
|
|
|
|
Else
|
|
|
|
TheAction := caNone;
|
|
|
|
|
|
|
|
Finally
|
|
|
|
TempList.Free;
|
|
|
|
End;
|
|
|
|
End;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|