From bd7a54463509a4ddd2175867b501a3efad818f59 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 14 Oct 2022 21:26:21 +0000 Subject: [PATCH] tvplanit: Fix event editor storing new events with ResourceID 0. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8561 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/tvplanit/examples/printing/ganttview/data.ini | 4 +++- components/tvplanit/source/vpdata.pas | 1 + components/tvplanit/source/vpganttview.pas | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/tvplanit/examples/printing/ganttview/data.ini b/components/tvplanit/examples/printing/ganttview/data.ini index ce9746191..fa8e794ef 100644 --- a/components/tvplanit/examples/printing/ganttview/data.ini +++ b/components/tvplanit/examples/printing/ganttview/data.ini @@ -16,6 +16,8 @@ Version=v105 1387047049={StartTime:2022/10/07 09:00:00}|{EndTime:2022/10/07 13:00:00}|{ResourceID:1178568021}|{Description:Test Recurring daily}|{Category:0}|{AllDayEvent:false}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtCustom}|{RepeatRangeEnd:2022/10/30}|{CustomInterval:4} 939711377={StartTime:2022/10/08 10:00:00}|{EndTime:2022/10/08 10:30:00}|{ResourceID:1178568021}|{Description:Test}|{Category:3}|{AllDayEvent:false}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} 1294424480={StartTime:2022/10/15 08:00:00}|{EndTime:2022/10/15 08:30:00}|{ResourceID:1178568021}|{Description:All-day event Oct 15}|{Category:2}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} -1915067938={StartTime:2022/10/25}|{EndTime:2022/10/25 23:59:00}|{ResourceID:0}|{Description:test abc}|{Category:3}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{RepeatRangeEnd:4637/11/25}|{CustomInterval:0} +121790187={StartTime:2022/10/17}|{EndTime:2022/10/17 23:59:00}|{ResourceID:1178568021}|{Description:xyz}|{Category:0}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{RepeatRangeEnd:4637/11/25}|{CustomInterval:0} +1915067938={StartTime:2022/10/25}|{EndTime:2022/10/25 23:59:00}|{ResourceID:1178568021}|{Description:test abc}|{Category:3}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{RepeatRangeEnd:4637/11/25}|{CustomInterval:0} 638950699={StartTime:2022/10/26}|{EndTime:2022/11/03}|{ResourceID:1178568021}|{Description:Test All-day events Oct26-Nov3}|{Category:0}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} +2069450027={StartTime:2022/11/01}|{EndTime:2022/11/01 23:59:00}|{ResourceID:1178568021}|{Description:test 1.nov}|{Category:0}|{AllDayEvent:true}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{RepeatRangeEnd:4637/11/25}|{CustomInterval:0} 825453432={StartTime:2022/11/07 08:00:00}|{EndTime:2022/11/07 19:00:00}|{ResourceID:1178568021}|{Description:Test Nov-07}|{Category:2}|{AllDayEvent:false}|{AlarmSet:false}|{AlarmAdvance:15}|{AlarmAdvanceType:atMinutes}|{RepeatCode:rtNone}|{CustomInterval:0} diff --git a/components/tvplanit/source/vpdata.pas b/components/tvplanit/source/vpdata.pas index 6b8435e96..e75e7b0d2 100644 --- a/components/tvplanit/source/vpdata.pas +++ b/components/tvplanit/source/vpdata.pas @@ -1801,6 +1801,7 @@ begin Result.Loading := true; FEventList.Add(Result); Result.RecordID := RecordID; + Result.ResourceID := Owner.ResourceID; Result.StartTime := StartTime; Result.EndTime := EndTime; Result.Loading := false; diff --git a/components/tvplanit/source/vpganttview.pas b/components/tvplanit/source/vpganttview.pas index 36d3d42c3..23195afa2 100644 --- a/components/tvplanit/source/vpganttview.pas +++ b/components/tvplanit/source/vpganttview.pas @@ -896,12 +896,13 @@ begin begin startTime := DatePart(dt); endTime := startTime + 1.0 - OneSecond; - ActiveEvent := Datastore.Resource.Schedule.AddEvent( + FActiveEvent := Datastore.Resource.Schedule.AddEvent( Datastore.GetNextID(EventsTableName), startTime, endTime ); FActiveEvent.AllDayEvent := true; + SetActiveEvent(FActiveEvent); SpawnEventEditDialog(True); end; end;