Esempio n. 1
0
        private void BindToDataSet()
        {
            if (this.schedulerDataSet == null)
            {
                this.schedulerDataSet = new SchedulerDataSet();

                this.appointmentsAdapter.Fill(this.schedulerDataSet.Appointments);

                ResourcesTableAdapter resourcesAdapter = new ResourcesTableAdapter();
                resourcesAdapter.Fill(this.schedulerDataSet.Resources);

                AppointmentsResourcesTableAdapter appointmentsResourcesAdapter = new AppointmentsResourcesTableAdapter();
                appointmentsResourcesAdapter.Fill(this.schedulerDataSet.AppointmentsResources);
            }

            SchedulerBindingDataSource dataSource = new SchedulerBindingDataSource();

            dataSource.EventProvider.AppointmentFactory = this.radSchedulerDemo.AppointmentFactory;

            AppointmentMappingInfo appointmentMappingInfo = new AppointmentMappingInfo();

            appointmentMappingInfo.Mappings.Add(new SchedulerMapping("Email", "Email"));

            appointmentMappingInfo.UniqueId       = "ID";
            appointmentMappingInfo.Start          = "Start";
            appointmentMappingInfo.End            = "End";
            appointmentMappingInfo.Summary        = "Summary";
            appointmentMappingInfo.Description    = "Description";
            appointmentMappingInfo.Location       = "Location";
            appointmentMappingInfo.BackgroundId   = "BackgroundID";
            appointmentMappingInfo.StatusId       = "StatusID";
            appointmentMappingInfo.Resources      = "AppointmentsAppointmentsResources";
            appointmentMappingInfo.ResourceId     = "ResourceID";
            appointmentMappingInfo.RecurrenceRule = "RecurrenceRule";
            appointmentMappingInfo.Exceptions     = "AppointmentsAppointments";
            appointmentMappingInfo.MasterEventId  = "ParentID";
            appointmentMappingInfo.Visible        = "Visible";

            dataSource.EventProvider.Mapping    = appointmentMappingInfo;
            dataSource.EventProvider.DataSource = this.schedulerDataSet.Appointments;

            ResourceMappingInfo resourceMappingInfo = new ResourceMappingInfo();

            resourceMappingInfo.Id   = "ID";
            resourceMappingInfo.Name = "ResourceName";

            dataSource.ResourceProvider.Mapping    = resourceMappingInfo;
            dataSource.ResourceProvider.DataSource = this.schedulerDataSet.Resources;

            this.radSchedulerDemo.DataSource = dataSource;
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            //see http://msdn.microsoft.com/en-us/library/ms171933.aspx
            AppointmentsResourcesTableAdapter appointmentsResourcesAdapter = new AppointmentsResourcesTableAdapter();

            appointmentsResourcesAdapter.Adapter.AcceptChangesDuringUpdate = false;

            SchedulerDataSet.AppointmentsResourcesDataTable newChildRecords      = null;
            SchedulerDataSet.AppointmentsResourcesDataTable modifiedChildRecords = null;

            SchedulerDataSet.AppointmentsResourcesDataTable deletedChildRecords =
                this.schedulerDataSet.AppointmentsResources.GetChanges(DataRowState.Deleted)
                as SchedulerDataSet.AppointmentsResourcesDataTable;

            try
            {
                if (deletedChildRecords != null)
                {
                    appointmentsResourcesAdapter.Update(deletedChildRecords);
                }

                this.appointmentsAdapter.Update(this.schedulerDataSet.Appointments);
                //this.schedulerDataSet.Appointments.AcceptChanges();

                newChildRecords = this.schedulerDataSet.AppointmentsResources.GetChanges(DataRowState.Added)
                                  as SchedulerDataSet.AppointmentsResourcesDataTable;

                modifiedChildRecords = this.schedulerDataSet.AppointmentsResources.GetChanges(DataRowState.Modified)
                                       as SchedulerDataSet.AppointmentsResourcesDataTable;

                if (newChildRecords != null)
                {
                    appointmentsResourcesAdapter.Update(newChildRecords);
                }

                if (modifiedChildRecords != null)
                {
                    appointmentsResourcesAdapter.Update(modifiedChildRecords);
                }

                this.schedulerDataSet.AcceptChanges();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("An error occurred during the update process:\n{0}", ex.Message));
            }
            finally
            {
                if (deletedChildRecords != null)
                {
                    deletedChildRecords.Dispose();
                }
                if (newChildRecords != null)
                {
                    newChildRecords.Dispose();
                }
                if (modifiedChildRecords != null)
                {
                    modifiedChildRecords.Dispose();
                }
            }
        }