How to add an allocation to a resource.


One you have a reference to a resource, call the AddSlot method to add an allocation.

var
  r: TssResource;
  a: TssResourceAllocation;
begin
  r := RAC.FindResource('My Resource');
  if Assigned(r) then begin
    RAC.BeginUpdate;
    try
      // add an allocation 1 hour long starting Now
      a := r.AddSlot(Now, Now + EncodeTime(1, 0, 0, 0);
      // check not nil, in case the allocation could not be added
      if Assigned(a) then
        // use the returned reference to the new allocation
        // in this example, we'll store the record ID in the Tag
        a.Tag := IntToStr(AllocationRecordID);
    finally
      RAC.EndUpdate;
    end;
  end;
end;

Note: It is important to test that AddSlot did not return nil. If the time span is already occupied, AddSlot will not add a new allocation and will return nil.

What People Say

Resource Allocation Chart is one of those rare components that really fires the imagination. It looks great and is extremely flexible. A must for any application that allocates time slots.
Trevor Pegley, Visionhall
More …

No malware No spam
McAfee Site Report
Web of Trust