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

Copying (duplicating) an appointment server-side

6 Answers 178 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 2
Dave asked on 08 Feb 2010, 12:50 PM
Hello,

We are wondering how to access the low-level appointment data (like recordset ID or internal references) in order to duplicate a selected appointment including all its settings to a new date in timeline view (v. Q2_2009).
We were looking at the exposed properties without finding something, but I guess we certainly missed something...

Edit: The selection of the appointment occurs through a contextual menu.

This has to be done server-side for technical reasons.
Anybody has an idea?

Regards,
David

6 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 08 Feb 2010, 07:19 PM
I'm assuming the property you want is the Appointment.Clone(). This will return a duplicate of the appointment object.

Is that what you're looking for?
0
Peter
Telerik team
answered on 09 Feb 2010, 03:57 PM
Hi David,

In addition to Robert's suggestion, we have recently had a question on how to copy and paste an appointment using the context menu. Here is sample code for this functionality:

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"
        <telerik:RadScheduler ID="RadScheduler1" runat="server" OnAppointmentContextMenuItemClicking="RadScheduler1_AppointmentContextMenuItemClicking"
            OnTimeSlotContextMenuItemClicking="RadScheduler1_TimeSlotContextMenuItemClicking"
            <AppointmentContextMenuSettings EnableDefault="true" /> 
            <AppointmentContextMenus
                <telerik:RadSchedulerContextMenu ID="RadSchedulerAppointmentContextMenu1" runat="server"
                    <Items
                        <telerik:RadMenuItem Text="Copy" Value="Copy"
                        </telerik:RadMenuItem
                    </Items
                </telerik:RadSchedulerContextMenu
            </AppointmentContextMenus
            <TimeSlotContextMenuSettings EnableDefault="true" /> 
            <TimeSlotContextMenus
                <telerik:RadSchedulerContextMenu ID="RadSchedulerTimeslotContextMenu1" runat="server"
                    <Items
                        <telerik:RadMenuItem Text="Paste" Value="Paste"
                        </telerik:RadMenuItem
                    </Items
                </telerik:RadSchedulerContextMenu
            </TimeSlotContextMenus
        </telerik:RadScheduler
    </telerik:RadAjaxPanel>

protected void RadScheduler1_TimeSlotContextMenuItemClicking(object sender, TimeSlotContextMenuItemClickingEventArgs e) 
   
       if(Session["appointment"] != null
       
           Appointment a = Session["appointment"] as Appointment; 
           //The following achieves cut and paste: 
           //RadScheduler1.DeleteAppointment(a, true); 
           TimeSpan appDuration = a.Duration; 
           a.Start = e.TimeSlot.Start; 
           a.End = e.TimeSlot.Start.Add(appDuration); 
           RadScheduler1.InsertAppointment(a); 
               
               
           RadScheduler1.Rebind(); 
       
           
   
   protected void RadScheduler1_AppointmentContextMenuItemClicking(object sender, AppointmentContextMenuItemClickingEventArgs e) 
   
       Session["appointment"] = e.Appointment; 
   
   protected void Page_Init(object sender, EventArgs e) 
   
       XmlSchedulerProvider provider = new XmlSchedulerProvider(Server.MapPath("~/App_Data/Appointments.xml"), true); 
       RadScheduler1.Provider = provider; 
   }

Attached is a simple demo for reference.


Kind regards,
Peter
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Christopher
Top achievements
Rank 1
answered on 19 Jan 2017, 07:26 PM
This almost works for what I am trying to do.  One thing that I need to be able to do is nullify a custom attribute (primary key to the table) so that instead of editing an existing record in the database, I insert a new record.
0
Christopher
Top achievements
Rank 1
answered on 20 Jan 2017, 01:44 PM

I basically have the desired result I want except my calendar is not rebinding once I insert my record into the database.  I have to close and rerun the page to see the new appointment.  Here is my code...

    Private Sub RadScheduler1_TimeSlotContextMenuItemClicking(sender As Object, e As TimeSlotContextMenuItemClickingEventArgs) Handles RadScheduler1.TimeSlotContextMenuItemClicking
        If Session("appointment") IsNot Nothing Then
            Dim oSched1 As Appointment = Session("appointment")
            Dim oSched2 As Appointment = Nothing
            Dim appDuration As TimeSpan = oSched1.Duration
            oSched1.Start = e.TimeSlot.Start
            oSched1.End = e.TimeSlot.Start.Add(appDuration)

            Dim oScheduledShipment As New tScheduledShipment
            Dim oNewShipment As New tScheduledShipment
            With oScheduledShipment
                .ShipmentID = oSched1.Attributes.Item("ShipmentID")
                .OriginAssetID = oSched1.Attributes.Item("OriginAssetID")
                .DestinationID = oSched1.Attributes.Item("DestinationID")
                .Vessel = oSched1.Attributes.Item("Vessel")
                .CarrierID = oSched1.Attributes.Item("CarrierID")
                .ScheduledTons = oSched1.Attributes.Item("ScheduledTons")
                .ScheduledShipDate = oSched1.Start
                .ExpectedArrivalDate = oSched1.End
                .ActionID = 1
                .ActionBy = "chrisruckman"
                .ActionMachine = "abc"
                .ActionDate = Date.Now
            End With

            Using o As New CIMSLogisticsService.ScheduledShipmentsClient
                oNewShipment = o.InsertScheduledShipment(oScheduledShipment)
            End Using

            oSched2 = New Appointment
            With oNewShipment
                oSched2.Attributes("ScheduledShipmentID") = .ScheduledShipmentID
                oSched2.Attributes("ShipmentID") = .ShipmentID
                oSched2.Attributes("OriginAssetID") = .OriginAssetID
                oSched2.Attributes("DestinationID") = .DestinationID
                oSched2.Attributes("Vessel") = .Vessel
                oSched2.Attributes("CarrierID") = .CarrierID
                oSched2.Attributes("ScheduledTons") = .ScheduledTons
                oSched2.Attributes("ScheduledShipDate") = .ScheduledShipDate
                oSched2.Attributes("ExpectedArrivalDate") = .ExpectedArrivalDate
                oSched2.Attributes("ActionID") = .ActionID
                oSched2.Attributes("ActionBy") = .ActionBy
                oSched2.Attributes("ActionMachine") = .ActionMachine
                oSched2.Attributes("ActionDate") = .ActionDate
            End With

            RadScheduler1.InsertAppointment(oSched2)

            'RadScheduler1.DataSource = ScheduledShipments()
            'RadScheduler1.DataBind()
            RadScheduler1.Rebind()
        End If
    End Sub

 

0
Christopher
Top achievements
Rank 1
answered on 20 Jan 2017, 03:50 PM

I fixed it.  My ScheduledShipments wasn't populating the datasource because it was checking to see if a session variable was being set.  I simply set the session variable to nothing and called the ScheduledShipments to set the data and called the scheduler's databind methog.  I removed .Rebind because it was undoing the databind()

 

                RadScheduler1.DataSource = Nothing
                Session(SCHEDULEDSHIPMENTS_DATA) = Nothing

                RadScheduler1.DataSource = ScheduledShipments()
                RadScheduler1.DataBind()

0
Veselin Tsvetanov
Telerik team
answered on 24 Jan 2017, 02:21 PM
Hi Christopher,

Thank you for shearing the approach you have chosen, in order to resolve the issue faced.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Scheduler
Asked by
Dave
Top achievements
Rank 2
Answers by
robertw102
Top achievements
Rank 1
Peter
Telerik team
Christopher
Top achievements
Rank 1
Veselin Tsvetanov
Telerik team
Share this question
or