TMS TPLANNNER AND TDBPLANER schedule and calendar components are mainly used to design a variety of different types of planning schedule applications. This component has won the best schedule with the Delphi Informant Magazine Reader Choice Award for 3 consecutive years. But the only disadvantage of this component is that there is a lack of help files, only one English TMS Planner Developers Guide uses documents. Demonstration is not very detailed. Recently, I need to study TDBPLANNER, I feel that I really have a great component, and I don't have to write too much code. It can easily bind the database with TDBPLANNER to operate directly on TDBPLANNER. Here, some use experience is introduced to everyone.
First, the corresponding component introduction
(1) TDBPLANNER components
TDBPLANNER is mainly composed of 12 display areas and methods (as shown below):
1. TPLANNER CAPTION: Table title. You can set whether you are displayed via the Planner's CAPTION property.
2. TPLANNER Navigator Buttons: Column Navigation button. You can set it via the Planner's NavigatorButtons property. You can choose whether to display.
3. TPLANNER Sidebar: Toolsum, can be set by the Planner's SideBar property, you can choose whether it is displayed. It can be set at the left, right, top and left and right sides of the table.
4. TPLANNER Header: Table head. You can set it through the PLANNER's HEADER attribute, you can choose whether it is displayed.
5. TPLANNER GRID: Table body. Settings can be set via the Planner's Display property.
6. TPLANNNERITEM: Schedule entry. The entries are universal display, including time and text. Setups can be made in DefaultItem.
7. TPLANNNERITEM: Schedule entry. Hypertext display mode, the title is fixed text.
8. TPLANNERITEM: Schedule entry. HTML display, this method can be inserted into a hypertext link.
9. TPLANNER FOOTER: Tail. The ranking resource is displayed through the progress bar.
10. TPLANNERITEM: The schedule entry that can be displayed in the form header.
11. TPLANNERITEM: Background schedule entry.
12. By customizing the drawing table head.
Setting Planner is a horizontal display or vertical display via Sidebar's Position property.
(2) TDBDAYSOURCE components
The TDBDAYSOURCE component is a bridge between the data control and the TDBPlanner control, which can associate the database field with some of the TDBPLANNER's display attributes.
The main properties are as follows:
Attributes
Description
AutoHeaderupdate
Automatically populate the date data to TDBPLANNER table head.
AutoInckey
When the database master key uses an automated increment, it should be set to TRUE so that TDBDaySourceDoes will not automatically generate a GUID primary key value.
If the database master key does not use automatic increment, the value should be set to false, so that when an item is added, TDBDaySourceDoes will automatically generate a GUID as the primary key value of the database.
DataSource
Set data source
DAY
Set the date value of the first column of TDBPLANER
EndTimefield
Set the field that saves the end time
Keyfield
Set the primary key field
Notesfield
Set the text content field of TPLANNERITEM
StartTimeField Set the field that saves the start time
Subjectfield
Set TPLANNERITEM's header field
Second, the demo program
1, database settings
There must be three fields in the database:
Field
Types of
Description
Starting time
(StartTime)
Full date / time
If the database does not support full-time / time type, you can use the character type of length bit 20.
End Time
(EndTime)
Full date / time
If the database does not support full-time / time type, you can use the character type of length bit 20.
Primary key (Key)
Character or automatic increment
If it is a character type, the length needs to be 40, and you can refer to the AutoIncKey property of the TDBDAYSOURCE component.
Of course, in order to record the schedule information, the following two fields are required:
Field
Types of
Description
Schedule
(Notes)
Character or note
Schedule title
(SBUJECT)
character
This field can be done, because in the default editing state (not using the edit control), the schedule title is unmodified.
The above field You can associate with the properties of the TDBDaySource component, so that these fields can be updated automatically when the content content of the TDBPLANNER changes.
If you need to record other additional information, you can set a field value via DBITEMSource.onfieldstoITEM and DBITEMSOURCE.ONITEMTOFIELDS events.
E.g:
The following code will map the Color field of the database to the Color property of TPLANNERITEM, and the Image field is mapped to the TPLANNNERITEM's imageID field, and the Caption field sets the title display of TPLANNerItem.
Procedure TFORM1.DBDAYSOURCE1FIELDSTOITEM (Sender: Tobject; Fields: tfields; item: tplannerItem);
Begin
Item.color: = tcolor (Fields.fieldByname ('color'). Asinteger;
Item.captionbkg: = item.color;
Item.imageId: = fields.fieldbyname ('image'). Asinteger;
If Fields.fieldByname ('caption'). Asboolean Then
Item.captiontype: = CTTIME
Else
Item.captiontype: = ctnone;
END;
Procedure TForm1.dbdaysource1Itemtofield (Sender: TOBJECT; FIELDS: TFIELDS;
Item: tplanneritem;
Begin
Fields.fieldbyName ('color'). Asinteger: = INTEGER (Item.color);
Fields.fieldbyName ('caption'). Asboolean: = item.captiontype = cttime;
Fields.fieldbyName ('Image'). Asinteger: = Item.imageId;
END;
2, program design
After the database is established, you can start building a demo program.
Place a Tadoconnection control, Tadotable control, TDataSource control, TDBDAYSOURCE control, and TDBPLANNER controls in Form1.
Each control property is set as follows:
a) Tadoconnection
Attributes
value
Description
Connectionstring
Provider = microsoft.jet.OLEDb.4.0; data source = test.mdb; persist security info = falseloginprompt
False
Connected
True
b) tadotable
Attributes
value
Description
Connection
Adoconnection1
TableName
Test
Active
True
c) TDataSource
Attributes
value
Description
DataSet
ADOTABLE1
d) TDBDAYSOURCE
Attributes
value
Description
AutoInckey
True
Because the automatic increment is used as the primary key, it is set to True here.
DataSource
DataSource1
StartTimefield
StartTime
EndTimefield
Endtime
Keyfield
Id
Subjectfield
Sunject
Notesfield
Notes
AutoHeaderupdate
True
DateFormat
YYYY-MM-DD
DAY
2005-3-16
e) TDBPLANNER
Attributes
value
Description
Align
Alclient
Autoinsdel
True
Allow automatic increase and delete Item
DefaultItem.captiontype
CTTIME
DefaultItem.showdeletebutton
True
Show TPLANNNERITEM's delete button, which can delete TPLANNerItem directly, and the record is also removed in the database.
EditDirect
True
Allow direct editing of Item on TDBPLANNER
Sidebar.position
SPLEFTRIGHT
Itemsource
DBDAYSOURCE1
Associate with the database
To add a schedule entry in TDBPLANNER, just add the following code in the RightClick of TDBPLANNER:
With dbplanner1.createItematureSerection Do
Begin
Update;
END;
If you don't want to right to add an entry to your mouse, you can also use other ways.
Note that there are two ways to add: TDBPLANNNNER.CREATETEM AND DBPLANNNER.CREATETEMATSELECTION. CreateItem requires you to specify start time and end time. CreateItem TSELECTION is established in the selection area.
Delete schedule entries can be deleted by TDBPLANNER.FREEITEM (AplannerItem: TPLANNERITEM).
The content of the modification schedule can be directly clicked to modify.
Is it very convenient, very simple to implement a general application? The TSIMPLEiteMeditor, TDEFAULTITOR, and TPERIDITEMEDITOREDITOR and TPERIDITEMEDITOR have edited the schedule entry in the component package, and the pop-up window can be set via TPLANNNERRECURRENCYEDITOR.
Demo program source code:
download