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

Bindiing Scheduler to SQL

29 Answers 519 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Joe Bohen
Top achievements
Rank 1
Joe Bohen asked on 13 May 2009, 03:48 PM

I am new to Telerik controls and am attempting setting up a Scheduler control on a windows form. I have followed the web based sample and am attempting to bind to your sql based sample data using as the ScheduleBindingDataSource data setting the settings as your sample

Does the datasource need to be initiated when the form loads as I am returning no records?

 

ResourceProvide

Allownew         True

Datamember      Appointments

DataSource         SchedulerDataDataSet

 

If I comment out the if statement in the data binding event and force a new instance of the SchedulerDataDataSet then the records are returned!

 

'If Me.SchedulerDataDataSet Is Nothing Then

            Me.SchedulerDataDataSet = New SchedulerDataDataSet()

 

            Dim appointmentsAdapter As New AppointmentsTableAdapter()

            appointmentsAdapter.Fill(Me.SchedulerDataDataSet.Appointments)

 

            Dim resourcesAdapter As New ResourcesTableAdapter()

            resourcesAdapter.Fill(Me.SchedulerDataDataSet.Resources)

 

            Dim appointmentsResourcesAdapter As New TransientAppointmentsResourcesTableAdapter()

            appointmentsResourcesAdapter.Fill(Me.SchedulerDataDataSet.TransientAppointmentsResources)

            ' End If

29 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 16 May 2009, 12:33 PM
Hi Joe Bohen,

Yes, the data source must be loaded with data. In the data binding example of RadScheduler for WinForms notice (in the BindToDataSet method) that the dataset tables are filled with data before setting them as data sources to the SchedulerBindingDataSource.

I hope this helps. Do not hesitate to write again if you have further questions.

Best wishes,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
TwoLaJit
Top achievements
Rank 2
answered on 17 May 2009, 05:35 AM
I am also trying to bind scheduler to SQL. 
I have never worked with this control before. 
Here is what I have attempted.

I did followed this perfectly

once that was done, i made an appointment and closed out of my program, when i went back into my program, the appointment was not there. 

So then i tried to add on my radscheduler1 control i tried to make the datasource = SchedulerDataBindingSource1

i get this error: Object reference not set to an instance of an object.

Any ideas? 

I have referred to the  BindToDataSet method in the sample, still no luck. 


Update: actually it works perfectly now. I removed the if statement from the bindtodataset sample...
 ' If Me.SchedulerDataSet Is Nothing Then





0
Joe Bohen
Top achievements
Rank 1
answered on 19 May 2009, 12:35 PM

Hi Jordan

Thanks for replying to my question, I know have only one issue with the scheduler ! When I add a resource to an appointment it is not saved I cannot spot the issue will you have a look at the code and advice me?

 

‘code used to load scheduler

 

Try

            'If Me.SchedulerDataDataSet Is Nothing Then

            Me.SchedulerDataDataSet = New SchedulerDataDataSet()

 

            Dim appointmentsAdapter As New AppointmentsTableAdapter()

            appointmentsAdapter.Fill(Me.SchedulerDataDataSet.Appointments)

 

            Dim resourcesAdapter As New ResourcesTableAdapter()

            resourcesAdapter.Fill(Me.SchedulerDataDataSet.Resources)

 

            Dim appointmentsResourcesAdapter As New TransientAppointmentsResourcesTableAdapter()

            appointmentsResourcesAdapter.Fill(Me.SchedulerDataDataSet.TransientAppointmentsResources)

            ' End If

 

            Dim dataSource As New SchedulerBindingDataSource()

            Dim appointmentMappingInfo As New AppointmentMappingInfo()

            appointmentMappingInfo.Start = "Start"

            appointmentMappingInfo.End = "End"

            appointmentMappingInfo.Summary = "Summary"

            appointmentMappingInfo.Description = "Description"

            appointmentMappingInfo.Location = "Location"

            appointmentMappingInfo.BackgroundId = "BackgroundID"

            appointmentMappingInfo.StatusId = "StatusID"

            appointmentMappingInfo.Resources = "Appointments_AppointmentsResources"

            appointmentMappingInfo.ResourceId = "ResourceID"

            appointmentMappingInfo.RecurrenceRule = "RecurrenceRule"

 

            dataSource.EventProvider.Mapping = appointmentMappingInfo

            dataSource.EventProvider.DataSource = Me.SchedulerDataDataSet.Appointments

 

            Dim resourceMappingInfo As New ResourceMappingInfo()

            resourceMappingInfo.Id = "ID"

            resourceMappingInfo.Name = "Name"

 

            dataSource.ResourceProvider.Mapping = resourceMappingInfo

            dataSource.ResourceProvider.DataSource = Me.SchedulerDataDataSet.Resources

 

            Me.RadScheduler1.DataSource = dataSource

            Me.DockPanel2.DockPosition = Docking.DockPosition.Left

            Me.DockPanel2.DockState = Docking.DockState.AutoHide

            Me.RadSchedulerNavigator1.Top = 0

 

 

        Catch ex As Exception

            MsgBox(Err.Description)

        End Try

 

‘Code to save data

 

Private Sub SaveChanges()

        Dim appointmentsAdapter As New AppointmentsTableAdapter()

        appointmentsAdapter.Update(Me.SchedulerDataDataSet.Appointments)

 

       

        Dim appointmentsResourcesAdapter As New TransientAppointmentsResourcesTableAdapter()        appointmentsResourcesAdapter.Update(Me.SchedulerDataDataSet.TransientAppointmentsResources)

    End Sub

0
Jordan
Telerik team
answered on 19 May 2009, 03:24 PM
Hi Joe Bohen,

I just tried assigning a resource to an appointment and then saving that to the data source, but it seems there is some issue with the latest version of RadScheduler.

I will have to investigate more and follow up later with a detailed answer.

All the best,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jordan
Telerik team
answered on 21 May 2009, 08:03 AM
Hello Joe Bohen,

I found the reason for the issue that I mentioned earlier. The relation in the data set was missing so there was no way that the resources could work.

Please, check if that is the problem. Please notice how in the line below the Resources property is assigned the name of the relation:

appointmentMappingInfo.Resources = "Appointments_AppointmentsResources"

It is very important that there is a relation in the data set and it has the same name [as the one set to the property]. Otherwise the data binding functionality will not be able to find the resources.

If that is not the case I will most probably need a sample project that demonstrates the issue in order to help you further.

Greetings,
Jordan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Thomas Schuster
Top achievements
Rank 1
answered on 14 Jul 2009, 01:38 PM
Hello Jordan.

I'm currently sitting on nearly the same problem.

Difference is, i'm using C# instead of VB.NET.

I followed your instructions in this Thread, but i'm getting following exception:

bei System.Data.DataView.System.Collections.IList.Clear() 
   bei Telerik.WinControls.UI.Scheduler.SimpleResourceIdMapper.ClearResourceIds() 
   bei Telerik.WinControls.UI.SchedulerBindingDataSource.EventBindingProvider.ProcessSchedulerItem(IEvent schedulerItem, Object dataSourceItem, SchedulerMapping mapping, PropertyDescriptor dataItemProperty) 
   bei Telerik.WinControls.UI.Scheduler.BindingProviderBase`1.UpdateDataItemProperties(Object item, T schedulerItem) 
   bei Telerik.WinControls.UI.Scheduler.BindingProviderBase`1.Insert(T itemToInsert) 
   bei Telerik.WinControls.UI.RadScheduler.OnAddAppointments(IList list) 
   bei Telerik.WinControls.UI.RadScheduler.appointments_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) 
   bei Telerik.WinControls.Data.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) 
   bei Telerik.WinControls.Data.ObservableCollection`1.NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e) 
   bei Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) 
   bei Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index) 
   bei Telerik.WinControls.Data.ObservableCollection`1.InsertItem(Int32 index, T item, Action`1 approvedAction) 
   bei Telerik.WinControls.Data.ObservableCollection`1.InsertItem(Int32 index, T item) 
   bei Telerik.WinControls.UI.SchedulerAppointmentCollection.InsertItem(Int32 index, IEvent item) 
   bei System.Collections.ObjectModel.Collection`1.Add(T item) 
   bei Telerik.WinControls.UI.RadScheduler.appointmentItem_Click(Object sender, EventArgs e) 
   bei Telerik.WinControls.RadItem.OnClick(EventArgs e) 
   bei Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e) 
   bei Telerik.WinControls.UI.RadMenuItemBase.OnClick(EventArgs e) 
   bei Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e) 
   bei Telerik.WinControls.RadItem.DoClick(EventArgs e) 
   bei Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) 
   bei Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) 
   bei Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args) 
   bei Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args) 
   bei Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e) 
   bei Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e) 
   bei Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e) 
   bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
   bei System.Windows.Forms.Control.WndProc(Message& m) 
   bei System.Windows.Forms.ScrollableControl.WndProc(Message& m) 
   bei Telerik.WinControls.RadControl.WndProc(Message& m) 
   bei Telerik.WinControls.UI.RadPopupControl.WndProc(Message& m) 
   bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
   bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
   bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
   bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
   bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
   bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
   bei System.Windows.Forms.Application.Run(Form mainForm) 
   bei Vacation.Program.Main() in C:\Users\User\Documents\Visual Studio 2005\Projects\Vacation\Vacation\Program.cs:Zeile 17. 
   bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
   bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
   bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
   bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
   bei System.Threading.ThreadHelper.ThreadStart() 

This is just the Stacktrace.
Localisation is german, so i cant post the original trace.
I've tried to trace it manually, but there was no success

Kind regards
Thomas


0
Boyko Markov
Telerik team
answered on 17 Jul 2009, 01:43 PM
Hello Thomas Schuster,

Thank you for writing us.

Could you please send me a very simple application which demonstrates the erroneous behavior?
This will help me very much in further testing and debugging of the issue. Hopefully I will be able to provide you a better help and fix it in the application as the exception's call stack not really help me at the moment. 

I'm looking forward to your reply.



Kind regards,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
rizu mussa
Top achievements
Rank 1
answered on 07 Jan 2010, 08:43 PM
hello Mr. Joe Bohen,

i'm need your help, becouse i have same problem that you, When I add a resource to an appointment it is not saved, please can you help me to resolve this.

WHEN I CLICK THE  "Update button" I GIVE THIS ERROR:

The INSERT statement conflicted with the FOREIGN KEY constraint "FK_AppointmentsResources_Appointments". The conflict occurred in database "C:\DOCUMENTS AND SETTINGS\NUNEX2\DESKTOP\CONSULTASMEDICAS\BD\SCHEDULERDATA.MDF", table "dbo.Appointments", column 'ID'. The statement has been terminated.

i'm using Telerik winform Q3 2009, and cheduler control.



0
Boyko Markov
Telerik team
answered on 13 Jan 2010, 07:49 AM
Hello rizu mussa,

You can find the answer to your question in your support ticket. I have written there that you have to create and assign an appointment mapping.

Greetings,
Boyko Markov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
shinu rag
Top achievements
Rank 1
answered on 19 Feb 2010, 06:22 AM
can i bind scheduler using collection of class objects..
is it posible?..

like this

 

// Function Starts Here 
public IList<ClsAppData> GetAppointments_() 
        { 
            ClsAppData objApp; 
            IList<ClsAppData> AppList = new List<ClsAppData>(); 
            
             
            try 
            { 
                con.Open(); 
                sql = "select ID,FirstName,LastName,Phone,Dob,Gender,Subject,Location,Start,[End],RecurrenceRule,Description from Appointments"
                da = new SqlDataAdapter(sql, con); 
                ds = new DataSet(); 
                ds.Tables.Clear(); 
                da.Fill(ds, "Appointments"); 
                foreach (DataRow row in ds.Tables["Appointments"].Rows) 
                { 
                    objApp = new ClsAppData(); 
                    objApp.ID_ = Convert.ToInt32(row[0]); 
                    objApp.FirstName_ = Convert.ToString(row[1]); 
                    objApp.LastName_ = Convert.ToString(row[2]); 
                    objApp.Phone_ = Convert.ToString(row[3]); 
                    objApp.DtDob_ = Convert.ToDateTime(row[4]); 
                    objApp.Gender_ = Convert.ToInt32(row[5]); 
                    objApp.Subject_ = Convert.ToString(row[6]); 
                    objApp.Location_ = Convert.ToString(row[7]); 
                    objApp.DtStartDate_ = Convert.ToDateTime(row[8]); 
                    objApp.DtEndDate_ = Convert.ToDateTime(row[9]); 
                    objApp.RecurrenceRule_ = Convert.ToString(row[10]); 
                    objApp.Description_ = Convert.ToString(row[11]); 
                    AppList.Add(objApp); 
                } 
            } 
            catch (Exception ex) 
            { System.Windows.Forms.MessageBox.Show(ex.Message); } 
            finally 
            { con.Close(); } 
            
 
             return AppList; 
        } 
//Function End Here 
 
 
// Calling the above function and binding datas to scheduler 
        try 
            { 
                ClsAppFunc obj = new ClsAppFunc(); 
                SchedulerBindingDataSource dataSource = new SchedulerBindingDataSource(); 
                dataSource.EventProvider.AppointmentFactory = this.radScheduler1.AppointmentFactory; 
                AppointmentMappingInfo info = new AppointmentMappingInfo(); 
 
                info.UniqueId = "ID"
                info.Summary = "FirstName"
                info.Location = "Location"
                info.Start = "Start"
                info.End = "End"
                info.RecurrenceRule = "RecurrenceRule"
                info.Description = "Description"
                info.Visible = "Visible"
 
                 
                dataSource.EventProvider.Mapping = info
                                 
                ////////////////////////////////////// 
                IList<ClsAppData> AppList=new List<ClsAppData>(); 
                AppList = obj.GetAppointments_(); 
                dataSource.EventProvider.DataSource = AppList
                ///////////////////////////////////// 
 
                 
                this.radScheduler1.DataSource = dataSource
            } 
            catch (Exception ex) 
            { MessageBox.Show(ex.Message); } 

when excecuting the application the values are binding with empty values and placed on wrong location...
i won't bind datas using datatable or datasets...
please help me
thanks..
0
Dobry Zranchev
Telerik team
answered on 19 Feb 2010, 08:54 AM
Hi shinu rag,

You could look at the demo example(Scheduler DataBinding). I hope that this will help you. If you have additional questions, feel free to ask.

All the best,
Dobry Zranchev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Aaron
Top achievements
Rank 1
answered on 26 Feb 2013, 06:20 PM
I am having the same issue with Resources not being saved when binding to SQL Tables. The appointments save with a null resource every time. The AppointmentsResources table never gets updated. I followed the online videos, but none of the ones I found actually even test that functionality. What needs to happen for the AppointmentResources table to get updates when creating appointments? 
0
Julian Benkov
Telerik team
answered on 01 Mar 2013, 03:29 PM
Hi Aaron,

To update AppointmentsResources table it is very important to set 
AppointmentMappingInfo properly. For the AppointmentMappingInfo you should set the ResourceId property to the ResourceId field name in the AppointmentsResources table, and for the Resources you should set the name of the relation between AppointmentsResources and Appointments. When you associate the resource to the appointment, a new record will be added to AppointmentsResources if there is no such.  

More information about this you can find in our
online documentation.

I hope this helps.

All the best,
Julian Benkov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

Interested, but can’t attend? Register anyway and we’ll send you the recording.
0
Timothy
Top achievements
Rank 1
answered on 06 Mar 2013, 10:51 PM
I'm having the same problem as Aaron.

I have followed your instructions: For the AppointmentMappingInfo you should set the ResourceId property to the ResourceId field name in the AppointmentsResources table, and for the Resources you should set the name of the relation

But it still does not persist the resource. No errors, it just does not insert a record into the AppointmentsResources table.

Is there anything else I should check?
0
Timothy
Top achievements
Rank 1
answered on 06 Mar 2013, 11:33 PM
I figured out my problem. I wasn't updating the AppointmentsResources table in the button click event.
0
Julian Benkov
Telerik team
answered on 08 Mar 2013, 03:27 PM
Hi Joe,

I am glad to hear that you managed to find a solution for the experienced problem. 
Do not hesitate to contact us if you have further questions or issues. 

Regards,
Julian Benkov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
Silveron
Top achievements
Rank 1
answered on 26 Feb 2014, 12:47 AM
I know this is an old post but Timothy can you post your code?  I am having this issue.  I have it bound to a SQL backend, however the AppointmentID never gets a value put in, however the ResourceID does.
0
Timothy
Top achievements
Rank 1
answered on 26 Feb 2014, 03:07 PM
Yes, it has been a long time :-). I don't really remember the issue but I searched through the code history and found what I think is related. These changes were on 3/6/2013 anyway. I think the issue has to do with the newChildRecords portion. I probably assumed that just doing the "Update" was enough but had to add code to handle the deletes and new records as well.

I hope this helps.

Private
Sub RadButton1_Click(sender As System.Object, e As System.EventArgs) Handles RadButton1.Click
    CS_ScheduleInfo_ResourcesTableAdapter.Adapter.AcceptChangesDuringUpdate = False
    Dim deletedChildRecords As ClientSchedulerDS.CS_ScheduleInfo_ResourcesDataTable = TryCast(Me.ClientSchedulerDS.CS_ScheduleInfo_Resources.GetChanges(DataRowState.Deleted), ClientSchedulerDS.CS_ScheduleInfo_ResourcesDataTable)
    Dim newChildRecords As ClientSchedulerDS.CS_ScheduleInfo_ResourcesDataTable = TryCast(Me.ClientSchedulerDS.CS_ScheduleInfo_Resources.GetChanges(DataRowState.Added), ClientSchedulerDS.CS_ScheduleInfo_ResourcesDataTable)
    Dim modifiedChildRecords As ClientSchedulerDS.CS_ScheduleInfo_ResourcesDataTable = TryCast(Me.ClientSchedulerDS.CS_ScheduleInfo_Resources.GetChanges(DataRowState.Modified), ClientSchedulerDS.CS_ScheduleInfo_ResourcesDataTable)
    Try
        If deletedChildRecords IsNot Nothing Then
            CS_ScheduleInfo_ResourcesTableAdapter.Update(deletedChildRecords)
        End If
        CS_ScheduleInfoTableAdapter.Update(Me.ClientSchedulerDS.CS_ScheduleInfo)
        If newChildRecords IsNot Nothing Then
            CS_ScheduleInfo_ResourcesTableAdapter.Update(newChildRecords)
        End If
        If modifiedChildRecords IsNot Nothing Then
            CS_ScheduleInfo_ResourcesTableAdapter.Update(modifiedChildRecords)
        End If
        Me.ClientSchedulerDS.AcceptChanges()
        ClientSchedulerDS.AcceptChanges()
    Catch ex As Exception
        MessageBox.Show(String.Format("An error occurred during the update process:" & vbLf & "{0}", ex.Message))
    Finally
        If deletedChildRecords IsNot Nothing Then
            deletedChildRecords.Dispose()
        End If
        If newChildRecords IsNot Nothing Then
            newChildRecords.Dispose()
        End If
        If modifiedChildRecords IsNot Nothing Then
            modifiedChildRecords.Dispose()
        End If
    End Try
End Sub




0
Silveron
Top achievements
Rank 1
answered on 26 Feb 2014, 04:05 PM
Timothy,  thank you for your code.  The situation I am in, is that my development machine and the production machines are at a different location so the sql server connection string will be different.  Along with that, I will have different location beyond that, that will be using my application so each location will have a different location string.

So I have to change the connection string at runtime, in which I would like to use your code, however I don't know how to change the datasource to the dataset at run time.  My other option is to do everything from code-behind and connect to the server and use stored producedures (which I have been trying to do) but running into issues.  The code below is just a snippet of the save function.  Perhaps you could give me some ideas on how to accomplish what I need?  I've been on this issue for two weeks now and it's driven me pretty much insane. With the code below it will not add an entry to the AppointmentID (but it does to the ResourceID) and editing appointments do not save.  I would have to think there is an easier way to accomplish this..

​
Public Sub SaveScheduler()
        AppointmentsResourcesTableAdapter.AcceptChangesDuringUpdate = False
        Dim deletedChildRecords = schedulerDataDataSet.GetChanges(DataRowState.Deleted)
        Dim newChildRecords = schedulerDataDataSet.GetChanges(DataRowState.Added)
        Dim modifiedChildRecords = schedulerDataDataSet.GetChanges(DataRowState.Modified)
 
        connection = New SqlConnection(connectstring)
 
        appointmentsResourcesTableAdapter.SelectCommand = New SqlCommand()
        appointmentsResourcesTableAdapter.SelectCommand.Connection = connection
        appointmentsResourcesTableAdapter.SelectCommand.CommandText = "procGetAppointmentResources"
        appointmentsResourcesTableAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
 
        AppointmentsTableAdapter.SelectCommand = New SqlCommand()
        AppointmentsTableAdapter.SelectCommand.Connection = connection
        AppointmentsTableAdapter.SelectCommand.CommandText = "procGetAppointments2"
        AppointmentsTableAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
 
        Try
            If deletedChildRecords IsNot Nothing Then
                'If deletedChildRecords.Tables(2).Rows.Count > 0 Then
 
                AppointmentsTableAdapter.DeleteCommand = New SqlCommand()
                AppointmentsTableAdapter.DeleteCommand.Connection = connection
                AppointmentsTableAdapter.DeleteCommand.CommandText = "procGetAppointments2"
                AppointmentsTableAdapter.DeleteCommand.CommandType = CommandType.StoredProcedure
                Dim cmdBuilder2 As New SqlClient.SqlCommandBuilder(AppointmentsTableAdapter)
                AppointmentsTableAdapter.DeleteCommand = cmdBuilder2.GetDeleteCommand
 
                appointmentsResourcesTableAdapter.DeleteCommand = New SqlCommand()
                appointmentsResourcesTableAdapter.DeleteCommand.Connection = connection
                appointmentsResourcesTableAdapter.DeleteCommand.CommandText = "procGetAppointmentResources"
                appointmentsResourcesTableAdapter.DeleteCommand.CommandType = CommandType.StoredProcedure
                Dim cmdBuilder As New SqlClient.SqlCommandBuilder(appointmentsResourcesTableAdapter)
                appointmentsResourcesTableAdapter.DeleteCommand = cmdBuilder.GetDeleteCommand
 
                'End If
            End If
            If newChildRecords IsNot Nothing Then
                If newChildRecords.Tables(2).Rows.Count > 0 Then
                    AppointmentsTableAdapter.InsertCommand = New SqlCommand()
                    AppointmentsTableAdapter.InsertCommand.Connection = connection
                    AppointmentsTableAdapter.InsertCommand.CommandText = "procGetAppointments2"
                    AppointmentsTableAdapter.InsertCommand.CommandType = CommandType.StoredProcedure
                    Dim cmdBuilder2 As New SqlClient.SqlCommandBuilder(AppointmentsTableAdapter)
                    AppointmentsTableAdapter.InsertCommand = cmdBuilder2.GetInsertCommand
 
                    appointmentsResourcesTableAdapter.InsertCommand = New SqlCommand()
                    appointmentsResourcesTableAdapter.InsertCommand.Connection = connection
                    appointmentsResourcesTableAdapter.InsertCommand.CommandText = "procGetAppointmentResources"
                    appointmentsResourcesTableAdapter.InsertCommand.CommandType = CommandType.StoredProcedure
                    Dim cmdBuilder As New SqlClient.SqlCommandBuilder(appointmentsResourcesTableAdapter)
                    appointmentsResourcesTableAdapter.InsertCommand = cmdBuilder.GetInsertCommand
                    
                End If
            End If
            If modifiedChildRecords IsNot Nothing Then
                If modifiedChildRecords.Tables(2).Rows.Count > 0 Then
                    AppointmentsTableAdapter.UpdateCommand = New SqlCommand()
                    AppointmentsTableAdapter.UpdateCommand.Connection = connection
                    AppointmentsTableAdapter.UpdateCommand.CommandText = "procGetAppointments2"
                    AppointmentsTableAdapter.UpdateCommand.CommandType = CommandType.StoredProcedure
                    Dim cmdBuilder2 As New SqlClient.SqlCommandBuilder(AppointmentsTableAdapter)
                    AppointmentsTableAdapter.UpdateCommand = cmdBuilder2.GetUpdateCommand
 
                    appointmentsResourcesTableAdapter.UpdateCommand = New SqlCommand()
                    appointmentsResourcesTableAdapter.UpdateCommand.Connection = connection
                    appointmentsResourcesTableAdapter.UpdateCommand.CommandText = "procGetAppointmentResources"
                    appointmentsResourcesTableAdapter.UpdateCommand.CommandType = CommandType.StoredProcedure
                    Dim cmdBuilder As New SqlClient.SqlCommandBuilder(appointmentsResourcesTableAdapter)
                    appointmentsResourcesTableAdapter.UpdateCommand = cmdBuilder.GetUpdateCommand
                End If
            End If
 
            BindingContext(schedulerDataDataSet.Tables("Appointments")).EndCurrentEdit()
            BindingContext(schedulerDataDataSet.Tables("AppointmentsResources")).EndCurrentEdit()
            AppointmentsTableAdapter.Update(Me.schedulerDataDataSet.Tables("Appointments"))
            appointmentsResourcesTableAdapter.Update(Me.schedulerDataDataSet.Tables("AppointmentsResources"))
            Me.schedulerDataDataSet.AcceptChanges()
        Catch ex As Exception
            MessageBox.Show(String.Format("An error occurred during the update process:" & vbLf & "{0}", ex.Message))
        Finally
            If deletedChildRecords IsNot Nothing Then
                deletedChildRecords.Dispose()
            End If
            If newChildRecords IsNot Nothing Then
                newChildRecords.Dispose()
            End If
            If modifiedChildRecords IsNot Nothing Then
                modifiedChildRecords.Dispose()
            End If
        End Try
    End Sub
0
Timothy
Top achievements
Rank 1
answered on 26 Feb 2014, 04:21 PM
I'm kind of in a time crunch at work right now. However, I will be happy to look at this tonight. I was put on a different project and haven't worked the scheduler control since around September last year. But I will try to help if I can. I know how frustrating it was getting the scheduler to work.

(And you can call me Tim)
0
Silveron
Top achievements
Rank 1
answered on 26 Feb 2014, 04:27 PM
Thanks Tim!  I'm eagerly awaiting your expertise :)
0
Timothy
Top achievements
Rank 1
answered on 27 Feb 2014, 01:16 AM
Unfortunately I have very little expertise when it comes to this control. I've been looking at this for about 45 minutes and I can't seem to find anything that would help you. As I mentioned before, the code I posted was from last March. I went and looked at my latest version of the project and it would seem I took a completely different route.

I don't use resources anymore. If I remember correctly I was trying to see if I could treat an employee as a resource but apparently that never worked out for me. Also, I don't typically use the dataset GUI or table adapters. I did in this project because that's how the examples were written so I went with it. (I have a custom dll based off one of Microsoft's old Application Blocks call SQLHelper and I use that for data access.)

I modify my connection string at runtime as well. The application is designed to be implemented on the local servers of our customers.

As far as handling edits, I had to create event handlers for changes and deletions to the table the scheduler was bound to:
AddHandler Me.ClientSchedulerDS.Tables("CS_ScheduleInfo").RowChanged, New DataRowChangeEventHandler(AddressOf SaveChanges)
AddHandler Me.ClientSchedulerDS.Tables("CS_ScheduleInfo").RowDeleted, New DataRowChangeEventHandler(AddressOf SaveChanges)

The SaveChanges sub:
Private Sub SaveChanges(sender As Object, e As System.Data.DataRowChangeEventArgs)
    Try
        If Not Me.updating AndAlso Not Me._loading Then
            Me.updating = True
            Me.CS_ScheduleInfoTableAdapter.Adapter.AcceptChangesDuringUpdate = False
            CS_ScheduleInfoTableAdapter.Update(Me.ClientSchedulerDS.CS_ScheduleInfo)
            Me.ClientSchedulerDS.CS_ScheduleInfo.AcceptChanges()
            Me.updating = False
            Me.rleStatus.Text = "Changes saved."
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        InsertErrorLog(Now, GetExecutingAssembly.FullName, GetCurrentMethod.Name, My.User.Name, My.Computer.Name, ex.ToString(), ErrorLevel.Error, ex)
    End Try
End Sub

The only advice I can give at this point is to go over and over the online documentation to make sure you're following their guidelines. Also, you may want to create a separate post or ask Telerik if they can help.

Good luck.
0
Silveron
Top achievements
Rank 1
answered on 27 Feb 2014, 02:55 PM
Tim,  Thanks for taking the time to look into this.  I decided to start over again and use their examples of just adding the datasource and dataset at design time.. Once I get that working I will look into updating the app.config connection string based on what company is using it.

However, I can add an appointment but when I start using the GroupType I am having issues.  It inserts a negative incrementing number (-1, -2, etc..) into the AppointmentID field instead of using the ID number of the Appointment Table.  Not sure what I am doing wrong, I have all the mapping correct.  Below is my code if someone could help me out?

​
Private Function Appointments_CollectionChanged(ByVal sender As Object, ByVal e As NotifyCollectionChangedEventArgs) As String
 
        If e.Action <> Telerik.WinControls.Data.NotifyCollectionChangedAction.Batch Then
            AppointmentsResourcesTableAdapter.Adapter.AcceptChangesDuringUpdate = False
            Dim deletedChildRecords As spis_beSQLDataSet.AppointmentsResourcesDataTable = TryCast(Me.Spis_beSQLDataSet.AppointmentsResources.GetChanges(DataRowState.Deleted), spis_beSQLDataSet.AppointmentsResourcesDataTable)
            Dim newChildRecords As spis_beSQLDataSet.AppointmentsResourcesDataTable = TryCast(Me.Spis_beSQLDataSet.AppointmentsResources.GetChanges(DataRowState.Added), spis_beSQLDataSet.AppointmentsResourcesDataTable)
            Dim modifiedChildRecords As spis_beSQLDataSet.AppointmentsResourcesDataTable = TryCast(Me.Spis_beSQLDataSet.AppointmentsResources.GetChanges(DataRowState.Modified), spis_beSQLDataSet.AppointmentsResourcesDataTable)
            Try
                If deletedChildRecords IsNot Nothing Then
                    AppointmentsResourcesTableAdapter.Update(deletedChildRecords)
                End If
                AppointmentsTableAdapter.Update(Me.Spis_beSQLDataSet.Appointments)
                If newChildRecords IsNot Nothing Then
                    AppointmentsResourcesTableAdapter.Update(newChildRecords)
                End If
                If modifiedChildRecords IsNot Nothing Then
                    AppointmentsResourcesTableAdapter.Update(modifiedChildRecords)
                End If
                AppointmentsResourcesTableAdapter.Update(Me.Spis_beSQLDataSet.AppointmentsResources)
                Me.Spis_beSQLDataSet.AcceptChanges()
            Catch ex As Exception
                MessageBox.Show(String.Format("An error occurred during the update process:" & vbLf & "{0}", ex.Message))
            Finally
                If deletedChildRecords IsNot Nothing Then
                    deletedChildRecords.Dispose()
                End If
                If newChildRecords IsNot Nothing Then
                    newChildRecords.Dispose()
                End If
                If modifiedChildRecords IsNot Nothing Then
                    modifiedChildRecords.Dispose()
                End If
            End Try
        End If
 
    End Function
0
Silveron
Top achievements
Rank 1
answered on 27 Feb 2014, 08:00 PM
I was able to resolve it, had to change the increment step from -1 to 1.  The only issue I have now is when creating an exception, no matter what appointment I create the exception on, it creates a duplicate of that particular appointment.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 28 Feb 2014, 01:18 PM
Hello Silveron,

Thank you for contacting us.

Our Data Binding Walkthrough help article is quite useful about this topic. Note that in addition it is necessary to add a relation Appointments_Appointments1, linking "ID" to "ParentID" fields in the Appointments table. Thus, you will be able to save an exceptional appointment as a separate appointment in the data table.

We noticed that you have already opened another thread, related to this matter, I would kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

Thank you for your understanding.

Regards,
Desislava
Telerik
0
Silveron
Top achievements
Rank 1
answered on 28 Feb 2014, 01:35 PM
Would I then map the Appointments_Appointments1 to the "Exceptions"?  Also I noticed (this is a different issue) that when I 'drag' an existing appointment and hit the save button that it does not get saved.  Stepping through the code they are all 'Nothing'.  New records get saved ok.

​appointmentsResourcesTableAdapter.Adapter.AcceptChangesDuringUpdate = False
 Dim deletedChildRecords As spis_beSQLDataSet.AppointmentsResourcesDataTable = TryCast(Me.Spis_beSQLDataSet.AppointmentsResources.GetChanges(DataRowState.Deleted), spis_beSQLDataSet.AppointmentsResourcesDataTable)
 Dim newChildRecords As spis_beSQLDataSet.AppointmentsResourcesDataTable = TryCast(Me.Spis_beSQLDataSet.AppointmentsResources.GetChanges(DataRowState.Added), spis_beSQLDataSet.AppointmentsResourcesDataTable)
 Dim modifiedChildRecords As spis_beSQLDataSet.AppointmentsResourcesDataTable = TryCast(Me.Spis_beSQLDataSet.AppointmentsResources.GetChanges(DataRowState.Modified), spis_beSQLDataSet.AppointmentsResourcesDataTable)

      
0
Silveron
Top achievements
Rank 1
answered on 28 Feb 2014, 01:39 PM
FYI if I double click an appointment and change the time and then hit the save button, it saves correctly.  The problem is when I drag an appointment, it doesn't want to save.
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Mar 2014, 05:03 PM
Hello Silveron,

Thank you for writing back.

The relation "Appointments_Appointments1" should be mapped with the AppointmentMappingInfo.Exceptions property:
appointmentMappingInfo.Exceptions = "Appointments_Appointments1"

As to the question related to drag and drop behavior of the appointments I was unable to reproduce the problem that you are facing on my end. Editing appointment via the EditAppointment dialog is the same as  drag and drop behavior for the specific appointment. In both cases the start/end dates of the appointment are changed and these modifications are reflected in the database. Please find attached a sample video (drag and drop over the browser to play), demonstrating the behavior on my end. I have also attached my sample project together with the .bak file form my SQL database.

Please do not hesitate to contact us if you have any additional questions.

Regards,
Desislava
Telerik

DevCraft Q1'14 is here! Join the free online conference to see how this release solves your top-5 .NET challenges. Reserve your seat now!

0
Alejandro
Top achievements
Rank 1
answered on 12 Jun 2017, 03:37 PM
Works for me. Thank you. 
Tags
Scheduler and Reminder
Asked by
Joe Bohen
Top achievements
Rank 1
Answers by
Jordan
Telerik team
TwoLaJit
Top achievements
Rank 2
Joe Bohen
Top achievements
Rank 1
Thomas Schuster
Top achievements
Rank 1
Boyko Markov
Telerik team
rizu mussa
Top achievements
Rank 1
shinu rag
Top achievements
Rank 1
Dobry Zranchev
Telerik team
Aaron
Top achievements
Rank 1
Julian Benkov
Telerik team
Timothy
Top achievements
Rank 1
Silveron
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Alejandro
Top achievements
Rank 1
Share this question
or