This is a migrated thread and some comments may be shown as answers.

Show Custom Form - Edit appointment

10 Answers 395 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Karen
Top achievements
Rank 1
Karen asked on 29 Jul 2014, 03:43 PM
Hello
I downloaded the demo of Telerik Q2 2014. 
I'm trying Scheduler and Reminder in visual basic 2013. NetFramework 

In the event AppointmentEditDialogShowing RadScheduler1 
I try to show the custom form. 

Private Sub radScheduler1_AppointmentEditDialogShowing (sender As Object, e As AppointmentEditDialogShowingEventArgs) 
e.AppointmentEditDialog = New CustomForm()

End Sub 


I took the code from the following thread
http://www.telerik.com/forums/custom-edit-dialog

but displays an error "System.InvalidCastException"

I try 

Private Sub radScheduler1_AppointmentEditDialogShowing (sender As Object, e As AppointmentEditDialogShowingEventArgs)
CustomForm.show
End Sub

This show the original form and my custom form

Thanks




10 Answers, 1 is accepted

Sort by
0
Jeff
Top achievements
Rank 1
answered on 29 Jul 2014, 08:14 PM
Because of the level of customization, I found it easier to create a new form that didn't inherit the built in form. I pass it the ID that was clicked or I pass 0 along with the date and time clicked if it's a new appointment. 

The attached image is my custom form. As you can see, you can be as creative as you like. The 'Resources' tab is where you add guests and emloyees to the appointment and add custom info for each guest like weight, shoe size, horseback riding skill, etc. Once you figure out the custom forms you'll find that you can use it for just about anything that's scheduled.

Your second method is similar to mine. This is basically what I do. They key to stopping the original form from showing is "e.cancel = true"
Now, I have a lot of other code that determines if an appointment or blank was clicked and opens an existing appointment or starts a new one. My custom form reads the variables from FormMain (the MDI parent) to determine what it should do.

Private Sub RadScheduler1_AppointmentEditDialogShowing(sender As Object, e As Telerik.WinControls.UI.AppointmentEditDialogShowingEventArgs) Handles RadScheduler1.AppointmentEditDialogShowing
 
       e.Cancel = True
       FormMain.ClickedID = Int(e.Appointment.UniqueId.ToString())
       FormAppointmentEdit.show
 
   End Sub
0
Karen
Top achievements
Rank 1
answered on 30 Jul 2014, 12:14 AM
Thank you very much for your answer. 
Works the code to remove the original form and use the custom form. 
But how data is bound to the new form? (eg txt_client, tp_startdate, dl_resource, dp_background) 

I use this code to load the data to SchedulerBindingDataSource1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
 
        Me.ResourcesTableAdapter.Fill(Me.AppointmentsDataSet.Resources)
        Me.AppointmentsTableAdapter.Fill(Me.AppointmentsDataSet.Appointments)
 
 
        Dim resourceMappingInfo As New ResourceMappingInfo()
        resourceMappingInfo.Id = "ID"
        resourceMappingInfo.Name = "ResourceName"
        resourceMappingInfo.Color = "Color"
        Me.SchedulerBindingDataSource1.ResourceProvider.Mapping = ResourceMappingInfo
 
        Dim appointmentMappingInfo As New AppointmentMappingInfo()
 
        appointmentMappingInfo.Mappings.Add(New SchedulerMapping("Email", "Email"))
        appointmentMappingInfo.Mappings.Add(New SchedulerMapping("Phone", "Phone"))
        appointmentMappingInfo.Mappings.Add(New SchedulerMapping("Address", "Address"))
        ' appointmentMappingInfo.Mappings.Add(New SchedulerMapping("Amount", "Amount"))
 
        appointmentMappingInfo.BackgroundId = "BackgroundID"
        appointmentMappingInfo.Description = "Description"
        appointmentMappingInfo.[End] = "End"
        appointmentMappingInfo.Location = "Location"
        appointmentMappingInfo.MasterEventId = "ParentID"
        appointmentMappingInfo.RecurrenceRule = "RecurrenceRule"
        appointmentMappingInfo.ResourceId = "ResourceID"
        appointmentMappingInfo.Resources = "AppointmentsAppointmentsResources"
        appointmentMappingInfo.Start = "Start"
        appointmentMappingInfo.StatusId = "StatusID"
        appointmentMappingInfo.Summary = "Client"
        SchedulerBindingDataSource1.EventProvider.Mapping = appointmentMappingInfo
 
        SchedulerBindingDataSource1.ResourceProvider.DataSource = AppointmentsDataSet.Resources
        SchedulerBindingDataSource1.EventProvider.DataSource = AppointmentsDataSet.Appointments
 
        RadScheduler1.DataSource = SchedulerBindingDataSource1
 
    End Sub
0
Jeff
Top achievements
Rank 1
answered on 30 Jul 2014, 08:58 PM
I bind each field in the new form to the table and handle the filling and saving in the form. 

To start a new appointment or load the clicked appointment, something like this:
If ClickedID = 0 Then
    ActActivityScheduleBindingSource.AddNew()
    StartDateTimePicker.Value = StartDate
    StopDateTimePicker.Value = StartDate 'This gets updated once they pick an activity.
Else
    ActActivityScheduleTableAdapter.FillByID(ExecuSuitePMSDataSet.ActActivitySchedule, ClickedID)
End If

And to save, I do something like this. Of course, this is quite simplified - there are a lot of things my custom form needs to save across many tables.
ActActivityScheduleBindingSource.EndEdit()
ActActivityScheduleTableAdapter.Update(ExecuSuitePMSDataSet.ActActivitySchedule)


Once I'm finished saving, I close the custom form and refresh the calendar view to show the new or updated appointment.
0
Karen
Top achievements
Rank 1
answered on 01 Aug 2014, 08:40 AM
I use the code for both forms I used a module. 

FormMain.ClickedID = Int(e.Appointment.UniqueId.ToString())
does not result in an integer. Ex. (4d7dfd93-1f05-4ca0-a130-40401af8)

running at the time. I have an error implicit conversion - System.InvalidCastException:


I try

ClickedID = CType(e.Appointment.UniqueId.ToString, Integer)
 

ClickedID = CInt(e.Appointment.UniqueId.ToString)

Could you give me the form of a project to study the code? I'm still learning. Thank you ;)


0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 Aug 2014, 12:35 PM
Hello guys,

Thank you for writing.

@ Karen,
Your CustomForm must inherit from EditAppointmentDialog which implements the IEditAppointmentDialog interface. Please refer to our Adding a custom field to the EditAppointment dialog help article, which guides you through the process of replacing the EditAppointmentDialog with a custom one. 

You can cancel the AppointmentEditDialogShowing event, as Jeff suggested, which will stop the default edit dialog to show and you are free to show your custom form. However, have in mind that when you open your own form which is neither a derivative of the EditAppointmentDialog, nor implements the IEditAppointmentDialog interface, you should apply all the modifications to the Appointment instance that you are going to edit. 

@Jeff,
I have updated your Telerik points for the community effort.

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Jeff
Top achievements
Rank 1
answered on 01 Aug 2014, 02:24 PM
Karen,

Unfortunately I don't have time this week to make a demo project but I can offer some suggestions.

Both of these code examples are on my form containing the RadScheduler. PanelLoading is just a "Loading Data" indicator that I pop up any time I think there might be more than a second or two wait while data loads. 

I have my code that passes the clicked ID in a Try Catch. If it fails, I pass a 0. The only reason it should fail is if there is no UniqueID because you've clicked a blank cell. I also pass the start date that was clicked if a blank cell was clicked. I start the new appointment with this date and time.
Try
    FormMain.ClickedID = Int(e.Appointment.UniqueId.ToString())
Catch ex As Exception
    FormMain.ClickedID = 0
    Dim GetClickedDates() As Date
    GetClickedDates = SchedulerUIHelper.GetSelectedDates(RadScheduler1)
    FormMain.StartDate = GetClickedDates(0)
End Try

After this I set some more variables on FormMain that need to be shared by various forms, then I call my sub that displays the custom form. I only allow one custom appointment edit window at a time so I check to be sure it isn't already open.
Private Sub ShowEdit()
    Dim IsItOpen As Boolean = False
    For Each window As Docking.DockWindow In FormMain.RadDock1.DockWindows.ToolWindows
        If window.Name = "FormActivityDetailEdit1" Then
            IsItOpen = True
        End If
    Next
    If IsItOpen = False Then
        FormMain.PanelLoading.Visible = True
        Application.DoEvents()
        Dim MDI As New FormActivityDetailEdit
        MDI.MdiParent = FormMain
        MDI.Show()
    End If
End Sub

0
Karen
Top achievements
Rank 1
answered on 03 Aug 2014, 07:17 PM
Hi guys. 
Thank you very much for your answers. 

I created the customized form. The custom form loads the data from the database. I created the filters.

The error is the UniqueID. When I try to get the ID value. the result is not an integer.

ClickedID = Int(e.Appointment.UniqueId.ToString())

:S






0
Jeff
Top achievements
Rank 1
answered on 04 Aug 2014, 02:33 PM
Karen, are you mapping the UniqueID to the key of your table? The key to my table is ID and I map it to UniqueID. 
This page shows mapping. http://www.telerik.com/help/winforms/scheduler-data-binding-data-binding-walkthrough.html

If you're clicking a blank cell on the scheduler you will get an error and this is when you catch it and start a new appointment. 
0
Karen
Top achievements
Rank 1
answered on 04 Aug 2014, 08:20 PM
OMG! you're right. I was not linking table data.

appointmentMappingInfo.UniqueId = "ID"

Now works perfectly.

Thank you very much for your help.

I will continue testing the features of Telerik. I find it very interesting.



0
Jeff
Top achievements
Rank 1
answered on 04 Aug 2014, 08:50 PM
You're welcome. I struggled with these things as well so I'm happy to help someone else if I can.
Tags
Scheduler and Reminder
Asked by
Karen
Top achievements
Rank 1
Answers by
Jeff
Top achievements
Rank 1
Karen
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or