tvplanit: Cosmetic format changes in units vpbase and vpflxds

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4727 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2016-06-12 13:51:29 +00:00
parent 8b2fe7e075
commit 3fe2442f42
2 changed files with 241 additions and 293 deletions

View File

@ -96,7 +96,6 @@ type
TVpGetEditorCaption = procedure(var Caption : string) of object; TVpGetEditorCaption = procedure(var Caption : string) of object;
{ XML exceptions } { XML exceptions }
EXML = class (Exception); EXML = class (Exception);
@ -104,45 +103,38 @@ type
private private
seFilePos : Longint; seFilePos : Longint;
public public
constructor CreateError(const FilePos : Longint; constructor CreateError(const FilePos: Longint; const Reason: DOMString);
const Reason : DOMString); property FilePos: Longint
property FilePos : Longint
read seFilePos; read seFilePos;
end; end;
EVpFilterError = class(EVpStreamError) EVpFilterError = class(EVpStreamError)
private private
feReason : DOMString; feReason: DOMString;
feLine : Longint; feLine: Longint;
feLinePos : Longint; feLinePos: Longint;
public public
constructor CreateError(const FilePos, Line, LinePos : Longint; constructor CreateError(const FilePos, Line, LinePos: Longint; const Reason: DOMString);
const Reason : DOMString); property Reason : DOMString read feReason;
property Reason : DOMString property Line : Longint read feLine;
read feReason; property LinePos : Longint read feLinePos;
property Line : Longint
read feLine;
property LinePos : Longint
read feLinePos;
end; end;
EVpParserError = class(EVpFilterError) EVpParserError = class(EVpFilterError)
protected
public public
constructor CreateError(Line, LinePos : Longint; constructor CreateError(Line, LinePos: Longint; const Reason: DOMString);
const Reason : DOMString);
end; end;
{ implements the Version property with its associated design time About box } { implements the Version property with its associated design time About box }
TVpComponent = class(TComponent) TVpComponent = class(TComponent)
protected { private } protected { private }
function GetVersion : string; function GetVersion: string;
procedure SetVersion(const Value : string); procedure SetVersion(const Value: string);
public public
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
published published
{ properties } { properties }
property Version : string read GetVersion write SetVersion stored False; property Version: string read GetVersion write SetVersion stored False;
end; end;
{ Ancestor for all Visual PlanIt visual controls } { Ancestor for all Visual PlanIt visual controls }
@ -162,19 +154,17 @@ type
{$ENDIF} {$ENDIF}
protected protected
procedure DoOnMouseWheel(Shift : TShiftState; procedure DoOnMouseWheel(Shift: TShiftState; Delta, XPos, YPos: SmallInt); dynamic;
Delta, XPos, YPos : SmallInt); dynamic;
procedure CreateWnd; override; procedure CreateWnd; override;
property AfterEnter : TNotifyEvent read FAfterEnter write FAfterEnter; property AfterEnter: TNotifyEvent read FAfterEnter write FAfterEnter;
property AfterExit : TNotifyEvent read FAfterExit write FAfterExit; property AfterExit: TNotifyEvent read FAfterExit write FAfterExit;
property OnMouseWheel : TVpMouseWheelEvent read FOnMouseWheel property OnMouseWheel: TVpMouseWheelEvent read FOnMouseWheel write FOnMouseWheel;
write FOnMouseWheel;
public public
constructor Create (AOwner : TComponent); override; constructor Create (AOwner : TComponent); override;
published published
property Version : string read GetVersion write SetVersion stored False; property Version: string read GetVersion write SetVersion stored False;
{$IFNDEF LCL} {$IFNDEF LCL}
{$IFDEF VERSION6} {$IFDEF VERSION6}
property BevelEdges; property BevelEdges;
@ -214,9 +204,8 @@ type
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;
published published
property BackgroundColor : TColor property BackgroundColor : TColor read FBackgroundColor write SetBackgroundColor
read FBackgroundColor write SetBackgroundColor default clWindow;
default clWindow;
property Bitmap : TBitmap read FBitmap write SetBitmap; property Bitmap : TBitmap read FBitmap write SetBitmap;
property Color: TColor read FColor write SetColor; property Color: TColor read FColor write SetColor;
property Description: string read FDescription write SetDescription; property Description: string read FDescription write SetDescription;
@ -272,10 +261,10 @@ type
procedure SetVersion(const Value: String); procedure SetVersion(const Value: String);
procedure SetName(Value: String); virtual; procedure SetName(Value: String); virtual;
public public
property DisplayText : string read FDisplayText write FDisplayText; property DisplayText: string read FDisplayText write FDisplayText;
property Name: String read FName write SetName; property Name: String read FName write SetName;
published published
property Version : String read GetVersion write SetVersion; property Version: String read GetVersion write SetVersion;
end; end;
TVpCollection = class(TCollection) TVpCollection = class(TCollection)
@ -296,32 +285,26 @@ type
function GetCount : Integer; function GetCount : Integer;
procedure Loaded; procedure Loaded;
public public
constructor Create(AOwner : TPersistent; constructor Create(AOwner : TPersistent; ItemClass : TCollectionItemClass); virtual;
ItemClass : TCollectionItemClass); virtual;
destructor Destroy; override; destructor Destroy; override;
property ItemEditor : TForm read FItemEditor write FItemEditor; property ItemEditor: TForm read FItemEditor write FItemEditor;
function Add : TVpCollectionItem; dynamic; function Add: TVpCollectionItem; dynamic;
{$IFNDEF VERSION4} {$IFNDEF VERSION4}
function Insert(Index: Integer): TVpCollectionItem; dynamic; function Insert(Index: Integer): TVpCollectionItem; dynamic;
{$ENDIF} {$ENDIF}
function GetItem(Index: Integer): TVpCollectionItem; function GetItem(Index: Integer): TVpCollectionItem;
function GetOwner: TPersistent; override; function GetOwner: TPersistent; override;
procedure SetItem(Index: Integer; Value: TVpCollectionItem); procedure SetItem(Index: Integer; Value: TVpCollectionItem);
procedure DoOnItemSelected(Index : Integer); procedure DoOnItemSelected(Index: Integer);
function GetEditorCaption : string; function GetEditorCaption: string;
function ItemByName(const Name : string) : TVpCollectionItem; function ItemByName(const Name: string) : TVpCollectionItem;
function ParentForm : TForm; function ParentForm: TForm;
property Count: Integer read GetCount; property Count: Integer read GetCount;
property Item[Index: Integer] : TVpCollectionItem property Item[Index: Integer] : TVpCollectionItem read GetItem write SetItem; default;
read GetItem write SetItem; default; property OnGetEditorCaption : TVpGetEditorCaption read FOnGetEditorCaption write FOnGetEditorCaption;
property OnGetEditorCaption : TVpGetEditorCaption property ReadOnly : Boolean read FReadOnly write FReadOnly default False;
read FOnGetEditorCaption write FOnGetEditorCaption; property OnChanged : TNotifyEvent read FOnChanged write FOnChanged;
property ReadOnly : Boolean property OnItemSelected : TVpItemSelectedEvent read FOnItemSelected write FOnItemSelected;
read FReadOnly write FReadOnly default False;
property OnChanged : TNotifyEvent
read FOnChanged write FOnChanged;
property OnItemSelected : TVpItemSelectedEvent
read FOnItemSelected write FOnItemSelected;
end; end;
TVpContainerList = class(TList) TVpContainerList = class(TList)
@ -378,8 +361,7 @@ type
property Holiday: TColor read FHoliday write SetHoliday; property Holiday: TColor read FHoliday write SetHoliday;
property Weekday: TColor read FWeekday write SetWeekday; property Weekday: TColor read FWeekday write SetWeekday;
property Weekend: TColor read FWeekend write SetWeekend; property Weekend: TColor read FWeekend write SetWeekend;
property ActiveRange: TVpTimeRange property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange;
read FActiveRange write FActiveRange;
end; end;
implementation implementation
@ -404,11 +386,10 @@ end;
{ EAdFilterError } { EAdFilterError }
constructor EVpFilterError.CreateError(const FilePos, Line, constructor EVpFilterError.CreateError(const FilePos, Line, LinePos: Integer;
LinePos: Integer; const Reason: DOMString); const Reason: DOMString);
begin begin
inherited CreateError(FilePos, Reason); inherited CreateError(FilePos, Reason);
feLine := Line; feLine := Line;
feLinePos := LinePos; feLinePos := LinePos;
feReason := Reason; feReason := Reason;
@ -425,7 +406,7 @@ end;
(*****************************************************************************) (*****************************************************************************)
{ TVpCustomControl } { TVpCustomControl }
constructor TVpCustomControl.Create (AOwner : TComponent); constructor TVpCustomControl.Create (AOwner: TComponent);
begin begin
inherited Create (AOwner); inherited Create (AOwner);
TabStop := True; TabStop := True;
@ -446,8 +427,8 @@ begin
end; end;
{=====} {=====}
procedure TVpCustomControl.DoOnMouseWheel(Shift: TShiftState; Delta, XPos, procedure TVpCustomControl.DoOnMouseWheel(Shift: TShiftState;
YPos: SmallInt); Delta, XPos, YPos: SmallInt);
begin begin
if Assigned(FOnMouseWheel) then if Assigned(FOnMouseWheel) then
FOnMouseWheel(Self, Shift, Delta, XPos, YPos); FOnMouseWheel(Self, Shift, Delta, XPos, YPos);
@ -475,15 +456,16 @@ begin
with Msg do with Msg do
DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys}, DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys},
HIWORD(wParam) {zDelta}, HIWORD(wParam) {zDelta},
LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos}); LOWORD(lParam) {xPos},
HIWORD(lParam) {yPos}
);
end; end;
{=====} {=====}
(*****************************************************************************) (*****************************************************************************)
{ TVpCollection } { TVpCollection }
constructor TVpCollection.Create(AOwner : TPersistent; constructor TVpCollection.Create(AOwner: TPersistent; ItemClass: TCollectionItemClass);
ItemClass : TCollectionItemClass);
begin begin
FOwner := AOwner; FOwner := AOwner;
Inherited Create(ItemClass); Inherited Create(ItemClass);
@ -498,20 +480,20 @@ begin
end; end;
{=====} {=====}
procedure TVpCollection.DoOnItemSelected(Index : Integer); procedure TVpCollection.DoOnItemSelected(Index: Integer);
begin begin
if Assigned(FOnItemSelected) then if Assigned(FOnItemSelected) then
FOnItemSelected(Self, Index); FOnItemSelected(Self, Index);
end; end;
{=====} {=====}
function TVpCollection.GetCount : Integer; function TVpCollection.GetCount: Integer;
begin begin
Result := inherited Count; Result := inherited Count;
end; end;
{=====} {=====}
function TVpCollection.GetEditorCaption : string; function TVpCollection.GetEditorCaption: string;
begin begin
Result := 'Editing ' + ClassName; Result := 'Editing ' + ClassName;
if Assigned(FOnGetEditorCaption) then if Assigned(FOnGetEditorCaption) then
@ -519,7 +501,7 @@ begin
end; end;
{=====} {=====}
function TVpCollection.Add : TVpCollectionItem; function TVpCollection.Add: TVpCollectionItem;
begin begin
Result := TVpCollectionItem(inherited Add); Result := TVpCollectionItem(inherited Add);
if ItemEditor <> nil then if ItemEditor <> nil then
@ -540,7 +522,7 @@ end;
{=====} {=====}
{$ENDIF} {$ENDIF}
function TVpCollection.GetItem(Index : Integer) : TVpCollectionItem; function TVpCollection.GetItem(Index: Integer): TVpCollectionItem;
begin begin
Result := TVpCollectionItem(inherited GetItem(Index)); Result := TVpCollectionItem(inherited GetItem(Index));
end; end;
@ -551,13 +533,13 @@ begin
end; end;
{=====} {=====}
procedure TVpCollection.SetItem(Index : Integer; Value : TVpCollectionItem); procedure TVpCollection.SetItem(Index: Integer; Value: TVpCollectionItem);
begin begin
inherited SetItem(Index, Value); inherited SetItem(Index, Value);
end; end;
{=====} {=====}
function TVpCollection.ItemByName(const Name : string) : TVpCollectionItem; function TVpCollection.ItemByName(const Name: string): TVpCollectionItem;
var var
i : Integer; i : Integer;
begin begin
@ -660,9 +642,10 @@ end;
procedure TVpFont.Changed; procedure TVpFont.Changed;
begin begin
inherited; inherited;
Assert((FOwner is TControl) or (FOwner is TVpPersistent), Assert(
Format('TVpFont.Changed: Unexpected parent class: %s', (FOwner is TControl) or (FOwner is TVpPersistent),
[FOwner.ClassName])); Format('TVpFont.Changed: Unexpected parent class: %s', [FOwner.ClassName])
);
if FOwner is TControl then if FOwner is TControl then
TControl(FOwner).Invalidate TControl(FOwner).Invalidate
else if FOwner is TVpPersistent then else if FOwner is TVpPersistent then
@ -683,7 +666,6 @@ end;
constructor TVpCategoryColorMap.Create; constructor TVpCategoryColorMap.Create;
begin begin
inherited Create; inherited Create;
FCat0 := TVpCategoryInfo.Create; FCat0 := TVpCategoryInfo.Create;
FCat0.Color := clNavy; FCat0.Color := clNavy;
FCat0.Description := RSCategoryDesc0; FCat0.Description := RSCategoryDesc0;
@ -787,25 +769,23 @@ end;
constructor TVpCategoryInfo.Create; constructor TVpCategoryInfo.Create;
begin begin
inherited Create; inherited Create;
FBitmap := TBitmap.Create;
FBitmap := TBitmap.Create;
FBackgroundColor := clWindow; FBackgroundColor := clWindow;
end; end;
destructor TVpCategoryInfo.Destroy; destructor TVpCategoryInfo.Destroy;
begin begin
FBitmap.Free; FBitmap.Free;
inherited Destroy; inherited Destroy;
end; end;
procedure TVpCategoryInfo.SetBackgroundColor (const v : TColor); procedure TVpCategoryInfo.SetBackgroundColor(const v: TColor);
begin begin
if v <> FBackgroundColor then if v <> FBackgroundColor then
FBackgroundColor := v; FBackgroundColor := v;
end; end;
procedure TVpCategoryInfo.SetBitmap (v : TBitmap); procedure TVpCategoryInfo.SetBitmap(v: TBitmap);
begin begin
FBitmap.Assign (v); FBitmap.Assign (v);
end; end;
@ -857,7 +837,6 @@ begin
{ start to be one hour earlier than the end } { start to be one hour earlier than the end }
if FRangeBegin > Value then if FRangeBegin > Value then
FRangeBegin := TVpHours(Ord(Value) - 1); FRangeBegin := TVpHours(Ord(Value) - 1);
FRangeEnd := Value; FRangeEnd := Value;
SetEndTime((Ord(Value) * 60) / MinutesInDay); SetEndTime((Ord(Value) * 60) / MinutesInDay);
end; end;
@ -868,7 +847,6 @@ begin
if Value < StartTime then if Value < StartTime then
StartTime := Value - (30 / MinutesInDay); StartTime := Value - (30 / MinutesInDay);
FEndTime := Value; FEndTime := Value;
if FOwner is TVpTimeSlotColor then if FOwner is TVpTimeSlotColor then
(FOwner as TVpTimeSlotColor).Changed; (FOwner as TVpTimeSlotColor).Changed;
end; end;
@ -879,7 +857,6 @@ begin
if Value > EndTime then if Value > EndTime then
EndTime := Value + (30 / MinutesInDay); EndTime := Value + (30 / MinutesInDay);
FStartTime := Value; FStartTime := Value;
if FOwner is TVpTimeSlotColor then if FOwner is TVpTimeSlotColor then
(FOwner as TVpTimeSlotColor).Changed; (FOwner as TVpTimeSlotColor).Changed;
end; end;
@ -895,12 +872,12 @@ constructor TVpTimeSlotColor.Create(AOwner: TVpCustomControl);
begin begin
inherited Create; inherited Create;
FOwner := AOwner; FOwner := AOwner;
FActiveRange := TVpTimeRange.Create(Self); FActiveRange := TVpTimeRange.Create(Self);
FInactive := $0080FFFF; FInactive := $0080FFFF;
FHoliday := $00FF80FF; FHoliday := $00FF80FF;
FWeekend := $00FFFF80; FWeekend := $00FFFF80;
FActive := clWhite; FActive := clWhite;
FWeekday := clWhite; FWeekday := clWhite;
end; end;
{=====} {=====}

View File

@ -193,7 +193,7 @@ type
property OnGetNextID: TVpGetNextIDEvent property OnGetNextID: TVpGetNextIDEvent
read FOnGetNextID write FOnGetNextID; read FOnGetNextID write FOnGetNextID;
property OnCreateTable: TVpTableEvent property OnCreateTable: TVpTableEvent
read FOnCreateTable write FOnCreateTable; read FOnCreateTable write FOnCreateTable;
property OnSetFilterCriteria: TVpSetFilterCriteriaEvent property OnSetFilterCriteria: TVpSetFilterCriteriaEvent
read FOnSetFilterCriteria write FOnSetFilterCriteria; read FOnSetFilterCriteria write FOnSetFilterCriteria;
end; end;
@ -210,10 +210,10 @@ constructor TVpFlexDataStore.Create(AOwner: TComponent);
begin begin
inherited; inherited;
FResourceMappings := TCollection.Create(TVpFieldMapping); FResourceMappings := TCollection.Create(TVpFieldMapping);
FEventMappings := TCollection.Create(TVpFieldMapping); FEventMappings := TCollection.Create(TVpFieldMapping);
FContactMappings := TCollection.Create(TVpFieldMapping); FContactMappings := TCollection.Create(TVpFieldMapping);
FTaskMappings := TCollection.Create(TVpFieldMapping); FTaskMappings := TCollection.Create(TVpFieldMapping);
FDataSources := TVpDataSources.Create(self); FDataSources := TVpDataSources.Create(self);
FConnected := false; FConnected := false;
FResourceID := 0; FResourceID := 0;
end; end;
@ -234,7 +234,7 @@ function TVpFlexDataStore.GetConnected: Boolean;
var var
AllAssigned, AllActive: Boolean; AllAssigned, AllActive: Boolean;
begin begin
AllActive := false; AllActive := false;
AllAssigned := (FResourceDataSrc.DataSet <> nil) AllAssigned := (FResourceDataSrc.DataSet <> nil)
and (FEventsDataSrc.DataSet <> nil) and (FEventsDataSrc.DataSet <> nil)
and (FContactsDataSrc.DataSet <> nil) and (FContactsDataSrc.DataSet <> nil)
@ -348,9 +348,8 @@ begin
try try
FResourceDataSrc.DataSet.Open; FResourceDataSrc.DataSet.Open;
except except
if Assigned(OnCreateTable) then begin if Assigned(OnCreateTable) then
OnCreateTable(Self, ResourceTableName); OnCreateTable(Self, ResourceTableName);
end;
try try
FResourceDataSrc.DataSet.Open; FResourceDataSrc.DataSet.Open;
except except
@ -364,9 +363,8 @@ begin
try try
FEventsDataSrc.DataSet.Open; FEventsDataSrc.DataSet.Open;
except except
if Assigned(OnCreateTable) then begin if Assigned(OnCreateTable) then
OnCreateTable(Self, EventsTableName); OnCreateTable(Self, EventsTableName);
end;
try try
FEventsDataSrc.DataSet.Open; FEventsDataSrc.DataSet.Open;
except except
@ -380,9 +378,8 @@ begin
try try
FContactsDataSrc.DataSet.Open; FContactsDataSrc.DataSet.Open;
except except
if Assigned(OnCreateTable) then begin if Assigned(OnCreateTable) then
OnCreateTable(Self, ContactsTableName); OnCreateTable(Self, ContactsTableName);
end;
try try
FContactsDataSrc.DataSet.Open; FContactsDataSrc.DataSet.Open;
except except
@ -396,9 +393,8 @@ begin
try try
FTasksDataSrc.DataSet.Open; FTasksDataSrc.DataSet.Open;
except except
if Assigned(OnCreateTable) then begin if Assigned(OnCreateTable) then
OnCreateTable(Self, TasksTableName); OnCreateTable(Self, TasksTableName);
end;
try try
FTasksDataSrc.DataSet.Open; FTasksDataSrc.DataSet.Open;
except except
@ -429,9 +425,8 @@ end;
procedure TVpFlexDataStore.Load; procedure TVpFlexDataStore.Load;
var var
Res : TVpResource; Res: TVpResource;
{FieldName} FN: string; // Field name
FN: string;
begin begin
if (csLoading in ComponentState) then if (csLoading in ComponentState) then
Exit; Exit;
@ -538,21 +533,17 @@ var
{Field Name} {Field Name}
FN1, FN2, FN3 : string; FN1, FN2, FN3 : string;
begin begin
if (FEventsDataSrc = nil) if (FEventsDataSrc = nil) or (FEventsDataSrc.DataSet = nil) then
or (FEventsDataSrc.DataSet = nil) then
Exit; Exit;
if (FResource <> nil) then begin if (FResource <> nil) then begin
{ Load this resource's events into memory } { Load this resource's events into memory }
SetFilterCriteria(FEventsDataSrc.DataSet, SetFilterCriteria(FEventsDataSrc.DataSet, True, FResource.ResourceID,
True, TimeRange.StartTime, TimeRange.EndTime);
FResource.ResourceID,
TimeRange.StartTime,
TimeRange.EndTime);
if (FEventsDataSrc = nil) if (FEventsDataSrc = nil) or
or (FEventsDataSrc.DataSet = nil) (FEventsDataSrc.DataSet = nil) or (not FEventsDataSrc.DataSet.Active)
or (not FEventsDataSrc.DataSet.Active) then then
Exit; Exit;
with FEventsDataSrc.Dataset do begin with FEventsDataSrc.Dataset do begin
@ -564,8 +555,8 @@ begin
FN3 := GetFieldName(FEventMappings, 'EndTime'); FN3 := GetFieldName(FEventMappings, 'EndTime');
if (FN1 <> '') and (FN2 <> '') and (FN3 <> '') then begin if (FN1 <> '') and (FN2 <> '') and (FN3 <> '') then begin
Event := Resource.Schedule.AddEvent(FieldByName(FN1).AsInteger, Event := Resource.Schedule.AddEvent(FieldByName(FN1).AsInteger,
FieldByName(FN2).AsDateTime, FieldByName(FN2).AsDateTime, FieldByName(FN3).AsDateTime);
FieldByName(FN3).AsDateTime);
if Event <> nil then begin if Event <> nil then begin
Event.Loading := true; Event.Loading := true;
@ -688,187 +679,185 @@ var
begin begin
if (FResource <> nil) then begin if (FResource <> nil) then begin
{load this resource's contacts into memory} {load this resource's contacts into memory}
if (FContactsDataSrc <> nil) if (FContactsDataSrc <> nil) and (FContactsDataSrc.DataSet <> nil) and FContactsDataSrc.DataSet.Active
and (FContactsDataSrc.DataSet <> nil) then
and (FContactsDataSrc.DataSet.Active) then with FContactsDataSrc.DataSet do begin
with FContactsDataSrc.DataSet do begin SetFilterCriteria(FContactsDataSrc.DataSet, False, FResource.ResourceID, 0, 0);
SetFilterCriteria(FContactsDataSrc.DataSet, False, First;
FResource.ResourceID, 0, 0); while not EOF do begin
First; Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName));
while not EOF do begin if Contact <> nil then begin
Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName)); Contact.Loading := true;
if Contact <> nil then begin
Contact.Loading := true;
FN := GetFieldName(FContactMappings, 'RecordID'); FN := GetFieldName(FContactMappings, 'RecordID');
if FN <> '' then if FN <> '' then
Contact.RecordID := FieldByName(FN).AsInteger; Contact.RecordID := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'FirstName'); FN := GetFieldName(FContactMappings, 'FirstName');
if FN <> '' then if FN <> '' then
Contact.FirstName := FieldByName(FN).AsString; Contact.FirstName := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'LastName'); FN := GetFieldName(FContactMappings, 'LastName');
if FN <> '' then if FN <> '' then
Contact.LastName := FieldByName(FN).AsString; Contact.LastName := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'BirthDate'); FN := GetFieldName(FContactMappings, 'BirthDate');
if FN <> '' then if FN <> '' then
Contact.Birthdate := FieldByName(FN).AsDateTime; Contact.Birthdate := FieldByName(FN).AsDateTime;
FN := GetFieldName(FContactMappings, 'Anniversary'); FN := GetFieldName(FContactMappings, 'Anniversary');
if FN <> '' then if FN <> '' then
Contact.Anniversary := FieldByName(FN).AsDateTime; Contact.Anniversary := FieldByName(FN).AsDateTime;
FN := GetFieldName(FContactMappings, 'Title'); FN := GetFieldName(FContactMappings, 'Title');
if FN <> '' then if FN <> '' then
Contact.Title := FieldByName(FN).AsString; Contact.Title := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Company'); FN := GetFieldName(FContactMappings, 'Company');
if FN <> '' then if FN <> '' then
Contact.Company := FieldByName(FN).AsString; Contact.Company := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Job_Position'); FN := GetFieldName(FContactMappings, 'Job_Position');
if FN = '' then if FN = '' then
FN := GetFieldName(FContactMappings, 'Position'); // deprecated FN := GetFieldName(FContactMappings, 'Position'); // deprecated
if FN <> '' then if FN <> '' then
Contact.Job_Position := FieldByName(FN).AsString; Contact.Job_Position := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'EMail'); FN := GetFieldName(FContactMappings, 'EMail');
if FN <> '' then if FN <> '' then
Contact.EMail := FieldByName(FN).AsString; Contact.EMail := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Address'); FN := GetFieldName(FContactMappings, 'Address');
if FN <> '' then if FN <> '' then
Contact.Address := FieldByName(FN).AsString; Contact.Address := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'City'); FN := GetFieldName(FContactMappings, 'City');
if FN <> '' then if FN <> '' then
Contact.City := FieldByName(FN).AsString; Contact.City := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'State'); FN := GetFieldName(FContactMappings, 'State');
if FN <> '' then if FN <> '' then
Contact.State := FieldByName(FN).AsString; Contact.State := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Zip'); FN := GetFieldName(FContactMappings, 'Zip');
if FN <> '' then if FN <> '' then
Contact.Zip := FieldByName(FN).AsString; Contact.Zip := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Country'); FN := GetFieldName(FContactMappings, 'Country');
if FN <> '' then if FN <> '' then
Contact.Country := FieldByName(FN).AsString; Contact.Country := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Notes'); FN := GetFieldName(FContactMappings, 'Notes');
if FN = '' then if FN = '' then
FN := GetFieldName(FContactMappings, 'Note'); // deprecated FN := GetFieldName(FContactMappings, 'Note'); // deprecated
if FN <> '' then if FN <> '' then
Contact.Notes := FieldByName(FN).AsString; Contact.Notes := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Phone1'); FN := GetFieldName(FContactMappings, 'Phone1');
if FN <> '' then if FN <> '' then
Contact.Phone1 := FieldByName(FN).AsString; Contact.Phone1 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Phone2'); FN := GetFieldName(FContactMappings, 'Phone2');
if FN <> '' then if FN <> '' then
Contact.Phone2 := FieldByName(FN).AsString; Contact.Phone2 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Phone3'); FN := GetFieldName(FContactMappings, 'Phone3');
if FN <> '' then if FN <> '' then
Contact.Phone3 := FieldByName(FN).AsString; Contact.Phone3 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Phone4'); FN := GetFieldName(FContactMappings, 'Phone4');
if FN <> '' then if FN <> '' then
Contact.Phone4 := FieldByName(FN).AsString; Contact.Phone4 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Phone5'); FN := GetFieldName(FContactMappings, 'Phone5');
if FN <> '' then if FN <> '' then
Contact.Phone5 := FieldByName(FN).AsString; Contact.Phone5 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'PhoneType1'); FN := GetFieldName(FContactMappings, 'PhoneType1');
if FN <> '' then if FN <> '' then
Contact.PhoneType1 := FieldByName(FN).AsInteger; Contact.PhoneType1 := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'PhoneType2'); FN := GetFieldName(FContactMappings, 'PhoneType2');
if FN <> '' then if FN <> '' then
Contact.PhoneType2 := FieldByName(FN).AsInteger; Contact.PhoneType2 := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'PhoneType3'); FN := GetFieldName(FContactMappings, 'PhoneType3');
if FN <> '' then if FN <> '' then
Contact.PhoneType3 := FieldByName(FN).AsInteger; Contact.PhoneType3 := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'PhoneType4'); FN := GetFieldName(FContactMappings, 'PhoneType4');
if FN <> '' then if FN <> '' then
Contact.PhoneType4 := FieldByName(FN).AsInteger; Contact.PhoneType4 := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'PhoneType5'); FN := GetFieldName(FContactMappings, 'PhoneType5');
if FN <> '' then if FN <> '' then
Contact.PhoneType5 := FieldByName(FN).AsInteger; Contact.PhoneType5 := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'Category'); FN := GetFieldName(FContactMappings, 'Category');
if FN <> '' then if FN <> '' then
Contact.Category := FieldByName(FN).AsInteger; Contact.Category := FieldByName(FN).AsInteger;
FN := GetFieldName(FContactMappings, 'Custom1'); FN := GetFieldName(FContactMappings, 'Custom1');
if FN <> '' then if FN <> '' then
Contact.Custom1 := FieldByName(FN).AsString; Contact.Custom1 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Custom2'); FN := GetFieldName(FContactMappings, 'Custom2');
if FN <> '' then if FN <> '' then
Contact.Custom2 := FieldByName(FN).AsString; Contact.Custom2 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Custom3'); FN := GetFieldName(FContactMappings, 'Custom3');
if FN <> '' then if FN <> '' then
Contact.Custom3 := FieldByName(FN).AsString; Contact.Custom3 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'Custom4'); FN := GetFieldName(FContactMappings, 'Custom4');
if FN <> '' then if FN <> '' then
Contact.Custom4 := FieldByName(FN).AsString; Contact.Custom4 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField0'); FN := GetFieldName(FContactMappings, 'UserField0');
if FN <> '' then if FN <> '' then
Contact.UserField0 := FieldByName(FN).AsString; Contact.UserField0 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField1'); FN := GetFieldName(FContactMappings, 'UserField1');
if FN <> '' then if FN <> '' then
Contact.UserField1 := FieldByName(FN).AsString; Contact.UserField1 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField2'); FN := GetFieldName(FContactMappings, 'UserField2');
if FN <> '' then if FN <> '' then
Contact.UserField2 := FieldByName(FN).AsString; Contact.UserField2 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField3'); FN := GetFieldName(FContactMappings, 'UserField3');
if FN <> '' then if FN <> '' then
Contact.UserField3 := FieldByName(FN).AsString; Contact.UserField3 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField4'); FN := GetFieldName(FContactMappings, 'UserField4');
if FN <> '' then if FN <> '' then
Contact.UserField4 := FieldByName(FN).AsString; Contact.UserField4 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField5'); FN := GetFieldName(FContactMappings, 'UserField5');
if FN <> '' then if FN <> '' then
Contact.UserField5 := FieldByName(FN).AsString; Contact.UserField5 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField6'); FN := GetFieldName(FContactMappings, 'UserField6');
if FN <> '' then if FN <> '' then
Contact.UserField6 := FieldByName(FN).AsString; Contact.UserField6 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField7'); FN := GetFieldName(FContactMappings, 'UserField7');
if FN <> '' then if FN <> '' then
Contact.UserField7 := FieldByName(FN).AsString; Contact.UserField7 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField8'); FN := GetFieldName(FContactMappings, 'UserField8');
if FN <> '' then if FN <> '' then
Contact.UserField8 := FieldByName(FN).AsString; Contact.UserField8 := FieldByName(FN).AsString;
FN := GetFieldName(FContactMappings, 'UserField9'); FN := GetFieldName(FContactMappings, 'UserField9');
if FN <> '' then if FN <> '' then
Contact.UserField9 := FieldByName(FN).AsString; Contact.UserField9 := FieldByName(FN).AsString;
Contact.Loading := false; Contact.Loading := false;
end; end;
Next; Next;
end; {while} end; {while}
end; {with ContactsTable} end; {with ContactsTable}
end; {if Resource <> nil} end; {if Resource <> nil}
end; end;
{=====} {=====}
@ -881,12 +870,10 @@ var
begin begin
if (FResource <> nil) then begin if (FResource <> nil) then begin
{load this resource's contacts into memory} {load this resource's contacts into memory}
if (FTasksDataSrc <> nil) if (FTasksDataSrc <> nil) and (FTasksDataSrc.DataSet <> nil) and (FTasksDataSrc.DataSet.Active) then
and (FTasksDataSrc.DataSet <> nil) begin
and (FTasksDataSrc.DataSet.Active) then begin
with FTasksDataSrc.DataSet do begin with FTasksDataSrc.DataSet do begin
SetFilterCriteria(FTasksDataSrc.DataSet, False, FResource.ResourceID, SetFilterCriteria(FTasksDataSrc.DataSet, False, FResource.ResourceID, 0, 0);
0, 0);
First; First;
while not EOF do begin while not EOF do begin
Task := Resource.Tasks.AddTask(GetNextID(TasksTableName)); Task := Resource.Tasks.AddTask(GetNextID(TasksTableName));
@ -1000,7 +987,6 @@ begin
then FResourceDataSrc.DataSet.Open; then FResourceDataSrc.DataSet.Open;
if FResourceDataSrc.DataSet.Active then begin if FResourceDataSrc.DataSet.Active then begin
with FResourceDataSrc.DataSet do begin with FResourceDataSrc.DataSet do begin
{ if a resource } { if a resource }
FN := GetFieldName(FResourceMappings, 'ResourceID'); FN := GetFieldName(FResourceMappings, 'ResourceID');
@ -1115,20 +1101,17 @@ var
FN: string; FN: string;
begin begin
{if no events dataset has been defined then bail.} {if no events dataset has been defined then bail.}
if (FEventsDataSrc = nil) if (FEventsDataSrc = nil) or (FEventsDataSrc.DataSet = nil) then
or (FEventsDataSrc.DataSet = nil) then
Exit; Exit;
if (Resource <> nil) and Resource.EventsDirty then begin if (Resource <> nil) and Resource.EventsDirty then begin
{ Dump this resource's dirty events to the DB } { Dump this resource's dirty events to the DB }
if (FResourceDataSrc <> nil) if (FResourceDataSrc <> nil) and (FResourceDataSrc.DataSet <> nil) then
and (FResourceDataSrc.DataSet <> nil) then begin begin
FResourceDataSrc.DataSet.Open; FResourceDataSrc.DataSet.Open;
FN := GetFieldName(FEventMappings, 'ResourceID'); FN := GetFieldName(FEventMappings, 'ResourceID');
if (FN <> '') if (FN <> '') and FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, [])
and FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, [])
then begin then begin
SetFilterCriteria(FEventsDataSrc.DataSet, False, Resource.ResourceID, SetFilterCriteria(FEventsDataSrc.DataSet, False, Resource.ResourceID,
0, 0); 0, 0);
@ -1160,7 +1143,6 @@ begin
if Event.RecordID <> -1 then if Event.RecordID <> -1 then
EventsTable.FieldByName(FN).AsInteger := Event.RecordID; EventsTable.FieldByName(FN).AsInteger := Event.RecordID;
FN := GetFieldName(FEventMappings, 'StartTime'); FN := GetFieldName(FEventMappings, 'StartTime');
if FN <> '' then if FN <> '' then
EventsTable.FieldByName(FN).AsDateTime := Event.StartTime; EventsTable.FieldByName(FN).AsDateTime := Event.StartTime;
@ -1287,11 +1269,9 @@ begin
if Event.RecordID = -1 then begin if Event.RecordID = -1 then begin
FN := GetFieldName(EventMappings, 'RecordID'); FN := GetFieldName(EventMappings, 'RecordID');
if FN <> '' then if FN <> '' then
Event.RecordID Event.RecordID := EventsTable.FieldByName(FN).AsInteger;
:= EventsTable.FieldByName(FN).AsInteger;
end; end;
(* Bad Phillip. (* Bad Phillip.
if Event.RecordID = -1 then if Event.RecordID = -1 then
Event.RecordID := EventsTable.FieldByName('RecordID').AsInteger; Event.RecordID := EventsTable.FieldByName('RecordID').AsInteger;
@ -1332,8 +1312,8 @@ begin
{ if the delete flag is set then delete the record } { if the delete flag is set then delete the record }
{ and free the event instance } { and free the event instance }
if Contact.Deleted then begin if Contact.Deleted then begin
if ContactsTable.Locate(FN, Contact.RecordID, []) if ContactsTable.Locate(FN, Contact.RecordID, []) then
then ContactsTable.Delete; ContactsTable.Delete;
Contact.Free; Contact.Free;
Continue; Continue;
end; end;
@ -1530,7 +1510,7 @@ begin
if Contact.RecordID = -1 then begin if Contact.RecordID = -1 then begin
FN := GetFieldName(FContactMappings, 'RecordID'); FN := GetFieldName(FContactMappings, 'RecordID');
if FN <> '' then if FN <> '' then
Contact.RecordID := ContactsTable.FieldByName(FN).AsInteger; Contact.RecordID := ContactsTable.FieldByName(FN).AsInteger;
end; end;
Contact.Changed := false; Contact.Changed := false;
@ -1552,14 +1532,14 @@ var
begin begin
if (Resource <> nil) and Resource.TasksDirty then begin if (Resource <> nil) and Resource.TasksDirty then begin
if (FResourceDataSrc <> nil) if (FResourceDataSrc <> nil) and (FResourceDataSrc.Dataset <> nil) then
and (FResourceDataSrc.Dataset <> nil) then begin begin
FResourceDataSrc.DataSet.Open; FResourceDataSrc.DataSet.Open;
if FResourceDataSrc.DataSet.Active then begin if FResourceDataSrc.DataSet.Active then begin
FN := GetFieldName(FTaskMappings, 'ResourceID'); FN := GetFieldName(FTaskMappings, 'ResourceID');
{ Dump this resource's dirty contacts to the DB } { Dump this resource's dirty contacts to the DB }
if not FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, []) if not FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, []) then
then Exit; Exit;
end; {if FResourceDataSrc.DataSet.Active} end; {if FResourceDataSrc.DataSet.Active}
end; {if (FResourceDataSrc ...} end; {if (FResourceDataSrc ...}
@ -1569,9 +1549,7 @@ begin
for I := pred(Resource.Tasks.Count) downto 0 do begin for I := pred(Resource.Tasks.Count) downto 0 do begin
with FTasksDataSrc.DataSet do begin with FTasksDataSrc.DataSet do begin
Task := Resource.Tasks.GetTask(I); Task := Resource.Tasks.GetTask(I);
FN := GetFieldName(FTaskMappings, 'RecordID'); FN := GetFieldName(FTaskMappings, 'RecordID');
{ if the delete flag is set then delete the record } { if the delete flag is set then delete the record }
@ -1584,15 +1562,14 @@ begin
end; end;
if Task.Changed then begin if Task.Changed then begin
if Locate(FN, Task.RecordID, []) if Locate(FN, Task.RecordID, []) then
then
{ this event already exists in the database so update it } { this event already exists in the database so update it }
Edit Edit
else else
{ this record doesn't exist in the database, so it's a new event } { this record doesn't exist in the database, so it's a new event }
Append; Append;
try
try
{ DataStore descendants that can use an autoincrement RecordID } { DataStore descendants that can use an autoincrement RecordID }
{ field set the RecordID to -1 by default. If the RecordID is } { field set the RecordID to -1 by default. If the RecordID is }
{ -1 then this is a new record and we shouldn't overwrite } { -1 then this is a new record and we shouldn't overwrite }
@ -1726,7 +1703,6 @@ begin
FN := GetFieldName(FResourceMappings, 'ResourceID'); FN := GetFieldName(FResourceMappings, 'ResourceID');
if (FN <> '') then begin if (FN <> '') then begin
if (Res <> nil) and Res.Deleted then begin if (Res <> nil) and Res.Deleted then begin
PurgeEvents(Res); PurgeEvents(Res);
PurgeContacts(Res); PurgeContacts(Res);
@ -1850,9 +1826,8 @@ procedure TVpFlexDataStore.PurgeEvents(Res: TVpResource);
var var
I: integer; I: integer;
begin begin
for I := 0 to pred(Res.Schedule.EventCount) do begin for I := 0 to pred(Res.Schedule.EventCount) do
TVpEvent(Res.Schedule.GetEvent(I)).Deleted := true; TVpEvent(Res.Schedule.GetEvent(I)).Deleted := true;
end;
PostEvents; PostEvents;
Res.Schedule.ClearEvents; Res.Schedule.ClearEvents;
end; end;
@ -1863,9 +1838,8 @@ procedure TVpFlexDataStore.PurgeContacts(Res: TVpResource);
var var
I: integer; I: integer;
begin begin
for I := 0 to pred(Res.Contacts.Count) do begin for I := 0 to pred(Res.Contacts.Count) do
TVpContact(Res.Contacts.GetContact(I)).Deleted := true; TVpContact(Res.Contacts.GetContact(I)).Deleted := true;
end;
PostContacts; PostContacts;
Res.Contacts.ClearContacts; Res.Contacts.ClearContacts;
end; end;
@ -1876,9 +1850,8 @@ procedure TVpFlexDataStore.PurgeTasks(Res: TVpResource);
var var
I: integer; I: integer;
begin begin
for I := 0 to pred(Res.Tasks.Count) do begin for I := 0 to pred(Res.Tasks.Count) do
TVpTask(Res.Tasks.GetTask(I)).Deleted := true; TVpTask(Res.Tasks.GetTask(I)).Deleted := true;
end;
PostTasks; PostTasks;
Res.Tasks.ClearTasks; Res.Tasks.ClearTasks;
end; end;
@ -2079,7 +2052,6 @@ begin
{ for each table. } { for each table. }
result := -1; result := -1;
if Assigned(OnGetNextID) then if Assigned(OnGetNextID) then
result := OnGetNextID(Self, TableName); result := OnGetNextID(Self, TableName);
end; end;
@ -2203,5 +2175,4 @@ end;
{=====} {=====}
end. end.