Consultor Eletrônico



Kbase P172113: How to save appointments from UltraWinSchedule controls to a data source
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   27/08/2010
Status: Unverified

GOAL:

How to save appointments from UltraWinSchedule controls to a data source

GOAL:

How to use UltraCalendaInfo component with a binding source

GOAL:

How to store UltraWinSchedule appointments in a database table, temp-table, or ProDataSet

GOAL:

Data binding and the Infragistics UltraWinSchedule controls

GOAL:

Sample code using UltraCalendarInfo and ProBindingSource

GOAL:

Example of a ProBindingSource CreateRow event handler

FACT(s) (Environment):

Windows
OpenEdge 10.2x

FIX:

The UltraCalendarInfo component manages and exposes all scheduling information and control state synchronized across one or more of the UltraWinSchedule controls (UltraCalendarCombo, UltraDayView. UltraMonthViewMulti, UltraMonthViewSingle, and UltraWeekView). UltraCalendarInfo has an Appointments property, which is a collection of all the Appointment objects that UltraCalendarInfo manages. This collection can be persisted in a data source such as a database table, temp-table, or ProDataSet using the ProBindingSource. In order to do so, the data source must contain at least three fields, corresponding to the Subject, StartDateTime and EndDateTime properties of the Appointment object. Other Appointment properties can also be stored if desired.
Because the Appointments property of UltraCalendarInfo is a collection, a query on a database table, temp-table, or ProDataSet (which includes its own queries) is a natural data source to bind to the component through a ProBindingSource. The ProBindingSource must contain the three fields already mentioned, plus whatever other Appointment properties are desired to be persisted. Existing appointments can be navigated and displayed in the UltraWinSchedule controls, and new appointments can be created in the controls and stored in the data source using the CreateRow event of the ProBindingSource. The CreateRow event handler is coded to store new records in the data source and keep the query synchronized.
Below is a simple example of a CreateRow event handler that stores the minimum information for each new appointment created in a temp-table. Note that the UltraCalendarInfo Appointments collection, like all .NET collections, is zero-based, so the last appointment to have been created is numbered "Count -1" rather than "Count".
/*------------------------------------------------------------------------------
Purpose: Event handler for CreateRow event in UltraCalendarInfo
binding source. Create a record in the ttAppointments
temp-table for each new appointment, and create a new
row in the query to keep the data source synchronized
Notes:
------------------------------------------------------------------------------*/
@VisualDesigner.
METHOD PRIVATE VOID bindingSource1_CreateRow( INPUT sender AS System.Object, INPUT args AS Progress.Data.CreateRowEventArgs ):
DEFINE VARIABLE a AS Infragistics.Win.UltraWinSchedule.Appointment NO-UNDO.

a = ultraCalendarInfo1:Appointments:Item[ultraCalendarIn.fo1:Appointments:Count - 1].
CREATE ttAppointment.
ASSIGN
ttAppointment.Subject = a:Subject
ttAppointment.StartDatetime = a:StartDateTime
ttappointment.EndDatetime = a:EndDateTime
.
hAppointmentQuery:CREATE-RESULT-LIST-ENTRY ().
args:Created = TRUE.

RETURN.
END METHOD..