How to persist changes made to an allocation by the user dragging and/or resizing it.


You need to implement handlers for the OnAllocationDragEnd and/or OnAllocationStretchEnd events. In these handlers, you need to store the new values of the allocation's StartAt and EndAt properties. Exactly how you do this depends on the specifics of your chosen data store.

As one example, when you create an allocation on the chart, you could store the allocation's database record ID in the Tag property. That record ID would then be available when you need to update the data store with the allocation's new date/times.

procedure TForm1.RACAllocationDragEnd(Sender: TObject;
                                      Resource: TssResource;
                                      Allocation: TssResourceAllocation);
begin
  // call a stored procedure to update the allocation
  // record with the new start and end times
  with spUpdateAllocation do begin
    // get the allocation's record ID from its tag
    Parameters.FindParam('@ID').Value := Allocation.Tag;
    Parameters.FindParam('@StartAt').Value := Allocation.StartAt;
    Parameters.FindParam('@EndAt').Value := Allocation.EndAt;
    Execute;
  end;
end;