diff --git a/components/tvplanit/source/vpbase.pas b/components/tvplanit/source/vpbase.pas index 52f1d2f76..ffbd52fb2 100644 --- a/components/tvplanit/source/vpbase.pas +++ b/components/tvplanit/source/vpbase.pas @@ -96,7 +96,6 @@ type TVpGetEditorCaption = procedure(var Caption : string) of object; - { XML exceptions } EXML = class (Exception); @@ -104,45 +103,38 @@ type private seFilePos : Longint; public - constructor CreateError(const FilePos : Longint; - const Reason : DOMString); - property FilePos : Longint + constructor CreateError(const FilePos: Longint; const Reason: DOMString); + property FilePos: Longint read seFilePos; end; EVpFilterError = class(EVpStreamError) private - feReason : DOMString; - feLine : Longint; - feLinePos : Longint; + feReason: DOMString; + feLine: Longint; + feLinePos: Longint; public - constructor CreateError(const FilePos, Line, LinePos : Longint; - const Reason : DOMString); - property Reason : DOMString - read feReason; - property Line : Longint - read feLine; - property LinePos : Longint - read feLinePos; + constructor CreateError(const FilePos, Line, LinePos: Longint; const Reason: DOMString); + property Reason : DOMString read feReason; + property Line : Longint read feLine; + property LinePos : Longint read feLinePos; end; EVpParserError = class(EVpFilterError) - protected public - constructor CreateError(Line, LinePos : Longint; - const Reason : DOMString); + constructor CreateError(Line, LinePos: Longint; const Reason: DOMString); end; { implements the Version property with its associated design time About box } TVpComponent = class(TComponent) protected { private } - function GetVersion : string; - procedure SetVersion(const Value : string); + function GetVersion: string; + procedure SetVersion(const Value: string); public constructor Create(AOwner: TComponent); override; published { properties } - property Version : string read GetVersion write SetVersion stored False; + property Version: string read GetVersion write SetVersion stored False; end; { Ancestor for all Visual PlanIt visual controls } @@ -162,19 +154,17 @@ type {$ENDIF} protected - procedure DoOnMouseWheel(Shift : TShiftState; - Delta, XPos, YPos : SmallInt); dynamic; + procedure DoOnMouseWheel(Shift: TShiftState; Delta, XPos, YPos: SmallInt); dynamic; procedure CreateWnd; override; - property AfterEnter : TNotifyEvent read FAfterEnter write FAfterEnter; - property AfterExit : TNotifyEvent read FAfterExit write FAfterExit; - property OnMouseWheel : TVpMouseWheelEvent read FOnMouseWheel - write FOnMouseWheel; + property AfterEnter: TNotifyEvent read FAfterEnter write FAfterEnter; + property AfterExit: TNotifyEvent read FAfterExit write FAfterExit; + property OnMouseWheel: TVpMouseWheelEvent read FOnMouseWheel write FOnMouseWheel; public constructor Create (AOwner : TComponent); override; published - property Version : string read GetVersion write SetVersion stored False; + property Version: string read GetVersion write SetVersion stored False; {$IFNDEF LCL} {$IFDEF VERSION6} property BevelEdges; @@ -214,9 +204,8 @@ type constructor Create; destructor Destroy; override; published - property BackgroundColor : TColor - read FBackgroundColor write SetBackgroundColor - default clWindow; + property BackgroundColor : TColor read FBackgroundColor write SetBackgroundColor + default clWindow; property Bitmap : TBitmap read FBitmap write SetBitmap; property Color: TColor read FColor write SetColor; property Description: string read FDescription write SetDescription; @@ -272,10 +261,10 @@ type procedure SetVersion(const Value: String); procedure SetName(Value: String); virtual; public - property DisplayText : string read FDisplayText write FDisplayText; + property DisplayText: string read FDisplayText write FDisplayText; property Name: String read FName write SetName; published - property Version : String read GetVersion write SetVersion; + property Version: String read GetVersion write SetVersion; end; TVpCollection = class(TCollection) @@ -296,32 +285,26 @@ type function GetCount : Integer; procedure Loaded; public - constructor Create(AOwner : TPersistent; - ItemClass : TCollectionItemClass); virtual; + constructor Create(AOwner : TPersistent; ItemClass : TCollectionItemClass); virtual; destructor Destroy; override; - property ItemEditor : TForm read FItemEditor write FItemEditor; - function Add : TVpCollectionItem; dynamic; + property ItemEditor: TForm read FItemEditor write FItemEditor; + function Add: TVpCollectionItem; dynamic; {$IFNDEF VERSION4} function Insert(Index: Integer): TVpCollectionItem; dynamic; {$ENDIF} function GetItem(Index: Integer): TVpCollectionItem; function GetOwner: TPersistent; override; procedure SetItem(Index: Integer; Value: TVpCollectionItem); - procedure DoOnItemSelected(Index : Integer); - function GetEditorCaption : string; - function ItemByName(const Name : string) : TVpCollectionItem; - function ParentForm : TForm; + procedure DoOnItemSelected(Index: Integer); + function GetEditorCaption: string; + function ItemByName(const Name: string) : TVpCollectionItem; + function ParentForm: TForm; property Count: Integer read GetCount; - property Item[Index: Integer] : TVpCollectionItem - read GetItem write SetItem; default; - property OnGetEditorCaption : TVpGetEditorCaption - read FOnGetEditorCaption write FOnGetEditorCaption; - property ReadOnly : Boolean - read FReadOnly write FReadOnly default False; - property OnChanged : TNotifyEvent - read FOnChanged write FOnChanged; - property OnItemSelected : TVpItemSelectedEvent - read FOnItemSelected write FOnItemSelected; + property Item[Index: Integer] : TVpCollectionItem read GetItem write SetItem; default; + property OnGetEditorCaption : TVpGetEditorCaption read FOnGetEditorCaption write FOnGetEditorCaption; + property ReadOnly : Boolean read FReadOnly write FReadOnly default False; + property OnChanged : TNotifyEvent read FOnChanged write FOnChanged; + property OnItemSelected : TVpItemSelectedEvent read FOnItemSelected write FOnItemSelected; end; TVpContainerList = class(TList) @@ -378,8 +361,7 @@ type property Holiday: TColor read FHoliday write SetHoliday; property Weekday: TColor read FWeekday write SetWeekday; property Weekend: TColor read FWeekend write SetWeekend; - property ActiveRange: TVpTimeRange - read FActiveRange write FActiveRange; + property ActiveRange: TVpTimeRange read FActiveRange write FActiveRange; end; implementation @@ -404,11 +386,10 @@ end; { EAdFilterError } -constructor EVpFilterError.CreateError(const FilePos, Line, - LinePos: Integer; const Reason: DOMString); +constructor EVpFilterError.CreateError(const FilePos, Line, LinePos: Integer; + const Reason: DOMString); begin inherited CreateError(FilePos, Reason); - feLine := Line; feLinePos := LinePos; feReason := Reason; @@ -425,7 +406,7 @@ end; (*****************************************************************************) { TVpCustomControl } -constructor TVpCustomControl.Create (AOwner : TComponent); +constructor TVpCustomControl.Create (AOwner: TComponent); begin inherited Create (AOwner); TabStop := True; @@ -446,8 +427,8 @@ begin end; {=====} -procedure TVpCustomControl.DoOnMouseWheel(Shift: TShiftState; Delta, XPos, - YPos: SmallInt); +procedure TVpCustomControl.DoOnMouseWheel(Shift: TShiftState; + Delta, XPos, YPos: SmallInt); begin if Assigned(FOnMouseWheel) then FOnMouseWheel(Self, Shift, Delta, XPos, YPos); @@ -475,15 +456,16 @@ begin with Msg do DoOnMouseWheel(KeysToShiftState(LOWORD(wParam)) {fwKeys}, HIWORD(wParam) {zDelta}, - LOWORD(lParam) {xPos}, HIWORD(lParam) {yPos}); + LOWORD(lParam) {xPos}, + HIWORD(lParam) {yPos} + ); end; {=====} (*****************************************************************************) { TVpCollection } -constructor TVpCollection.Create(AOwner : TPersistent; - ItemClass : TCollectionItemClass); +constructor TVpCollection.Create(AOwner: TPersistent; ItemClass: TCollectionItemClass); begin FOwner := AOwner; Inherited Create(ItemClass); @@ -498,20 +480,20 @@ begin end; {=====} -procedure TVpCollection.DoOnItemSelected(Index : Integer); +procedure TVpCollection.DoOnItemSelected(Index: Integer); begin if Assigned(FOnItemSelected) then FOnItemSelected(Self, Index); end; {=====} -function TVpCollection.GetCount : Integer; +function TVpCollection.GetCount: Integer; begin Result := inherited Count; end; {=====} -function TVpCollection.GetEditorCaption : string; +function TVpCollection.GetEditorCaption: string; begin Result := 'Editing ' + ClassName; if Assigned(FOnGetEditorCaption) then @@ -519,7 +501,7 @@ begin end; {=====} -function TVpCollection.Add : TVpCollectionItem; +function TVpCollection.Add: TVpCollectionItem; begin Result := TVpCollectionItem(inherited Add); if ItemEditor <> nil then @@ -540,7 +522,7 @@ end; {=====} {$ENDIF} -function TVpCollection.GetItem(Index : Integer) : TVpCollectionItem; +function TVpCollection.GetItem(Index: Integer): TVpCollectionItem; begin Result := TVpCollectionItem(inherited GetItem(Index)); end; @@ -551,13 +533,13 @@ begin end; {=====} -procedure TVpCollection.SetItem(Index : Integer; Value : TVpCollectionItem); +procedure TVpCollection.SetItem(Index: Integer; Value: TVpCollectionItem); begin inherited SetItem(Index, Value); end; {=====} -function TVpCollection.ItemByName(const Name : string) : TVpCollectionItem; +function TVpCollection.ItemByName(const Name: string): TVpCollectionItem; var i : Integer; begin @@ -660,9 +642,10 @@ end; procedure TVpFont.Changed; begin inherited; - Assert((FOwner is TControl) or (FOwner is TVpPersistent), - Format('TVpFont.Changed: Unexpected parent class: %s', - [FOwner.ClassName])); + Assert( + (FOwner is TControl) or (FOwner is TVpPersistent), + Format('TVpFont.Changed: Unexpected parent class: %s', [FOwner.ClassName]) + ); if FOwner is TControl then TControl(FOwner).Invalidate else if FOwner is TVpPersistent then @@ -683,7 +666,6 @@ end; constructor TVpCategoryColorMap.Create; begin inherited Create; - FCat0 := TVpCategoryInfo.Create; FCat0.Color := clNavy; FCat0.Description := RSCategoryDesc0; @@ -787,25 +769,23 @@ end; constructor TVpCategoryInfo.Create; begin inherited Create; - - FBitmap := TBitmap.Create; + FBitmap := TBitmap.Create; FBackgroundColor := clWindow; end; destructor TVpCategoryInfo.Destroy; begin FBitmap.Free; - inherited Destroy; end; -procedure TVpCategoryInfo.SetBackgroundColor (const v : TColor); +procedure TVpCategoryInfo.SetBackgroundColor(const v: TColor); begin if v <> FBackgroundColor then FBackgroundColor := v; end; -procedure TVpCategoryInfo.SetBitmap (v : TBitmap); +procedure TVpCategoryInfo.SetBitmap(v: TBitmap); begin FBitmap.Assign (v); end; @@ -857,7 +837,6 @@ begin { start to be one hour earlier than the end } if FRangeBegin > Value then FRangeBegin := TVpHours(Ord(Value) - 1); - FRangeEnd := Value; SetEndTime((Ord(Value) * 60) / MinutesInDay); end; @@ -868,7 +847,6 @@ begin if Value < StartTime then StartTime := Value - (30 / MinutesInDay); FEndTime := Value; - if FOwner is TVpTimeSlotColor then (FOwner as TVpTimeSlotColor).Changed; end; @@ -879,7 +857,6 @@ begin if Value > EndTime then EndTime := Value + (30 / MinutesInDay); FStartTime := Value; - if FOwner is TVpTimeSlotColor then (FOwner as TVpTimeSlotColor).Changed; end; @@ -895,12 +872,12 @@ constructor TVpTimeSlotColor.Create(AOwner: TVpCustomControl); begin inherited Create; FOwner := AOwner; - FActiveRange := TVpTimeRange.Create(Self); + FActiveRange := TVpTimeRange.Create(Self); FInactive := $0080FFFF; - FHoliday := $00FF80FF; - FWeekend := $00FFFF80; - FActive := clWhite; - FWeekday := clWhite; + FHoliday := $00FF80FF; + FWeekend := $00FFFF80; + FActive := clWhite; + FWeekday := clWhite; end; {=====} diff --git a/components/tvplanit/source/vpflxds.pas b/components/tvplanit/source/vpflxds.pas index 8f7912ab4..4b524bf9c 100644 --- a/components/tvplanit/source/vpflxds.pas +++ b/components/tvplanit/source/vpflxds.pas @@ -193,7 +193,7 @@ type property OnGetNextID: TVpGetNextIDEvent read FOnGetNextID write FOnGetNextID; property OnCreateTable: TVpTableEvent - read FOnCreateTable write FOnCreateTable; + read FOnCreateTable write FOnCreateTable; property OnSetFilterCriteria: TVpSetFilterCriteriaEvent read FOnSetFilterCriteria write FOnSetFilterCriteria; end; @@ -210,10 +210,10 @@ constructor TVpFlexDataStore.Create(AOwner: TComponent); begin inherited; FResourceMappings := TCollection.Create(TVpFieldMapping); - FEventMappings := TCollection.Create(TVpFieldMapping); - FContactMappings := TCollection.Create(TVpFieldMapping); - FTaskMappings := TCollection.Create(TVpFieldMapping); - FDataSources := TVpDataSources.Create(self); + FEventMappings := TCollection.Create(TVpFieldMapping); + FContactMappings := TCollection.Create(TVpFieldMapping); + FTaskMappings := TCollection.Create(TVpFieldMapping); + FDataSources := TVpDataSources.Create(self); FConnected := false; FResourceID := 0; end; @@ -234,7 +234,7 @@ function TVpFlexDataStore.GetConnected: Boolean; var AllAssigned, AllActive: Boolean; begin - AllActive := false; + AllActive := false; AllAssigned := (FResourceDataSrc.DataSet <> nil) and (FEventsDataSrc.DataSet <> nil) and (FContactsDataSrc.DataSet <> nil) @@ -348,9 +348,8 @@ begin try FResourceDataSrc.DataSet.Open; except - if Assigned(OnCreateTable) then begin + if Assigned(OnCreateTable) then OnCreateTable(Self, ResourceTableName); - end; try FResourceDataSrc.DataSet.Open; except @@ -364,9 +363,8 @@ begin try FEventsDataSrc.DataSet.Open; except - if Assigned(OnCreateTable) then begin + if Assigned(OnCreateTable) then OnCreateTable(Self, EventsTableName); - end; try FEventsDataSrc.DataSet.Open; except @@ -380,9 +378,8 @@ begin try FContactsDataSrc.DataSet.Open; except - if Assigned(OnCreateTable) then begin + if Assigned(OnCreateTable) then OnCreateTable(Self, ContactsTableName); - end; try FContactsDataSrc.DataSet.Open; except @@ -396,9 +393,8 @@ begin try FTasksDataSrc.DataSet.Open; except - if Assigned(OnCreateTable) then begin + if Assigned(OnCreateTable) then OnCreateTable(Self, TasksTableName); - end; try FTasksDataSrc.DataSet.Open; except @@ -429,9 +425,8 @@ end; procedure TVpFlexDataStore.Load; var - Res : TVpResource; - {FieldName} - FN: string; + Res: TVpResource; + FN: string; // Field name begin if (csLoading in ComponentState) then Exit; @@ -538,21 +533,17 @@ var {Field Name} FN1, FN2, FN3 : string; begin - if (FEventsDataSrc = nil) - or (FEventsDataSrc.DataSet = nil) then + if (FEventsDataSrc = nil) or (FEventsDataSrc.DataSet = nil) then Exit; if (FResource <> nil) then begin { Load this resource's events into memory } - SetFilterCriteria(FEventsDataSrc.DataSet, - True, - FResource.ResourceID, - TimeRange.StartTime, - TimeRange.EndTime); + SetFilterCriteria(FEventsDataSrc.DataSet, True, FResource.ResourceID, + TimeRange.StartTime, TimeRange.EndTime); - if (FEventsDataSrc = nil) - or (FEventsDataSrc.DataSet = nil) - or (not FEventsDataSrc.DataSet.Active) then + if (FEventsDataSrc = nil) or + (FEventsDataSrc.DataSet = nil) or (not FEventsDataSrc.DataSet.Active) + then Exit; with FEventsDataSrc.Dataset do begin @@ -564,8 +555,8 @@ begin FN3 := GetFieldName(FEventMappings, 'EndTime'); if (FN1 <> '') and (FN2 <> '') and (FN3 <> '') then begin Event := Resource.Schedule.AddEvent(FieldByName(FN1).AsInteger, - FieldByName(FN2).AsDateTime, - FieldByName(FN3).AsDateTime); + FieldByName(FN2).AsDateTime, FieldByName(FN3).AsDateTime); + if Event <> nil then begin Event.Loading := true; @@ -688,187 +679,185 @@ var begin if (FResource <> nil) then begin {load this resource's contacts into memory} - if (FContactsDataSrc <> nil) - and (FContactsDataSrc.DataSet <> nil) - and (FContactsDataSrc.DataSet.Active) then - with FContactsDataSrc.DataSet do begin - SetFilterCriteria(FContactsDataSrc.DataSet, False, - FResource.ResourceID, 0, 0); - First; - while not EOF do begin - Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName)); - if Contact <> nil then begin - Contact.Loading := true; + if (FContactsDataSrc <> nil) and (FContactsDataSrc.DataSet <> nil) and FContactsDataSrc.DataSet.Active + then + with FContactsDataSrc.DataSet do begin + SetFilterCriteria(FContactsDataSrc.DataSet, False, FResource.ResourceID, 0, 0); + First; + while not EOF do begin + Contact := Resource.Contacts.AddContact(GetNextID(ContactsTableName)); + if Contact <> nil then begin + Contact.Loading := true; - FN := GetFieldName(FContactMappings, 'RecordID'); - if FN <> '' then - Contact.RecordID := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'RecordID'); + if FN <> '' then + Contact.RecordID := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'FirstName'); - if FN <> '' then - Contact.FirstName := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'FirstName'); + if FN <> '' then + Contact.FirstName := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'LastName'); - if FN <> '' then - Contact.LastName := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'LastName'); + if FN <> '' then + Contact.LastName := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'BirthDate'); - if FN <> '' then - Contact.Birthdate := FieldByName(FN).AsDateTime; + FN := GetFieldName(FContactMappings, 'BirthDate'); + if FN <> '' then + Contact.Birthdate := FieldByName(FN).AsDateTime; - FN := GetFieldName(FContactMappings, 'Anniversary'); - if FN <> '' then - Contact.Anniversary := FieldByName(FN).AsDateTime; + FN := GetFieldName(FContactMappings, 'Anniversary'); + if FN <> '' then + Contact.Anniversary := FieldByName(FN).AsDateTime; - FN := GetFieldName(FContactMappings, 'Title'); - if FN <> '' then - Contact.Title := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Title'); + if FN <> '' then + Contact.Title := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Company'); - if FN <> '' then - Contact.Company := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Company'); + if FN <> '' then + Contact.Company := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Job_Position'); - if FN = '' then - FN := GetFieldName(FContactMappings, 'Position'); // deprecated - if FN <> '' then - Contact.Job_Position := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Job_Position'); + if FN = '' then + FN := GetFieldName(FContactMappings, 'Position'); // deprecated + if FN <> '' then + Contact.Job_Position := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'EMail'); - if FN <> '' then - Contact.EMail := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'EMail'); + if FN <> '' then + Contact.EMail := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Address'); - if FN <> '' then - Contact.Address := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Address'); + if FN <> '' then + Contact.Address := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'City'); - if FN <> '' then - Contact.City := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'City'); + if FN <> '' then + Contact.City := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'State'); - if FN <> '' then - Contact.State := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'State'); + if FN <> '' then + Contact.State := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Zip'); - if FN <> '' then - Contact.Zip := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Zip'); + if FN <> '' then + Contact.Zip := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Country'); - if FN <> '' then - Contact.Country := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Country'); + if FN <> '' then + Contact.Country := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Notes'); - if FN = '' then - FN := GetFieldName(FContactMappings, 'Note'); // deprecated - if FN <> '' then - Contact.Notes := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Notes'); + if FN = '' then + FN := GetFieldName(FContactMappings, 'Note'); // deprecated + if FN <> '' then + Contact.Notes := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Phone1'); - if FN <> '' then - Contact.Phone1 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Phone1'); + if FN <> '' then + Contact.Phone1 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Phone2'); - if FN <> '' then - Contact.Phone2 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Phone2'); + if FN <> '' then + Contact.Phone2 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Phone3'); - if FN <> '' then - Contact.Phone3 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Phone3'); + if FN <> '' then + Contact.Phone3 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Phone4'); - if FN <> '' then - Contact.Phone4 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Phone4'); + if FN <> '' then + Contact.Phone4 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Phone5'); - if FN <> '' then - Contact.Phone5 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Phone5'); + if FN <> '' then + Contact.Phone5 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'PhoneType1'); - if FN <> '' then - Contact.PhoneType1 := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'PhoneType1'); + if FN <> '' then + Contact.PhoneType1 := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'PhoneType2'); - if FN <> '' then - Contact.PhoneType2 := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'PhoneType2'); + if FN <> '' then + Contact.PhoneType2 := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'PhoneType3'); - if FN <> '' then - Contact.PhoneType3 := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'PhoneType3'); + if FN <> '' then + Contact.PhoneType3 := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'PhoneType4'); - if FN <> '' then - Contact.PhoneType4 := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'PhoneType4'); + if FN <> '' then + Contact.PhoneType4 := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'PhoneType5'); - if FN <> '' then - Contact.PhoneType5 := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'PhoneType5'); + if FN <> '' then + Contact.PhoneType5 := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'Category'); - if FN <> '' then - Contact.Category := FieldByName(FN).AsInteger; + FN := GetFieldName(FContactMappings, 'Category'); + if FN <> '' then + Contact.Category := FieldByName(FN).AsInteger; - FN := GetFieldName(FContactMappings, 'Custom1'); - if FN <> '' then - Contact.Custom1 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Custom1'); + if FN <> '' then + Contact.Custom1 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Custom2'); - if FN <> '' then - Contact.Custom2 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Custom2'); + if FN <> '' then + Contact.Custom2 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Custom3'); - if FN <> '' then - Contact.Custom3 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Custom3'); + if FN <> '' then + Contact.Custom3 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'Custom4'); - if FN <> '' then - Contact.Custom4 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'Custom4'); + if FN <> '' then + Contact.Custom4 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField0'); - if FN <> '' then - Contact.UserField0 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField0'); + if FN <> '' then + Contact.UserField0 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField1'); - if FN <> '' then - Contact.UserField1 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField1'); + if FN <> '' then + Contact.UserField1 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField2'); - if FN <> '' then - Contact.UserField2 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField2'); + if FN <> '' then + Contact.UserField2 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField3'); - if FN <> '' then - Contact.UserField3 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField3'); + if FN <> '' then + Contact.UserField3 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField4'); - if FN <> '' then - Contact.UserField4 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField4'); + if FN <> '' then + Contact.UserField4 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField5'); - if FN <> '' then - Contact.UserField5 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField5'); + if FN <> '' then + Contact.UserField5 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField6'); - if FN <> '' then - Contact.UserField6 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField6'); + if FN <> '' then + Contact.UserField6 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField7'); - if FN <> '' then - Contact.UserField7 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField7'); + if FN <> '' then + Contact.UserField7 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField8'); - if FN <> '' then - Contact.UserField8 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField8'); + if FN <> '' then + Contact.UserField8 := FieldByName(FN).AsString; - FN := GetFieldName(FContactMappings, 'UserField9'); - if FN <> '' then - Contact.UserField9 := FieldByName(FN).AsString; + FN := GetFieldName(FContactMappings, 'UserField9'); + if FN <> '' then + Contact.UserField9 := FieldByName(FN).AsString; - Contact.Loading := false; - end; - Next; - end; {while} - end; {with ContactsTable} + Contact.Loading := false; + end; + Next; + end; {while} + end; {with ContactsTable} end; {if Resource <> nil} end; {=====} @@ -881,12 +870,10 @@ var begin if (FResource <> nil) then begin {load this resource's contacts into memory} - if (FTasksDataSrc <> nil) - and (FTasksDataSrc.DataSet <> nil) - and (FTasksDataSrc.DataSet.Active) then begin + if (FTasksDataSrc <> nil) and (FTasksDataSrc.DataSet <> nil) and (FTasksDataSrc.DataSet.Active) then + begin with FTasksDataSrc.DataSet do begin - SetFilterCriteria(FTasksDataSrc.DataSet, False, FResource.ResourceID, - 0, 0); + SetFilterCriteria(FTasksDataSrc.DataSet, False, FResource.ResourceID, 0, 0); First; while not EOF do begin Task := Resource.Tasks.AddTask(GetNextID(TasksTableName)); @@ -1000,7 +987,6 @@ begin then FResourceDataSrc.DataSet.Open; if FResourceDataSrc.DataSet.Active then begin - with FResourceDataSrc.DataSet do begin { if a resource } FN := GetFieldName(FResourceMappings, 'ResourceID'); @@ -1115,20 +1101,17 @@ var FN: string; begin {if no events dataset has been defined then bail.} - if (FEventsDataSrc = nil) - or (FEventsDataSrc.DataSet = nil) then + if (FEventsDataSrc = nil) or (FEventsDataSrc.DataSet = nil) then Exit; if (Resource <> nil) and Resource.EventsDirty then begin { Dump this resource's dirty events to the DB } - if (FResourceDataSrc <> nil) - and (FResourceDataSrc.DataSet <> nil) then begin - + if (FResourceDataSrc <> nil) and (FResourceDataSrc.DataSet <> nil) then + begin FResourceDataSrc.DataSet.Open; FN := GetFieldName(FEventMappings, 'ResourceID'); - if (FN <> '') - and FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, []) + if (FN <> '') and FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, []) then begin SetFilterCriteria(FEventsDataSrc.DataSet, False, Resource.ResourceID, 0, 0); @@ -1160,7 +1143,6 @@ begin if Event.RecordID <> -1 then EventsTable.FieldByName(FN).AsInteger := Event.RecordID; - FN := GetFieldName(FEventMappings, 'StartTime'); if FN <> '' then EventsTable.FieldByName(FN).AsDateTime := Event.StartTime; @@ -1287,11 +1269,9 @@ begin if Event.RecordID = -1 then begin FN := GetFieldName(EventMappings, 'RecordID'); if FN <> '' then - Event.RecordID - := EventsTable.FieldByName(FN).AsInteger; + Event.RecordID := EventsTable.FieldByName(FN).AsInteger; end; - (* Bad Phillip. if Event.RecordID = -1 then Event.RecordID := EventsTable.FieldByName('RecordID').AsInteger; @@ -1332,8 +1312,8 @@ begin { if the delete flag is set then delete the record } { and free the event instance } if Contact.Deleted then begin - if ContactsTable.Locate(FN, Contact.RecordID, []) - then ContactsTable.Delete; + if ContactsTable.Locate(FN, Contact.RecordID, []) then + ContactsTable.Delete; Contact.Free; Continue; end; @@ -1530,7 +1510,7 @@ begin if Contact.RecordID = -1 then begin FN := GetFieldName(FContactMappings, 'RecordID'); if FN <> '' then - Contact.RecordID := ContactsTable.FieldByName(FN).AsInteger; + Contact.RecordID := ContactsTable.FieldByName(FN).AsInteger; end; Contact.Changed := false; @@ -1552,14 +1532,14 @@ var begin if (Resource <> nil) and Resource.TasksDirty then begin - if (FResourceDataSrc <> nil) - and (FResourceDataSrc.Dataset <> nil) then begin + if (FResourceDataSrc <> nil) and (FResourceDataSrc.Dataset <> nil) then + begin FResourceDataSrc.DataSet.Open; if FResourceDataSrc.DataSet.Active then begin FN := GetFieldName(FTaskMappings, 'ResourceID'); { Dump this resource's dirty contacts to the DB } - if not FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, []) - then Exit; + if not FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, []) then + Exit; end; {if FResourceDataSrc.DataSet.Active} end; {if (FResourceDataSrc ...} @@ -1569,9 +1549,7 @@ begin for I := pred(Resource.Tasks.Count) downto 0 do begin with FTasksDataSrc.DataSet do begin - Task := Resource.Tasks.GetTask(I); - FN := GetFieldName(FTaskMappings, 'RecordID'); { if the delete flag is set then delete the record } @@ -1584,15 +1562,14 @@ begin end; if Task.Changed then begin - if Locate(FN, Task.RecordID, []) - then + if Locate(FN, Task.RecordID, []) then { this event already exists in the database so update it } Edit else { this record doesn't exist in the database, so it's a new event } Append; - try + try { DataStore descendants that can use an autoincrement RecordID } { field set the RecordID to -1 by default. If the RecordID is } { -1 then this is a new record and we shouldn't overwrite } @@ -1726,7 +1703,6 @@ begin FN := GetFieldName(FResourceMappings, 'ResourceID'); if (FN <> '') then begin - if (Res <> nil) and Res.Deleted then begin PurgeEvents(Res); PurgeContacts(Res); @@ -1850,9 +1826,8 @@ procedure TVpFlexDataStore.PurgeEvents(Res: TVpResource); var I: integer; 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; - end; PostEvents; Res.Schedule.ClearEvents; end; @@ -1863,9 +1838,8 @@ procedure TVpFlexDataStore.PurgeContacts(Res: TVpResource); var I: integer; 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; - end; PostContacts; Res.Contacts.ClearContacts; end; @@ -1876,9 +1850,8 @@ procedure TVpFlexDataStore.PurgeTasks(Res: TVpResource); var I: integer; 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; - end; PostTasks; Res.Tasks.ClearTasks; end; @@ -2079,7 +2052,6 @@ begin { for each table. } result := -1; - if Assigned(OnGetNextID) then result := OnGetNextID(Self, TableName); end; @@ -2203,5 +2175,4 @@ end; {=====} - end.