search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Events not rendering in Scheduler

Asked by Ozzie
13 years ago.

Hi,

After having some fun with this question ( http://forums.daypilot.org/Topic.aspx/1426/daypilot-scheduler---is-this-possible ) i have holidays, weekends, and resources / lessons displaying as required and now need to display the booking data itself but having problems showing any bookings.

This is my GetRoomBookedData sub that i call when the navigator date is selected but nothing shows up:

Protected Sub GetRoomBookedData(ByVal start As DateTime)

Dim objConnection As SqlConnection
Dim objCommand As SqlCommand
Dim currentDay As String = OPSDfunctions.ConvertDateFormat(start)

'set up the scheduler
DayPilotScheduler1.Days = "1"
DayPilotScheduler1.RowHeaderWidth = "160"
DayPilotScheduler1.DataStartField = "time_start"
DayPilotScheduler1.DataEndField = "time_end"
DayPilotScheduler1.DataTextField = "notes"
DayPilotScheduler1.DataValueField = "booking_id"
DayPilotScheduler1.HeaderFontSize = "8pt"
DayPilotScheduler1.HeaderHeight = "17"
DayPilotScheduler1.DataResourceField = "room_id"
DayPilotScheduler1.EventHeight = "40"
DayPilotScheduler1.ShowNonBusiness = "false"
DayPilotScheduler1.CellDuration = "60"
DayPilotScheduler1.BusinessBeginsHour = "0"
DayPilotScheduler1.BusinessEndsHour = "5"
DayPilotScheduler1.DataTagFields = "status,notes"

objConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("OPSDConnectionString").ConnectionString)
objCommand = New SqlCommand("SELECT tblrb_bookings.booking_id, tblrb_bookings.status, tblrb_bookings.room_id, tblrb_bookings.notes, tblrb_periods.time_start, tblrb_periods.time_end, tblrb_periods.bookable FROM tblrb_bookings INNER JOIN tblrb_rooms ON tblrb_bookings.room_id = tblrb_rooms.room_id INNER JOIN tblrb_periods ON tblrb_bookings.period_id = tblrb_periods.period_id WHERE (tblrb_bookings.booking_date = '" & currentDay & "') AND tblrb_periods.bookable = 1 ORDER BY tblrb_periods.time_start ASC", objConnection)

Try
objConnection.Open()
DayPilotScheduler1.DataSource = objCommand.ExecuteReader()
DayPilotScheduler1.DataBind()
DayPilotScheduler1.Update(CallBackUpdateType.Full)

Catch ex As Exception

'Inform of the error
Elmah.ErrorSignal.FromCurrentContext().Raise(ex)

Finally
objCommand.Dispose()
objConnection.Close()
objConnection.Dispose()

End Try

End Sub

I have stepped through this an now errors are thrown and running the query within SQL Server returns the correct data for the day in question. How do i ensure that the correct booking shows for the correct resource and the correct time.

These are the other thre Subs used.

Protected Sub DayPilotScheduler1_Command(sender As Object, e As DayPilot.Web.Ui.Events.CommandEventArgs)
Select Case e.Command

Case "navigate"
DayPilotScheduler1.StartDate = e.Data("start")

'Build the week bar
BuildNavBar(e.Data("start"))

'Load the resource data
LoadResources()

'Check Weekend
CheckWeekend(e.Data("start"))

'Check holiday
CheckHoliday(e.Data("start"))

'load booking data
GetRoomBookedData(e.Data("start"))

Exit Select
End Select

End Sub

Protected Sub DayPilotScheduler1_BeforeEventRender(sender As Object, e As BeforeEventRenderEventArgs)

Dim status As Integer = e.Tag("status")
Select Case status
Case 1 ' "timetabled"
'timetabled lesson
e.BackgroundColor = "#E68A73"
e.EventClickEnabled = False
e.EventDoubleClickEnabled = False

Case 2 '"staff"
'staff booked lesson
e.BackgroundColor = "#3082BF"
e.EventClickEnabled = False
e.EventDoubleClickEnabled = False

Case Else '"free"
'room is available to book.
e.BackgroundColor = "#FFFFFF"
e.InnerHTML = "<br /><br /><div style='text-align:center; vertical-align:middle;'><img src='../Content/icons/accept.png' alt='Click here to book' /> Book</div>"

End Select

End Sub

Protected Sub DayPilotScheduler1_BeforeCellRender(sender As Object, e As BeforeCellRenderEventArgs)

'Grey out all cells that are before today
If e.Start < DateTime.Today Then

If e.IsBusiness Then
e.BackgroundColor = "#D5D5C0"
End If

End If

End Sub

Any guideance would be much apreciated

Answer posted by Dan Letecky [DayPilot]
13 years ago.

Please check the following guide:

http://kb.daypilot.org/101644/events-not-showing-up-in-the-scheduler/

The most important thing to check is that the resource id (Resource.Value) matches the resource id for the event (DataResourceField). It must match exactly (including case and spaces...).

Please let me know if it didn't help.

Comment posted by Ozzie
13 years ago.

Hi Dan,

Yeah I did have a look at that but I think this is OK as the resource ID in the database is room_id and the init code for daypilot is as follows:

DayPilotScheduler1.DataResourceField = "room_id"

So this is OK, I think it is more to do with time placement of the booking itself. The bookings will run in slot of non even time i.e. 9:15 to 10:15 and we are using the following to define these slots:

DayPilotScheduler1.ShowNonBusiness = "false"
DayPilotScheduler1.CellDuration = "60"
DayPilotScheduler1.BusinessBeginsHour = "0"
DayPilotScheduler1.BusinessEndsHour = "5"

however our start and end fields are:

DayPilotScheduler1.DataStartField = "time_start"
DayPilotScheduler1.DataEndField = "time_end"

As these time are NOT visible within the booking area i would assume they are not being shown, the question is how to map the time of the booking to the businesshour slot?

Comment posted by Dan Letecky [DayPilot]
13 years ago.

Oh, yes, I forgot you are mapping the lessons to hours.

What is the actual content of the time_start/time_end fields? Does it contain the real time, i.e. 9:15 to 10:15?

If you are able to change that (i.e. if you are designing the db schema as well) you should store it directly as the mapped hours, i.e. 00:00 to 01:00 instead of 9:15 to 10:15.

If you have an existing db filled with data, you will have to run the data set through a custom method that will change these two fields accordingly - before you pass it to DayPilotScheduler.DataSource property.

Just a note, the time_start/time_end fields should also include the date part, otherwise it will be translated to 0001-01-01 or the current day or some other unexpected value.

Comment posted by Ozzie
13 years ago.

Hi Dan,

Yes the time_start/time_end fields do contain the actual start and end times of the lessons i.e. 9:15 to 10:15

I will manually changes the start and end time for the test bookings I have to see if that gets the bookings to display, If it does then I think I will need to have some sort of custom method as I will not know the number of lessons that a user may setup.

I'll let you know later today.

Answer posted by Ozzie
13 years ago.

Hi Dan,

Thanks for you help on this I now have it all working as required.

To resolve the issue I created a stored procedure with a case statement based on the order of the lessons (these can be ordered in anyway via the UI) the CASE statement then create 2 virtual fields and these are then fed into the data source for the scheduler as you can see below:

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[sp_DisplayBookingData]
-- Add the parameters for the stored procedure here
@today DateTime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

  • Insert statements for procedure here

SELECT
tblrb_bookings.booking_id,
tblrb_bookings.status,
tblrb_bookings.room_id,
tblrb_bookings.notes,
tblrb_periods.time_start,
tblrb_periods.time_end,
tblrb_periods.bookable,
'real_start' =
CASE
WHEN tblrb_periods.period_order = 0 THEN @today + ' 00:00:00'
WHEN tblrb_periods.period_order = 1 THEN @today + ' 01:00:00'
WHEN tblrb_periods.period_order = 2 THEN @today + ' 02:00:00'
WHEN tblrb_periods.period_order = 3 THEN @today + ' 03:00:00'
WHEN tblrb_periods.period_order = 4 THEN @today + ' 04:00:00'
WHEN tblrb_periods.period_order = 5 THEN @today + ' 05:00:00'
WHEN tblrb_periods.period_order = 6 THEN @today + ' 06:00:00'
WHEN tblrb_periods.period_order = 7 THEN @today + ' 07:00:00'
WHEN tblrb_periods.period_order = 8 THEN @today + ' 08:00:00'
WHEN tblrb_periods.period_order = 9 THEN @today + ' 09:00:00'
WHEN tblrb_periods.period_order = 10 THEN @today + ' 10:00:00'
END,
'real_end' =
CASE
WHEN tblrb_periods.period_order = 0 THEN @today + ' 01:00:00'
WHEN tblrb_periods.period_order = 1 THEN @today + ' 02:00:00'
WHEN tblrb_periods.period_order = 2 THEN @today + ' 03:00:00'
WHEN tblrb_periods.period_order = 3 THEN @today + ' 04:00:00'
WHEN tblrb_periods.period_order = 4 THEN @today + ' 05:00:00'
WHEN tblrb_periods.period_order = 5 THEN @today + ' 06:00:00'
WHEN tblrb_periods.period_order = 6 THEN @today + ' 07:00:00'
WHEN tblrb_periods.period_order = 7 THEN @today + ' 08:00:00'
WHEN tblrb_periods.period_order = 8 THEN @today + ' 09:00:00'
WHEN tblrb_periods.period_order = 9 THEN @today + ' 10:00:00'
WHEN tblrb_periods.period_order = 10 THEN @today + ' 11:00:00'
END
FROM tblrb_bookings
INNER JOIN tblrb_rooms ON tblrb_bookings.room_id = tblrb_rooms.room_id
INNER JOIN tblrb_periods ON tblrb_bookings.period_id = tblrb_periods.period_id
WHERE (tblrb_bookings.booking_date = @today) AND tblrb_periods.bookable = 1
ORDER BY tblrb_periods.period_order ASC
END

Comment posted by Rakhi
11 years ago.

Hi this is Rakhi

even my sceduler was having the same problem.event was not getting displayed in the scheduler but now its working.Is there any other way of entering the time instead of entering it manually in the db..please help

Comment posted by Dan Letecky [DayPilot]
11 years ago.

If you need to map the lessons/time slots to time part of the date please check the Timetable tutorial:

http://code.daypilot.org/65101/timetable-tutorial-asp-net-c-vb-net

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.