Save Changes Automatically

7 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 18 Jan 2012 Link to this post

    Hi,
    I was wondering if someone could help me, which event is best to call to save any changes made in the RadScheduler.At present I I use a button to save all changes using TableAdapters. I would like the changes saved automatically ie if resized, dragged or a appointment is opend edited and closed.

    I've tried the .Appointments.CollectionChanged and when adding an event using CustomEditAppointmentDialog it adds the appointment twice.

    Thanks

  2. Karl
    Karl avatar
    172 posts
    Member since:
    Jun 2009

    Posted 19 Jan 2012 Link to this post

    Think I sorted this, I added the

    AppointmentsRowChanged

    and the

    AppointmentsRowDeleted

     on the dataset and it seems to work ok
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 20 Jan 2012 Link to this post

    Hi Karl,

    I am glad that you have sorted this out.

    Indeed, this is the correct approach since RadScheduler always keeps the source collection consistent by updating it when this is needed.

    Should you have any future questions, do not hesitate to contact us.

    Greetings,
    Ivan Todorov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  5. Mark
    Mark avatar
    8 posts
    Member since:
    Jun 2011

    Posted 30 Apr 2012 Link to this post

    If this helps anyone, here is what i did to get the rad scheduler to save the data:

    I followed the instructions in this video here (had to manually create an SQL CE database based on their sample access db):

    http://tv.telerik.com/winforms/radscheduler/codeless-data-binding-with-radscheduler-winforms

    But anytime i added or changed an appointment it wouldn't save it to the database.

    So i added this to my form load:

    radScheduler1.Appointments.CollectionChanged += new Telerik.WinControls.Data.NotifyCollectionChangedEventHandler(Appointments_CollectionChanged);

    And the event handler code is:

            private void Appointments_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
            {
                appointmentsTableAdapter.Update(this.schedulerdataDataSet.Appointments);
                this.schedulerdataDataSet.AcceptChanges();

                Console.WriteLine("Updated scheduler at " + DateTime.Now.ToString());
            }

    After doing that it actually saved the data to the database and seems to work now.

    Hope this helps.
  6. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 03 May 2012 Link to this post

    Hi Mark,

    Thank you for sharing your solution with our community.

    Your Telerik points have been updated.

    Feel free to contact us whenever you need any help or you want to leave your feedback.

    Regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  7. Gaston
    Gaston avatar
    3 posts
    Member since:
    Jan 2014

    Posted 01 Feb 2014 in reply to Mark Link to this post

    I tried to you use your code and it work as it should when it come to editing an appointment. But one slight problem... whenever i create a new appointment it always make duplicate?!? Do you have any idea why it might do that?
  8. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 05 Feb 2014 Link to this post

    Hello Gaston,

    Thank you fro your question.

    Most probably this happens because calling Update method of the table adapter causes the scheduler to update its appointments and another CollectionChanged will be caused. To avoid this you can simply put a boolean flag to indicate if you are doing an update:
    bool updating = false;
    void Appointments_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
    {
        if (updating)
        {
            return;
        }
     
        updating = true;
        appointmentsTableAdapter.Update(this.schedulerDataDataSet.Appointments);
        this.schedulerDataDataSet.AcceptChanges();
        updating = false;
    }

    Hope this will help. If you have any other questions, feel free to ask.

    Regards,
    Ivan Todorov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready