The item is only in one day. Once moved, the item has no time. I need to keep them. Because then I don't see her in TDBPlaner. Times no longer exist in the dbpmwMonthItemToFields event. I can solve it with variables.
Q: How do I get times into item it after moving an item?
The time is not displayed in the item header. But twice the date. This is confusing for the user. The date is not even needed. He's in the cell. This seems logical for an item over several days. But the user again sees the item stretched across multiple cells. True, he may not see them all. The following can be programmatically provided in the component:
- one day = Date + time
- multiple days = Date + time - Date + time. We have enough places (?)
Q: Can I display the time or the date and time in the header?
This depends on the Planner mode. The time after moving an item is the time of the time slot the item is moved to.
This planner always cuts the time! There is no timeline here. Personally, I consider this a mistake. Time is to leave it as it is. I solved it using a variable.
Thanks.
procedure TfrmPlannerRole.dbpmwMonthMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
Item: TPlannerItem;
DateTime: TDateTime;
begin
case TPage(offpgrPlanner.ActivePageIndex) of
TPage.Day:
begin
Item := dbplDay.XYToItem(X, Y);
if Assigned(Item) then
dbplDay.Items.Select(Item);
end;
TPage.Week:
begin
Item := dbplWeek.XYToItem(X, Y);
if Assigned(Item) then
dbplWeek.Items.Select(Item);
end;
TPage.Month:
begin
dbpmwMonth.DateAtXY(X, Y, DateTime);
Item := dbpmwMonth.Items.FindItemAtDate(DateTime, X, Y);
if Assigned(Item) then
dbpmwMonth.Items.Select(Item);
end;
end;
end;
procedure TfrmPlannerRole.dbpmwMonthItemToFields(Sender: TObject; Fields: TFields; Item: TPlannerItem);
var
NewItem: Boolean;
begin
NewItem := Item.DBKey = '';
if NewItem then
begin
Item.DBKey := IntToStr(NewPrimaryKey);
Item.CaptionType := ctTime;
Item.CaptionText := 'Vytvorené automaticky';
Item.Text.Text := Item.CaptionText;
Item.Shape := psRect;
Item.Tag := -1;
end;
if not NewItem and (Sender is TDBPlannerMonthView) then
begin
Fields.FieldByName('STARTTIME').AsDateTime := PlanDates[StartTime];
Fields.FieldByName('ENDTIME').AsDateTime := PlanDates[EndTime];
end;
Fields.FieldByName('IDPLANNERS').AsInteger := StrToInt(Item.DBKey);
Fields.FieldByName('IMAGE').AsInteger := Item.ImageID;
Fields.FieldByName('CAPTIONTYPE').AsInteger := Ord(TCaptionType(Item.CaptionType));
Fields.FieldByName('Flashing').AsInteger := TBasicFunction.BooleanToInt(Item.Flashing);
Fields.FieldByName('FKUSERAPPS').AsInteger := oGlobVar.IDUserApps;
ItemToFieldsString(Fields, Item);
ItemToFieldsAlarm(Fields, Item);
if Item.Tag = -1 then
Fields.FieldByName('SHAPE').AsInteger := Ord(TPlannerShape(Item.Shape))
else
Fields.FieldByName('SHAPE').AsInteger := Item.Tag + Shift;
end;