Save to DB

I have looked and looked and I cannot find anything for this. I am suprised that you only show how to load from the database but nothing shows how to save, even the 'examples'. What I am doing is very basic, but I can't figure it out. 

What I need to do is save the appointments to the database, and if they change the change the appointment it will have to be updated. I have no idea how to get to the appointment form, and handle events on it, as well as add anything to the database. Any help would be appreciated. Thank you!

This is in C# too!

1 Reply 1 reply marked as answer

AR Arulpriya Ramalingam Syncfusion Team December 28, 2020 06:53 PM UTC

Hi Andrew,

Thank you for using Syncfusion products.   
   
By default, the ScheduleControl does not have the support to reflect the changes in DataBase. However, this can be done by manually whenever the changes are modified in the appointment at run time by using the ItemChanged event. In that event, the CurrentItem property holds the modified changes and the modified changes can be pushed to DataBase manually. We created a simple sample as per your scenario and please make use of the below code and sample,   
   
Code example   
   
//Event triggering   
this.scheduleControl1.ItemChanged += ScheduleControl1_ItemChanged;   
   
//Event customization   
private void ScheduleControl1_ItemChanged(object sender, ScheduleAppointmentEventArgs e)   
{   
    BindingSource Bnd1 = new BindingSource();   
    Bnd1.DataSource = SimpleArrayListProvider.data;   
    //To get the modified row.   
    int rowNo = Bnd1.Find("UniqueID", e.CurrentItem.UniqueID);   
    if (rowNo != -1)   
    {   
        //Update changes when the existing record modified.   
        if (e.Action == ItemAction.Edit)   
        {   
            SimpleArrayListProvider.data.Rows[rowNo]["Subject"] = e.CurrentItem.Subject;   
            SimpleArrayListProvider.data.Rows[rowNo]["Content"] = e.CurrentItem.Content;   
            SimpleArrayListProvider.data.Rows[rowNo]["StartTime"] = e.CurrentItem.StartTime;   
            SimpleArrayListProvider.data.Rows[rowNo]["EndTime"] = e.CurrentItem.EndTime;   
            SimpleArrayListProvider.data.Rows[rowNo]["Label"] = e.CurrentItem.LabelValue;   
        }   
        //Update the DB when a row is deleted.   
        else if (e.Action == ItemAction.Delete)   
        {   
            SimpleArrayListProvider.data.Rows[rowNo].Delete();   
        }   
    }   
    //Update the changes when an appointment is added.   
    else if (rowNo == -1 && e.Action == ItemAction.Add)   
    {   
        DataRow row = SimpleArrayListProvider.data.NewRow();   
        row["Subject"] = e.CurrentItem.Subject;   
        row["Content"] = e.CurrentItem.Content;   
        row["StartTime"] = e.CurrentItem.StartTime;   
        row["EndTime"] = e.CurrentItem.EndTime;   
        row["Label"] = e.CurrentItem.LabelValue;   
        row["UniqueID"] = e.CurrentItem.UniqueID;   
        SimpleArrayListProvider.data.Rows.Add(row);   
    }   
}   
  
   
 
Please get back to us if you need any further assistance.
  
Regards,   
Arulpriya


Marked as answer
Loader.
Up arrow icon