I’m not able to update existing event after i navigated to another page but it’s working fine if i don’t. It happened during the debugging mode as well. I’m not able to update existing event created in previous debug session.
[code]Scheduler = New DHXScheduler()
Scheduler.Extensions.Add(SchedulerExtensions.Extension.Recurring)
Scheduler.Config.first_hour = 8
Scheduler.Config.last_hour = 19
Scheduler.Config.time_step = 30
Scheduler.Config.limit_time_select = True
Scheduler.Skin = DHXScheduler.Skins.Flat
Scheduler.DataAction = Me.ResolveUrl("~/Connector.ashx")
Scheduler.SaveAction = Me.ResolveUrl("~/Save.ashx")
Scheduler.LoadData = True
Scheduler.EnableDataprocessor = True
‘Title’
Dim titl = New LightboxText(“text”, “Title”)
titl.Height = 30
Scheduler.Lightbox.Add(titl)
‘Description’
Dim descr = New LightboxText(“event_details”, “Description”)
descr.Height = 60
Scheduler.Lightbox.Add(descr)
‘Venue’
Dim venue = New LightboxText(“event_venue”, “Venue”)
venue.Height = 30
Scheduler.Lightbox.Add(venue)
'Recurring options
Scheduler.Lightbox.Add(New LightboxRecurringBlock(“rec_type”, “Recurring”))
‘Time’
Scheduler.Lightbox.Add(New LightboxTime(“time”))[/code]
[code]Protected Function deleteRelated(ByVal action As DataAction, ByVal changedEvent As Events_Tran, ByVal context As SchedulerDataContext) As Boolean
Dim finished As Boolean = False
If (action.Type = DataActionTypes.Delete OrElse action.Type = DataActionTypes.Update) AndAlso Not String.IsNullOrEmpty(changedEvent.rec_type) Then
context.Events_Trans.DeleteAllOnSubmit(From ev In context.Events_Trans Where ev.event_pid = changedEvent.id)
End If
If action.Type = DataActionTypes.Delete AndAlso changedEvent.event_pid <> 0 Then
Dim changed As Events_Tran = (From ev In context.Events_Trans Where ev.id = action.TargetId).Single
changed.rec_type = “none”
finished = True
End If
Return finished
End Function
Protected Function insertRelated(ByVal action As DataAction, ByVal changedEvent As Events_Tran, ByVal context As SchedulerDataContext) As DataAction
If action.Type = DataActionTypes.Insert AndAlso changedEvent.rec_type = "none" Then
'insert_related
action.Type = DataActionTypes.Delete
End If
Return action
End Function
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
context.Response.ContentType = "text/xml"
Dim action = New DataAction(context.Request.Form)
Dim data = New SchedulerDataContext()
Try
Dim changedEvent = DirectCast(DHXEventsHelper.Bind(GetType(Events_Tran), context.Request.Form), Events_Tran)
Dim isFinished As Boolean = deleteRelated(action, changedEvent, data)
If Not isFinished Then
Select Case action.Type
Case DataActionTypes.Insert
' define here your Insert logic
data.Events_Trans.InsertOnSubmit(changedEvent)
Exit Select
Case DataActionTypes.Delete
' define here your Delete logic
changedEvent = data.Events_Trans.SingleOrDefault(Function(ev) ev.id = action.SourceId)
data.Events_Trans.DeleteOnSubmit(changedEvent)
Exit Select
Case Else
' "update" // define here your Update logic
Dim updated = data.Events_Trans.SingleOrDefault(Function(ev) ev.id = action.SourceId)
DHXEventsHelper.Update(updated, changedEvent, New List(Of String)() From {"id"})
Exit Select
End Select
End If
data.SubmitChanges()
action.TargetId = changedEvent.id
action = insertRelated(action, changedEvent, data)
Catch a As Exception
action.Type = DataActionTypes.[Error]
End Try
context.Response.Write(New AjaxSaveResponse(action).ToString())
End Sub
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property[/code]
[code]Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
‘’// Filter only event with Category = “Member”
'Dim dc = New SchedulerDataContext()
'Dim dataset As IEnumerable(Of Events_Tran)
'dataset = From ev In dc.Events_Trans
’ Where ev.Code3 = “Member” Select ev 'Code3 = Assigned to which access level
‘’// Filter only event with Category = “Member”
Dim dataResult As SchedulerAjaxData
dataResult = New SchedulerAjaxData((New SchedulerDataContext()).Events_Trans) '<--Enable this to load all record
'dataResult = New SchedulerAjaxData(dataset)
context.Response.ContentType = "application/json"
context.Response.Write(dataResult.ToString())
End Sub
ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
Get
Return False
End Get
End Property[/code]