Show Custom Form - Edit appointment

11 posts, 0 answers
  1. Karen
    Karen avatar
    6 posts
    Member since:
    Jul 2014

    Posted 29 Jul 2014 Link to this post

    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




  2. Jeff
    Jeff avatar
    48 posts
    Member since:
    Apr 2012

    Posted 29 Jul 2014 in reply to Karen Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Karen
    Karen avatar
    6 posts
    Member since:
    Jul 2014

    Posted 29 Jul 2014 in reply to Jeff Link to this post

    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
  5. Jeff
    Jeff avatar
    48 posts
    Member since:
    Apr 2012

    Posted 30 Jul 2014 in reply to Karen Link to this post

    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.
  6. Karen
    Karen avatar
    6 posts
    Member since:
    Jul 2014

    Posted 01 Aug 2014 in reply to Jeff Link to this post

    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 ;)


  7. Dess
    Admin
    Dess avatar
    1607 posts

    Posted 01 Aug 2014 Link to this post

    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.
     
  8. Jeff
    Jeff avatar
    48 posts
    Member since:
    Apr 2012

    Posted 01 Aug 2014 in reply to Karen Link to this post

    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

  9. Karen
    Karen avatar
    6 posts
    Member since:
    Jul 2014

    Posted 03 Aug 2014 in reply to Jeff Link to this post

    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






  10. Jeff
    Jeff avatar
    48 posts
    Member since:
    Apr 2012

    Posted 04 Aug 2014 in reply to Karen Link to this post

    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. 
  11. Karen
    Karen avatar
    6 posts
    Member since:
    Jul 2014

    Posted 04 Aug 2014 in reply to Jeff Link to this post

    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.



  12. Jeff
    Jeff avatar
    48 posts
    Member since:
    Apr 2012

    Posted 04 Aug 2014 in reply to Karen Link to this post

    You're welcome. I struggled with these things as well so I'm happy to help someone else if I can.
Back to Top
UI for WinForms is Visual Studio 2017 Ready