商务月历(WEB)
# FastWeb之商务月历(WEB)
# 1. 说明
本示例使用日历与数据库结合的方式,将数据库中的事项附加至日历上实现事项月历的功能。在使用此示例前,请先检查 节点数据库 中的 FastWeb
连接设置是否有效。
通过本范例学习,可以掌握 TUgFullCalendar
的使用方法,并结合实例实现商务月历展示的功能。
# 2. 设计明细
开启FastWeb设计器,分别加入下插图之控件。或者点击左上角的[导入]
选择模板文件来打开对应模板。

1:TUgPageControl组件,控件名称为UgPageControl01
。
2:TUgPanel组件,控件名称为 UgPanel01
。
3:TUgButton组件,控件名称为 btnAddEvent
。
4:TUgButton组件,控件名称为 btnEditEvent
。
5:TUgButton组件,控件名称为 btnDeleteEvent
。
6:TUgButton组件,控件名称为 btnCreateCalendar
。
7:TUgDBGrid组件,控件名称为 UgDBGrid01
。
8:TUgClientDataSet组件,控件名称为 cdsEvent
。
9:TUgDataSource组件,控件名称为 dsEvent
。
10:在另一个标签页中的 TUgFullCalendar组件,控件名称为 FullCalendar01
。
UgWebRunFrame属性设置
Height
:设置页面高度=600
。Width
:设置页面宽度=800
。
1: UgPageControl01属性设置
Align
:设置控件的对齐方式,设置为alClient
。
点击窗体结构与检视器中的此控件,点击其左上角的新增图标按钮新增两项
TabSheet
。分别设置其Caption
属性为事项
与日历
。2:UgPanel01属性设置
此控件是按钮控件的容器。其位于第一个
TabSheet
中。Align
:设置控件的对齐方式,设置为alTop
。Height
:设置控件的高度,设置为40
。
3:btnAddEvent属性设置
Caption
:设置显示的字幕内容,设置为新增事项
。
4:btnEditEvent属性设置
Caption
:设置显示的字幕内容,设置为编辑事项
。
5:btnDeleteEvent属性设置
Caption
:设置显示的字幕内容,设置为删除事项
。
6:btnCreateCalendar属性设置
Caption
:设置显示的字幕内容,设置为生成月历
。
7:UgDBGrid01属性设置
UgDBGrid01
位于第一个TabSheet
中。双击表格打开字段编辑器,编辑以下的字段内容。Align
:设置对齐方式,设置为alClient
。DataSource
:设置数据来源,设置为dsEvent
。ReadOnly
:设置表格是否为只读,设置为True
。
9:dsEvent属性设置
DataSet
:设置绑定的数据集,设置为cdsEvent
。
10:UgFullCalendar01属性设置
此控件位于第二个
TabSheet
中。Align
:设置对齐方式,设置为alClient
。CalendarOptions
:设置日历的外观显示选项,其中修改AspectRatio
为1.527
,修改DisplayEventEnd
为True
,修改DisplayEventTime
为True
,修改EventLimit
为True
,修改EventTimeFormat
为H:mm
。
# 3. 程序设计
点击程序设计界面右下角的按钮,切换至单元选择界面,勾选需要使用的单元。该程式的程序不需要引用单元。
# 3.1. 程序初始设置
设置一个自定义函数,用于生成表单。
//JScript
function GetEditorForm(){
Result = new TUgWebForm(UniApplication);
Result.FreeOnClose = false;
Result.Width = 400;
Result.Height = 350;
Result.Bordericons = biSystemMenu;
var edId = new TUgNumberEdit(Result);
edId.Name = "edId";
edId.Height = 22;
edId.Enabled = true;
edId.Parent = Result;
edId.FieldLabel = UGMM.LT("事项ID");
edId.FieldLabelSeparator = "";
edId.FieldLabelAlign = laLeft;
edId.Align = alTop;
edId.Margins.Left = 8;
edId.Margins.Right = 8;
edId.AlignWithMargins = true;
edId.EmptyText = "Id";
var edTitle = new TUgEdit(Result);
edTitle.Name = "edTitle";
edTitle.Height = 22;
edTitle.Enabled = true;
edTitle.Parent = Result;
edTitle.FieldLabel = UGMM.LT("事项名称");
edTitle.FieldLabelSeparator = "";
edTitle.FieldLabelAlign = laLeft;
edTitle.Align = alTop;
edTitle.Margins.Left = 8;
edTitle.Margins.Right = 8;
edTitle.AlignWithMargins = true;
edTitle.EmptyText = UGMM.LT("请输入事项名称");
var edAllDay = new TUgCheckBox(Result);
edAllDay.Name = "edAllDay";
edAllDay.Height = 22;
edAllDay.Parent = Result;
edAllDay.FieldLabel = UGMM.LT("全天事项?");
edAllDay.FieldLabelAlign = laLeft;
edAllDay.Align = alTop;
edAllDay.Margins.Left = 8;
edAllDay.Margins.Right = 8;
edAllDay.AlignWithMargins = true;
var edStartStr = new TUgDateTimePicker(Result);
edStartStr.Name = "edStartStr";
edStartStr.Height = 22;
edStartStr.Parent = Result;
edStartStr.FieldLabel = UGMM.LT("事项开始日期");
edStartStr.FieldLabelSeparator = "";
edStartStr.FieldLabelAlign = laLeft;
edStartStr.Align = alTop;
edStartStr.Margins.Left = 8;
edStartStr.Margins.Right = 8;
edStartStr.AlignWithMargins = true;
edStartStr.DateTime = StrToDateTime(FormatdateTime("yyyy-mm-dd",now()) + " 00:00:00");
edStartStr.Kind = tUniDateTime;
var edEndStr = new TUgDateTimePicker(Result);
edEndStr.Name = "edEndStr";
edEndStr.Height = 22;
edEndStr.Parent = Result;
edEndStr.FieldLabel = UGMM.LT("事项结束日期");
edEndStr.FieldLabelSeparator = "";
edEndStr.FieldLabelAlign = laLeft;
edEndStr.Align = alTop;
edEndStr.Margins.Left = 8;
edEndStr.Margins.Right = 8;
edEndStr.AlignWithMargins = true;
edEndStr.DateTime = StrToDateTime(FormatdateTime("yyyy-mm-dd",now()) + " 23:59:59");
edEndStr.Kind = tUniDateTime;
var edUrl = new TUgEdit(Result);
edUrl.Name = "edUrl";
edUrl.Height = 22;
edUrl.Enabled = true;
edUrl.Parent = Result;
edUrl.FieldLabel = UGMM.LT("链接");
edUrl.FieldLabelSeparator = "";
edUrl.FieldLabelAlign = laLeft;
edUrl.Align = alTop;
edUrl.Margins.Left = 8;
edUrl.Margins.Right = 8;
edUrl.AlignWithMargins = true;
edUrl.EmptyText = UGMM.LT("请输入链接");
var edBackgroundColor = new TUgEdit(Result);
edBackgroundColor.Name = "edBackgroundColor";
edBackgroundColor.Height = 22;
edBackgroundColor.Enabled = true;
edBackgroundColor.Parent = Result;
edBackgroundColor.FieldLabel = UGMM.LT("背景颜色");
edBackgroundColor.FieldLabelSeparator = "";
edBackgroundColor.FieldLabelAlign = laLeft;
edBackgroundColor.Align = alTop;
edBackgroundColor.Margins.Left = 8;
edBackgroundColor.Margins.Right = 8;
edBackgroundColor.AlignWithMargins = true;
edBackgroundColor.EmptyText = UGMM.LT("背景颜色(css)");
var edBorderColor = new TUgEdit(Result);
edBorderColor.Name = "edBorderColor";
edBorderColor.Height = 22;
edBorderColor.Enabled = true;
edBorderColor.Parent = Result;
edBorderColor.FieldLabel = UGMM.LT("边框颜色");
edBorderColor.FieldLabelSeparator = "";
edBorderColor.FieldLabelAlign = laLeft;
edBorderColor.Align = alTop;
edBorderColor.Margins.Left = 8;
edBorderColor.Margins.Right = 8;
edBorderColor.AlignWithMargins = true;
edBorderColor.EmptyText = UGMM.LT("边框颜色(css)");
var edTextColor = new TUgEdit(Result);
edTextColor.Name = "edTextColor";
edTextColor.Height = 22;
edTextColor.Enabled = true;
edTextColor.Parent = Result;
edTextColor.FieldLabel = UGMM.LT("文本颜色");
edTextColor.FieldLabelSeparator = "";
edTextColor.FieldLabelAlign = laLeft;
edTextColor.Align = alTop;
edTextColor.Margins.Left = 8;
edTextColor.Margins.Right = 8;
edTextColor.AlignWithMargins = True;
edTextColor.EmptyText = UGMM.LT("文本颜色(css)");
var btOk = new TUgButton(Result);
btOk.Name = "btOk";
btOk.Height = 32;
btOk.Parent = Result;
btOk.Margins.Bottom = 6;
btOk.Margins.Left = 8;
btOk.Margins.Right = 8;
btOk.Align = alBottom;
btOk.Caption = UGMM.LT("保存");
btOk.ModalResult = mrOK;
btOk.AlignWithMargins = true;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//PasScript
Function GetEditorForm:TUgWebForm;
Var
edId: TUgNumberEdit;
edTitle:TUgEdit;
edAllDay:TUgCheckBox;
edStartStr:TUgDateTimePicker;
edEndStr:TUgDateTimePicker;
edUrl: TUgEdit;
edBackgroundColor: TUgEdit;
edBorderColor: TUgEdit;
edTextColor: TUgEdit;
btOk: TUgButton;
Begin
Result := TUgWebForm.Create(UniApplication);
Result.FreeOnClose := False;
Result.Width := 400;
Result.Height := 350;
Result.Bordericons :=biSystemMenu;
edId:=TUgNumberEdit.Create(Result);
edId.Name := 'edId';
edId.Height := 22;
edId.Enabled := true;
edId.Parent := Result;
edId.FieldLabel := UGMM.LT('事项ID');
edId.FieldLabelSeparator := '';
edId.FieldLabelAlign := laLeft;
edId.Align := alTop;
edId.Margins.Left := 8;
edId.Margins.Right := 8;
edId.AlignWithMargins := True;
edId.EmptyText:='Id';
edTitle:=TUgEdit.Create(Result);
edTitle.Name := 'edTitle';
edTitle.Height := 22;
edTitle.Enabled := true;
edTitle.Parent := Result;
edTitle.FieldLabel := UGMM.LT('事项名称');
edTitle.FieldLabelSeparator := '';
edTitle.FieldLabelAlign := laLeft;
edTitle.Align := alTop;
edTitle.Margins.Left := 8;
edTitle.Margins.Right := 8;
edTitle.AlignWithMargins := True;
edTitle.EmptyText:= UGMM.LT('请输入事项名称');
edAllDay := TUgCheckBox.Create(Result);
edAllDay.Name := 'edAllDay';
edAllDay.Height := 22;
edAllDay.Parent := Result;
edAllDay.FieldLabel := UGMM.LT('全天事项?');
edAllDay.FieldLabelAlign := laLeft;
edAllDay.Align := alTop;
edAllDay.Margins.Left := 8;
edAllDay.Margins.Right := 8;
edAllDay.AlignWithMargins := True;
edStartStr:=TUgDateTimePicker.Create(Result);
edStartStr.Name := 'edStartStr';
edStartStr.Height := 22;
edStartStr.Parent := Result;
edStartStr.FieldLabel := UGMM.LT('事项开始日期');
edStartStr.FieldLabelSeparator := '';
edStartStr.FieldLabelAlign := laLeft;
edStartStr.Align := alTop;
edStartStr.Margins.Left := 8;
edStartStr.Margins.Right := 8;
edStartStr.AlignWithMargins := True;
edStartStr.DateTime := StrToDateTime(FormatdateTime('yyyy-mm-dd',now()) + ' 00:00:00');
edStartStr.Kind := tUniDateTime;
edEndStr:=TUgDateTimePicker.Create(Result);
edEndStr.Name := 'edEndStr';
edEndStr.Height := 22;
edEndStr.Parent := Result;
edEndStr.FieldLabel := UGMM.LT('事项结束日期');
edEndStr.FieldLabelSeparator := '';
edEndStr.FieldLabelAlign := laLeft;
edEndStr.Align := alTop;
edEndStr.Margins.Left := 8;
edEndStr.Margins.Right := 8;
edEndStr.AlignWithMargins := True;
edEndStr.DateTime := StrToDateTime(FormatdateTime('yyyy-mm-dd',now()) + ' 23:59:59');
edEndStr.Kind := tUniDateTime;
edUrl:=TUgEdit.Create(Result);
edUrl.Name := 'edUrl';
edUrl.Height := 22;
edUrl.Enabled := true;
edUrl.Parent := Result;
edUrl.FieldLabel := UGMM.LT('链接');
edUrl.FieldLabelSeparator := '';
edUrl.FieldLabelAlign := laLeft;
edUrl.Align := alTop;
edUrl.Margins.Left := 8;
edUrl.Margins.Right := 8;
edUrl.AlignWithMargins := True;
edUrl.EmptyText:= UGMM.LT('请输入链接');
edBackgroundColor:=TUgEdit.Create(Result);
edBackgroundColor.Name := 'edBackgroundColor';
edBackgroundColor.Height := 22;
edBackgroundColor.Enabled := true;
edBackgroundColor.Parent := Result;
edBackgroundColor.FieldLabel := UGMM.LT('背景颜色');
edBackgroundColor.FieldLabelSeparator := '';
edBackgroundColor.FieldLabelAlign := laLeft;
edBackgroundColor.Align := alTop;
edBackgroundColor.Margins.Left := 8;
edBackgroundColor.Margins.Right := 8;
edBackgroundColor.AlignWithMargins := True;
edBackgroundColor.EmptyText:= UGMM.LT('背景颜色(css)');
edBorderColor:=TUgEdit.Create(Result);
edBorderColor.Name := 'edBorderColor';
edBorderColor.Height := 22;
edBorderColor.Enabled := true;
edBorderColor.Parent := Result;
edBorderColor.FieldLabel := UGMM.LT('边框颜色');
edBorderColor.FieldLabelSeparator := '';
edBorderColor.FieldLabelAlign := laLeft;
edBorderColor.Align := alTop;
edBorderColor.Margins.Left := 8;
edBorderColor.Margins.Right := 8;
edBorderColor.AlignWithMargins := True;
edBorderColor.EmptyText:= UGMM.LT('边框颜色(css)');
edTextColor:=TUgEdit.Create(Result);
edTextColor.Name := 'edTextColor';
edTextColor.Height := 22;
edTextColor.Enabled := true;
edTextColor.Parent := Result;
edTextColor.FieldLabel := UGMM.LT('文本颜色');
edTextColor.FieldLabelSeparator := '';
edTextColor.FieldLabelAlign := laLeft;
edTextColor.Align := alTop;
edTextColor.Margins.Left := 8;
edTextColor.Margins.Right := 8;
edTextColor.AlignWithMargins := True;
edTextColor.EmptyText:= UGMM.LT('文本颜色(css)');
btOk:=TUgButton.Create(Result);
btOk.Name := 'btOk';
btOk.Height := 32;
btOk.Parent := Result;
btOk.Margins.Bottom:= 6;
btOk.Margins.Left := 8;
btOk.Margins.Right := 8;
btOk.Align := alBottom;
btOk.Caption:= UGMM.LT('保存');
btOk.ModalResult := mrOK;
btOk.AlignWithMargins := True;
End;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Make sure to add code blocks to your code group
//JScript
btnAddEvent.OnClick = &btnAddEventOnClick;
btnEditEvent.OnClick = &btnEditEventOnClick;
btnDeleteEvent.OnClick = &btnDeleteEventOnClick;
btnCreateCalendar.OnClick = &btnCreateCalendarOnClick;
UGMM.LC(Self);
UgFullCalendar01.CalendarOptions.Locale = UGMM.LT("zh-cn");
UgPageControl01.TabIndex = 0;
cdsEvent.DataNodeName = "FastWeb";
cdsEvent.CommandText = "Select * from Task_FullCalendar Order By Id";
cdsEvent.Open;
2
3
4
5
6
7
8
9
10
11
12
13
//PasScript
procedure UgWebRunFrameOnAfterRunScript(const sender: tobject);
begin
UGMM.LC(Self);
UgFullCalendar01.CalendarOptions.Locale := UGMM.LT('zh-cn');
end;
Begin
UgPageControl01.TabIndex := 0;
cdsEvent.DataNodeName := 'FastWeb';
cdsEvent.CommandText := 'Select * from Task_FullCalendar Order By Id';
cdsEvent.Open;
End.
2
3
4
5
6
7
8
9
10
11
12
13
// Make sure to add code blocks to your code group
# 3.2. 事件设置
- 3:btnAddEvent-OnClick事件
点击以新增事项。
//JScript
function btnAddEventOnClick(sender){
var F = GetEditorForm();
Try{
F.Caption = UGMM.LT("添加事项");
var e = "";
var b = true;
While (b){
if (e != "")
MessageDlg(e,mtError,mbOK);
if (F.ShowModal == mrOK){
Try{
if (TUgNumberEdit(F.FindComponent("edId")).Value == 0)
RaiseException(UGMM.LT("事项ID"));
//添加到内存表
cdsEvent.Append;
var v = TUgNumberEdit(F.FindComponent("edID")).Value;
cdsEvent.FieldByName("Id").AsString = v;
cdsEvent.FieldByName("Title").AsString = TUgEdit(F.FindComponent("edTitle")).Text;
cdsEvent.FieldByName("AllDay").AsBoolean = TUgCheckBox(F.FindComponent("edAllDay")).Checked;
cdsEvent.FieldByName("StartStr").AsDateTime = TUgDateTimePicker(F.FindComponent("edStartStr")).DateTime;
cdsEvent.FieldByName("EndStr").AsDateTime = TUgDateTimePicker(F.FindComponent("edEndStr")).DateTime;
cdsEvent.FieldByName("Url").AsString = TUgEdit(F.FindComponent("edUrl")).Text;
cdsEvent.FieldByName("BackgroundColor").AsString = TUgEdit(F.FindComponent("edBackgroundColor")).Text;
cdsEvent.FieldByName("BorderColor").AsString = TUgEdit(F.FindComponent("edBorderColor")).Text;
cdsEvent.FieldByName("TextColor").AsString = TUgEdit(F.FindComponent("edTextColor")).Text;
cdsEvent.Post;
cdsEvent.SubmitUpdates;
b = false;
}
Except{
RaiseException(ExceptionMessage);
}
} else{
b = false;
}
}
}
Finally{
F.Free;
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//PasScript
procedure btnAddEventOnClick(sender: tobject);
//添加事项
Var
F:TUgWebForm;
b:Boolean;
e:string;
s:String;
v:variant;
Begin
F:=GetEditorForm;
Try
F.Caption := UGMM.LT('添加事项');
e:='';
b:=True;
While b do
Begin
if e<>'' then
MessageDlg(e,mtError,mbOK);
if F.ShowModal = mrOK then
Begin
Try
if TUgNumberEdit(F.FindComponent('edID')).Value = 0 then
RaiseException(UGMM.LT('事项ID'));
//添加到内存表
cdsEvent.Append;
v := TUgNumberEdit(F.FindComponent('edID')).Value;
cdsEvent.FieldByName('Id').AsString := v;
cdsEvent.FieldByName('Title').AsString := TUgEdit(F.FindComponent('edTitle')).Text;
cdsEvent.FieldByName('AllDay').AsBoolean := TUgCheckBox(F.FindComponent('edAllDay')).Checked;
cdsEvent.FieldByName('StartStr').AsDateTime := TUgDateTimePicker(F.FindComponent('edStartStr')).DateTime;
cdsEvent.FieldByName('EndStr').AsDateTime := TUgDateTimePicker(F.FindComponent('edEndStr')).DateTime;
cdsEvent.FieldByName('Url').AsString := TUgEdit(F.FindComponent('edUrl')).Text;
cdsEvent.FieldByName('BackgroundColor').AsString := TUgEdit(F.FindComponent('edBackgroundColor')).Text;
cdsEvent.FieldByName('BorderColor').AsString := TUgEdit(F.FindComponent('edBorderColor')).Text;
cdsEvent.FieldByName('TextColor').AsString := TUgEdit(F.FindComponent('edTextColor')).Text;
cdsEvent.Post;
cdsEvent.SubmitUpdates;
b := False;
Except{ExceptionMessage}
e:=ExceptionMessage;
end;
End else
b:=False;
End;
Finally
F.Free;
end;
end;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Make sure to add code blocks to your code group
- 4:btnEditTask-OnClick事件
点击按钮以打开编辑事项的界面。
//JScript
function btnEditEventOnClick(sender){
var F=GetEditorForm;
Try{
F.Caption = UGMM.LT("修改任务");
var e = "";
var b = True;
TUgNumberEdit(F.FindComponent("edId")).Value = cdsEvent.FieldByName("Id").AsInteger;
TUgEdit(F.FindComponent("edTitle")).Text = cdsEvent.FieldByName("Title").AsString;
TUgCheckBox(F.FindComponent("edAllDay")).Checked = cdsEvent.FieldByName("AllDay").AsBoolean;
TUgDateTimePicker(F.FindComponent("edStartStr")).DateTime = cdsEvent.FieldByName("StartStr").AsDateTime;
TUgDateTimePicker(F.FindComponent("edEndStr")).DateTime = cdsEvent.FieldByName("EndStr").AsDateTime;
TUgEdit(F.FindComponent("edUrl")).Text = cdsEvent.FieldByName("Url").AsString;
TUgEdit(F.FindComponent("edBackgroundColor")).Text = cdsEvent.FieldByName("BackgroundColor").AsString;
TUgEdit(F.FindComponent("edBorderColor")).Text = cdsEvent.FieldByName("BorderColor").AsString;
TUgEdit(F.FindComponent("edTextColor")).Text = cdsEvent.FieldByName("TextColor").AsString;
While (b){
if (e != ""){
MessageDlg(e,mtError,mbOK);
}
if (F.ShowModal == mrOK){
Try{
if (TUgNumberEdit(F.FindComponent("edId")).Value == 0)
RaiseException(UGMM.LT("事项ID"));
//添加到内存表
cdsEvent.Edit;
var v = TUgNumberEdit(F.FindComponent("edId")).Value;
cdsEvent.FieldByName("Id").AsString = v;
cdsEvent.FieldByName("Title").AsString = TUgEdit(F.FindComponent("edTitle")).Text;
cdsEvent.FieldByName("AllDay").AsBoolean = TUgCheckBox(F.FindComponent("edAllDay")).Checked;
cdsEvent.FieldByName("StartStr").AsDateTime = TUgDateTimePicker(F.FindComponent("edStartStr")).DateTime;
cdsEvent.FieldByName("EndStr").AsDateTime = TUgDateTimePicker(F.FindComponent("edEndStr")).DateTime;
cdsEvent.FieldByName("Url").AsString = TUgEdit(F.FindComponent("edUrl")).Text;
cdsEvent.FieldByName("BackgroundColor").AsString = TUgEdit(F.FindComponent("edBackgroundColor")).Text;
cdsEvent.FieldByName("BorderColor").AsString = TUgEdit(F.FindComponent("edBorderColor")).Text;
cdsEvent.FieldByName("TextColor").AsString = TUgEdit(F.FindComponent("edTextColor")).Text;
cdsEvent.Post;
cdsEvent.SubmitUpdates;
b = False;
}
Except{RaiseException(ExceptionMessage);}
}else{
b = False;
}
}
}
Finally{
F.Free;
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//PasScript
procedure btnEditEventOnClick(sender: tobject);
//编辑事项
Var
F:TUgWebForm;
b:Boolean;
e:string;
s:String;
v:variant;
Begin
F:=GetEditorForm;
Try
F.Caption := UGMM.LT('修改任务');
e:='';
b:=True;
TUgNumberEdit(F.FindComponent('edId')).Value := cdsEvent.FieldByName('Id').AsInteger;
TUgEdit(F.FindComponent('edTitle')).Text := cdsEvent.FieldByName('Title').AsString;
TUgCheckBox(F.FindComponent('edAllDay')).Checked := cdsEvent.FieldByName('AllDay').AsBoolean;
TUgDateTimePicker(F.FindComponent('edStartStr')).DateTime := cdsEvent.FieldByName('StartStr').AsDateTime;
TUgDateTimePicker(F.FindComponent('edEndStr')).DateTime := cdsEvent.FieldByName('EndStr').AsDateTime;
TUgEdit(F.FindComponent('edUrl')).Text := cdsEvent.FieldByName('Url').AsString;
TUgEdit(F.FindComponent('edBackgroundColor')).Text := cdsEvent.FieldByName('BackgroundColor').AsString;
TUgEdit(F.FindComponent('edBorderColor')).Text := cdsEvent.FieldByName('BorderColor').AsString;
TUgEdit(F.FindComponent('edTextColor')).Text := cdsEvent.FieldByName('TextColor').AsString;
While b do
Begin
if e<>'' then
MessageDlg(e,mtError,mbOK);
if F.ShowModal = mrOK then
Begin
Try
if TUgNumberEdit(F.FindComponent('edId')).Value = 0 then
RaiseException(UGMM.LT('事项ID'));
//添加到内存表
cdsEvent.Edit;
v := TUgNumberEdit(F.FindComponent('edId')).Value;
cdsEvent.FieldByName('Id').AsString := v;
cdsEvent.FieldByName('Title').AsString := TUgEdit(F.FindComponent('edTitle')).Text;
cdsEvent.FieldByName('AllDay').AsBoolean := TUgCheckBox(F.FindComponent('edAllDay')).Checked;
cdsEvent.FieldByName('StartStr').AsDateTime := TUgDateTimePicker(F.FindComponent('edStartStr')).DateTime;
cdsEvent.FieldByName('EndStr').AsDateTime := TUgDateTimePicker(F.FindComponent('edEndStr')).DateTime;
cdsEvent.FieldByName('Url').AsString := TUgEdit(F.FindComponent('edUrl')).Text;
cdsEvent.FieldByName('BackgroundColor').AsString := TUgEdit(F.FindComponent('edBackgroundColor')).Text;
cdsEvent.FieldByName('BorderColor').AsString := TUgEdit(F.FindComponent('edBorderColor')).Text;
cdsEvent.FieldByName('TextColor').AsString := TUgEdit(F.FindComponent('edTextColor')).Text;
cdsEvent.Post;
cdsEvent.SubmitUpdates;
b := False;
Except{ExceptionMessage}
e:=ExceptionMessage;
end;
End else
b:=False;
End;
Finally
F.Free;
end;
end;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Make sure to add code blocks to your code group
- 5:btnDeleteEvent-OnClick事件
点击按钮以删除选择的事项。
//JScript
function btnDeleteEventOnClick(sender){
if (cdsEvent.IsEmpty)
RaiseException(UGMM.LT("没有记录无法删除"));
if (MessageDlg(UGMM.LT("注意:是否删除该事项?"),mtWarning,mbYes + mbNo) == mrYes){
cdsEvent.Delete;
cdsEvent.SubmitUpdates;
}
}
2
3
4
5
6
7
8
9
10
//PasScript
procedure btnDeleteEventOnClick(sender: tobject);
//删除事项
begin
if cdsEvent.IsEmpty then
RaiseException(UGMM.LT('没有记录无法删除'));
if MessageDlg(UGMM.LT('注意:是否删除该事项?'),mtWarning,mbYes + mbNo) = mrYes then
Begin
cdsEvent.Delete;
cdsEvent.SubmitUpdates;
end;
end;
2
3
4
5
6
7
8
9
10
11
12
13
// Make sure to add code blocks to your code group
- 6:btnCreateCalendar-OnClick事件
点击以创建日历。
//JScript
function btnCreateCalendarOnClick(sender){
var EventObject = new TEventObject();
UgFullCalendar01.RemoveEvents("");
cdsEvent.First;
while (!(cdsEvent.Eof)){
EventObject.Id = cdsEvent.FieldByName("Id").AsString;
EventObject.Title = cdsEvent.FieldByName("Title").AsString;
EventObject.AllDay = cdsEvent.FieldByName("AllDay").AsBoolean;
EventObject.StartStr = cdsEvent.FieldByName("StartStr").AsString;
EventObject.EndStr = cdsEvent.FieldByName("EndStr").AsString;
EventObject.Url = cdsEvent.FieldByName("Url").AsString;
EventObject.BackgroundColor = cdsEvent.FieldByName("BackgroundColor").AsString;
EventObject.BorderColor = cdsEvent.FieldByName("BorderColor").AsString;
EventObject.TextColor = cdsEvent.FieldByName("TextColor").AsString;
UgFullCalendar01.AddEvent(EventObject);
cdsEvent.Next;
}
UgPageControl01.TabIndex = 1;
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//PasScript
procedure btnCreateCalendarOnClick(sender: tobject);
//创建日历
var
EventObject: TEventObject;
begin
EventObject := TEventObject.Create;
UgFullCalendar01.RemoveEvents('');
cdsEvent.First;
while not cdsEvent.Eof do
Begin
EventObject.Id := cdsEvent.FieldByName('Id').AsString;
EventObject.Title := cdsEvent.FieldByName('Title').AsString;
EventObject.AllDay := cdsEvent.FieldByName('AllDay').AsBoolean;
EventObject.StartStr := cdsEvent.FieldByName('StartStr').AsString;
EventObject.EndStr := cdsEvent.FieldByName('EndStr').AsString;
EventObject.Url := cdsEvent.FieldByName('Url').AsString;
EventObject.BackgroundColor := cdsEvent.FieldByName('BackgroundColor').AsString;
EventObject.BorderColor := cdsEvent.FieldByName('BorderColor').AsString;
EventObject.TextColor := cdsEvent.FieldByName('TextColor').AsString;
UgFullCalendar01.AddEvent(EventObject);
cdsEvent.Next;
End;
UgPageControl01.TabIndex := 1;
end;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Make sure to add code blocks to your code group
# 4. 运行结果
使用鼠标在FastWeb菜单,点击[保存至数据库]
按钮,将其保存至数据库,点击[调试运行]
确认能够正常打开。
在事项编辑的界面,可进行事项的新增、编辑、删除等操作。点击 [生成月历]
,可看到事项在月历中的展示情况。

