Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
Appointment's BindingListObject/Extended SQL fields access, the easy way please?
posted

Issue,
After adding a new Appointment to a UltraCalendarInfo object via the Add method I need to access the BindingListObject to set other SQL Associated field data via the BindingListObject. However, after calling Add, the BindingListObject has not been set and returns null.

History,
My current DAL--DataSupport object--was styled after the Infragistics sample but converted to use the SQL objects and modifications to include the extra fields in my table with the Insert/Select commands.

My form also uses an UltraMonthViewMulti control allowing the user to navigate between dates. One hickup--because of slow performance when refreshing the UltraDayView control at load times I had to reload only the selected date data into the UltraCalendarInfo object. Works well but the UltraMonthViewMulti no longer reveals which days acutally have appointments, duh, the data is not available now.

Approach,
Currently I provide a context menu with choices to change my extra field values. To accomodate this I trap the mouse down event and save the clicked appointment--if there was one--to a private member of the form class. Next when the context menu-click event is fired I use the previously selected appointment, if there was one--the context menu's Cut/Copy is not presented if there was no previoulsy selected appointment.

To make actual updates to the extended fields I cast the appointment's BindingListObjects to a DataRow/DataRowView and use it for setting the specified values.

Currently I have aprox 10 fields in my SQL 2008 DB, of which 4 are indexed/Lookups and also available for modification in the appointment dialog editor as comboboxes, textboxes, etc, etc

When making a copy of a new appointment these extra fields must be persisted from the original appointment to the new appointment.

Example (non-working),
//uci, the master UltraCalendarInfo control previously setup and associated with owners and appointments
//ts, the selected timeslot to paste the previously selected appointment; StartDateTime, EndDateTime
//db, the DAL used to load/update the UltraCalendarInfo object.
private void Copy(UltraCalendarInfo uci, SelectedTimeSlotRange ts, WinSchedulerDatabaseSupport db)
{
    //create the new appointment assigning appointment's StartDateTime and EndDateTime.
    Appointment newAppointment= new Appointment(ts.StartDateTime, ts.EndDateTime);

    //copy original appointment data to new appointment object -- could this be cloned?
    newAppointment.DataKey = mSelectedAppointment.DataKey;
    newAppointment.Subject = mSelectedAppointment.Subject;
    newAppointment.BarColor = mSelectedAppointment.BarColor;
    newAppointment.Appearance.BackColor = mSelectedAppointment.Appearance.BackColor;
    newAppointment.Appearance.BackColor = mSelectedAppointment.Appearance.BackColor.2;
    newAppointment.Description = mSelectedAppointment.Description;
    newAppointment.Owner = mSelectedAppointment.Owner;
    newAppointment.OwnderKey = mSelectedAppointment.OwnderKey;

    //Add the newly created appointment to the UltraCalendarInfo object.
    newAppointment = uci.Appointments.Add(newAppointment);

    //Retrieve the actual DataRow objects for both the appointment to copy and the newly created appt
    DataRow originalDR = ((DataRow)mSelectedAppointment).BindListObject;
    DataRow newDR = ((DataRow)newAppointment).BindListObject;

    //Assign custom sql fields to the DataRow object.
    //At this point we get an error because there is not BindListObject for the new Appointment?
    newDR["EmployeeId"] = originalDR["EmployeeId"];
    //... more assignments to the newDR ...

    //Update the Appointments table.
   
    db.UpdateAppointmentsTable();    
}

Help,
How do I get access to the new appointments BindingListObject????


Conclusion,
This approach is convoluted, by having to use separate paths for updating the data.
I've seen a discussion, on this forum, alluring to the possibility of inheriting from the Appointment class where my extra SQL fields could be extended property members but no example.

Is it possible to use inheritance on the Appointment class and not require accessing the Appointment's BindingListObject for updating my extended SQL field data, as in my approach above? At what point/where/how would the data need to be loaded and persisted using the approach.

Would you please provide a pertinent example of the approach using enheritance with DAL support. Something simple that includes DAL support and access from the Appointment Dialog Editor? I believe this would be of great interest to many of your customers, especially me.

PLEASE, PLEASE, PLEASE, PLEASE.... :)