爱招飞帮助手册 爱招飞帮助手册
首页
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 功能用法
    • 专用模板
    • 开发流程
    • 函数程序
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 系统工具
    • 系统管理
    • 数据库工具
    • 专用模板
    • 外部功能
    • 开发流程
    • 函数代码
  • 开发手册
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 功能用法
    • 专用模板
    • 开发流程
    • 函数程序
  • 开发手册
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 功能用法
    • 专用模板
    • 开发流程
    • 函数程序
  • 开发手册
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
    • 报表设计
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
    • RestAPI
    • WebSocket
  • 学习手册

    • 安装配置
    • 快速上手
    • 程序架构
    • 界面介绍
    • 功能介绍
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
    • 预设资料
    • RestAPI说明
    • WebSocket说明
    • MQTT说明
    • Python说明
    • 自定程序
    • 运行卫士
    • 自动化作业
    • 函数程序
    • 控件使用
  • 开发手册
  • FastERP
  • FastWeb
  • Smart
  • PinToo
  • Flying
  • TARS
  • 通用功能

    • Report
    • Script
    • Echarts
    • Chart
    • DB Install
    • HiDesk
    • HiNAT
    • FastBPM
    • ReportBuilder
首页
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 功能用法
    • 专用模板
    • 开发流程
    • 函数程序
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 系统工具
    • 系统管理
    • 数据库工具
    • 专用模板
    • 外部功能
    • 开发流程
    • 函数代码
  • 开发手册
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 功能用法
    • 专用模板
    • 开发流程
    • 函数程序
  • 开发手册
  • 学习手册

    • 基本入门
    • 功能介绍
    • 控件说明
    • 功能用法
    • 专用模板
    • 开发流程
    • 函数程序
  • 开发手册
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
    • 报表设计
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
    • RestAPI
    • WebSocket
  • 学习手册

    • 安装配置
    • 快速上手
    • 程序架构
    • 界面介绍
    • 功能介绍
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
  • 学习手册

    • 安装配置
    • 快速上手
    • 界面介绍
    • 功能介绍
    • 预设资料
    • RestAPI说明
    • WebSocket说明
    • MQTT说明
    • Python说明
    • 自定程序
    • 运行卫士
    • 自动化作业
    • 函数程序
    • 控件使用
  • 开发手册
  • FastERP
  • FastWeb
  • Smart
  • PinToo
  • Flying
  • TARS
  • 通用功能

    • Report
    • Script
    • Echarts
    • Chart
    • DB Install
    • HiDesk
    • HiNAT
    • FastBPM
    • ReportBuilder
  • FastWeb帮助主页
  • 学习手册

  • 开发手册

    • 通讯协议

    • 交互输出

      • 打印

      • 条码

      • 图表

        • Google图表(WEB)
        • 甘特图展示(WEB)
          • 1. 说明
          • 2. 设计明细
          • 3. 程序设计
            • 3.1. 程序初始设置
            • 3.2. 事件设置
          • 4. 运行结果
        • 商务月历(WEB)
        • 时间线(WEB)
    • 媒体存取

    • 人工智慧

    • 实例运用

目录

甘特图展示(WEB)

# FastWeb之甘特图展示(WEB)

# 1. 说明

  采用与数据库连接的方式,通过任务的录入更新,以生成甘特图,展示相关的功能。在使用此示例前,请先检查 节点数据库 中的 FastWeb 连接设置是否有效。

  通过本范例学习,可以掌握甘特图图表的生成方式,并结合数据库实例实现甘特图的展示功能。

  甘特图是项目管理最常用的图表之一,如果要策划落地一个大型活动项目,为了合理地规划活动进程,通常会将整个项目划分为细致的任务,并希望能清晰地列出每个任务的历时情况以及它们之间的关系。对这一需求,一般的表格就显得有些不足了,尤其对于时间上有重叠的多项活动,查看起来并不方便。这个时候,甘特图就就可以发挥其作用。简单来说,甘特图就是将任务与时间联系起来的一种图表形式,能够清晰展示每个任务的历时长短。

  FastWeb中也集成了甘特图展示的控件,可结合数据库来实现动态展示的相关功能。接下来将介绍用于结合使用的范例。

# 2. 设计明细

  开启FastWeb设计器,分别加入下插图之控件。或者点击左上角的[导入]选择模板文件来打开对应模板。

  1:TUgPageControl组件,控件名称为UgPageControl01。

  2:TUgButton组件,控件名称为btnAddTask。

  3:TUgButton组件,控件名称为btnEditTask。

  4:TUgButton组件,控件名称为btnDelTask。

  5:TUgButtton组件,控件名称为btnCreateGantt。

  6:TUgDBGrid组件,控件名称为UgDBGrid01。

  7:TUgDataSource组件,控件名称为dsTask。

  8:TUgClientDataSet组件,控件名称为cdsTask。

  9:此控件为显示于甘特图标签页中的TUgGanttChart组件,控件名称为GanttChart01。

  • UgWebRunFrame属性设置

    • Height:设置页面高度=768。
    • Width:设置页面宽度=1024。
  • 1:UgPageControl01属性设置

      选择此控件后,在窗体结构与检视器中点击左上角的添加按钮,新增两个标签页,分别为UniTabSheet01与UniTabSheet02。分别修改Caption属性为任务与甘特图。

    • Align:设置对齐的选项,设置为alClient。
  • UgPanel01属性设置

      此控件显示于标签页任务中,作为操作按钮的布局容器使用。

    • Align:设置控件的对齐方式,设置为alTop。
  • 2:btnAddTask属性设置

    • Caption:设置显示的文本内容,设置为新增任务。
  • 3:btnEditTask属性设置

    • Caption:设置显示的文本内容,设置为编辑任务。
  • 4:btnDelTask属性设置

    • Caption:设置显示的文本内容,设置为删除任务。
  • 5:btnCreateGantt属性设置

    • Caption:设置显示的文本内容,设置为生成甘特图。
  • 6:UgDBGrid01属性设置

      此控件位于标签页任务中。

    • Align:设置控件的对齐方式,设置为alClient。
    • ReadOnly:设置控件表格是否为只读的模式,设置为True。

      双击此控件,打开字段编辑对话框,按照图示进行数据表格的设置。

  • 7:dsTask属性设置

    • DataSet:设置绑定显示的数据集,设置为cdsTask。
  • 9:UgGanttChart01属性设置

      此控件显示在标签页甘特图中。

    • Align:设置对齐方式,设置为alClient。

# 3. 程序设计

  点击程序设计界面右下角的按钮,切换至单元选择界面,勾选需要使用的单元。该程式的程序不需要引用单元。

# 3.1. 程序初始设置

  该程式的程序初始设置包含多语言的设置以及数据集的初始化等操作。

    //JScript
      UGMM.LC(Self);
      UgGanttChart01.GanttOptions.Lang = UGMM.LT("cn");
      
      UgPageControl01.TabIndex = 0;
      cdsTask.DataNodeName = "FastWeb";
      cdsTask.CommandText = "Select * from Task_Gantt Order By pID";
      cdsTask.Open;
      
      btnAddTask.OnClick = &btnAddTaskOnClick;
      btnEditTask.OnClick = &btnEditTaskOnClick;
      btnDelTask.OnClick = &btnDelTaskOnClick;
      btnCreateGantt.OnClick = &btnCreateGanttOnClick;
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    //PasScript
    procedure UgWebRunFrameOnAfterRunScript(const sender: tobject);
    begin
      UGMM.LC(Self);
      UgGanttChart01.GanttOptions.Lang := UGMM.LT('cn');
    end;
    
    Begin
      UgPageControl01.TabIndex := 0;
      cdsTask.DataNodeName := 'FastWeb';
      cdsTask.CommandText := 'Select * from Task_Gantt Order By pID';
      cdsTask.Open;
    End.
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    // Make sure to add code blocks to your code group

      除初始化的相关设置外,还包含了一编辑界面生成的函数。

      //JScript
      function GetEditorForm(){
        Result = new TUgWebForm(UniApplication);
        Result.FreeOnClose = false;
        Result.Width = 400;
        Result.Height = 530;
        Result.Bordericons = biSystemMenu;
        
        var edpID = new TUgNumberEdit(Result);
        edpID.Name = "edpID";
        edpID.Height = 22;
        edpID.Enabled = true;
        edpID.Parent = Result;
        edpID.FieldLabel = UGMM.LT("任务ID");
        edpID.FieldLabelSeparator = "";
        edpID.FieldLabelAlign = laLeft;
        edpID.Align = alTop;
        edpID.Margins.Left = 8;
        edpID.Margins.Right = 8;
        edpID.AlignWithMargins = true;
        edpID.EmptyText = "pID";
        
        var edpName = new TUgEdit(Result);
        edpName.Name = "edpName";
        edpName.Height = 22;
        edpName.Enabled = true;
        edpName.Parent = Result;
        edpName.FieldLabel = UGMM.LT("任务名称");
        edpName.FieldLabelSeparator = "";
        edpName.FieldLabelAlign = laLeft;
        edpName.Align = alTop;
        edpName.Margins.Left = 8;
        edpName.Margins.Right = 8;
        edpName.AlignWithMargins = true;
        edpName.EmptyText = UGMM.LT("请输入任务名称");
        
        var edpStart =new TUgDateTimePicker(Result);
        edpStart.Name = "edpStart";
        edpStart.Height = 22;
        edpStart.Parent = Result;
        edpStart.FieldLabel = UGMM.LT("任务开始日期");
        edpStart.FieldLabelSeparator = "";
        edpStart.FieldLabelAlign = laLeft;
        edpStart.Align = alTop;
        edpStart.Margins.Left = 8;
        edpStart.Margins.Right = 8;
        edpStart.AlignWithMargins = true;
        edpStart.DateTime = StrToDateTime(FormatdateTime("yyyy-mm-dd",now()) + " 00:00:00");
        edpStart.Kind = tUniDateTime; 
        
        var edpEnd = new TUgDateTimePicker(Result);
        edpEnd.Name = "edpEnd";
        edpEnd.Height = 22;
        edpEnd.Parent = Result;
        edpEnd.FieldLabel = UGMM.LT("任务结束日期");
        edpEnd.FieldLabelSeparator = "";
        edpEnd.FieldLabelAlign = laLeft;
        edpEnd.Align = alTop;
        edpEnd.Margins.Left = 8;
        edpEnd.Margins.Right = 8;
        edpEnd.AlignWithMargins = true;
        edpEnd.DateTime = StrToDateTime(FormatdateTime("yyyy-mm-dd",now()) + " 23:59:59");
        edpEnd.Kind = tUniDateTime; 
        
        var edpClass = new TUgComboBox(Result);
        edpClass.Name = "edpClass";
        edpClass.Height = 22;
        edpClass.Parent = Result;
        edpClass.FieldLabel = UGMM.LT("仪表样式");
        edpClass.FieldLabelSeparator = "";
        edpClass.FieldLabelAlign = laLeft;
        edpClass.Align = alTop;
        edpClass.Margins.Left = 8;
        edpClass.Margins.Right = 8;
        edpClass.AlignWithMargins = True;
        edpClass.EmptyText = UGMM.LT("请选择...");
        edpClass.Items.CommaText = "ggroupblack,gtaskblue,gtaskgreen,gtaskred,gtaskyellow,gtaskpurple,gtaskpink";
        edpClass.Style = csDropDownList;
        
        var edpLink = new TUgEdit(Result);
        edpLink.Name = "edpLink";
        edpLink.Height = 22;
        edpLink.Enabled = true;
        edpLink.Parent = Result;
        edpLink.FieldLabel = UGMM.LT("任务链接");
        edpLink.FieldLabelSeparator = "";
        edpLink.FieldLabelAlign = laLeft;
        edpLink.Align = alTop;
        edpLink.Margins.Left = 8;
        edpLink.Margins.Right = 8;
        edpLink.AlignWithMargins = true;
        edpLink.EmptyText = UGMM.LT("请输入任务链接");
        
        var edpMile = new TUgCheckBox(Result);
        edpMile.Name = "edpMile";
        edpMile.Height = 22;
        edpMile.Parent = Result;
        edpMile.FieldLabel = UGMM.LT("是否里程碑");
        edpMile.FieldLabelAlign = laLeft;
        edpMile.Align = alTop;
        edpMile.Margins.Left = 8;
        edpMile.Margins.Right = 8;
        edpMile.AlignWithMargins = True;
        
        var edpOpen = new TUgCheckBox(Result);
        edpOpen.Name = "edpOpen";
        edpOpen.Height = 22;
        edpOpen.Parent = Result;
        edpOpen.FieldLabel = UGMM.LT("是否展开");
        edpOpen.FieldLabelAlign = laLeft;
        edpOpen.Align = alTop;
        edpOpen.Margins.Left = 8;
        edpOpen.Margins.Right = 8;
        edpOpen.AlignWithMargins = true;
        
        var edpRes = new TUgComboBox(Result);
        edpRes.Name = "edpRes";
        edpRes.Height = 22;
        edpRes.Parent = Result;
        edpRes.FieldLabel = UGMM.LT("资源");
        edpRes.FieldLabelSeparator = "";
        edpRes.FieldLabelAlign = laLeft;
        edpRes.Align = alTop;
        edpRes.Margins.Left = 8;
        edpRes.Margins.Right = 8;
        edpRes.AlignWithMargins = True;
        edpRes.EmptyText = UGMM.LT("请选择...");
        edpRes.Items.CommaText  = "Roggie,Dean,Texta";
        edpRes.Style = csDropDownList;
        
        var edpComp = new TUgEdit(Result);
        edpComp.Name = "edpComp";
        edpComp.Height = 22;
        edpComp.Parent = Result;
        edpComp.FieldLabel = UGMM.LT("百分比%");
        edpComp.FieldLabelSeparator = "";
        edpComp.FieldLabelAlign = laLeft;
        edpComp.Align = alTop;
        edpComp.Margins.Left = 8;
        edpComp.Margins.Right = 8;
        edpComp.AlignWithMargins = true;
        edpComp.EmptyText = "";
      
        var edpGroup = new TUgComboBox(Result);
        edpGroup.Name = "edpGroup";
        edpGroup.Height = 22;
        edpGroup.Parent = Result;
        edpGroup.FieldLabel = UGMM.LT("是否组任务");
        edpGroup.FieldLabelSeparator = "";
        edpGroup.FieldLabelAlign = laLeft;
        edpGroup.Align = alTop;
        edpGroup.Margins.Left = 8;
        edpGroup.Margins.Right = 8;
        edpGroup.AlignWithMargins = true;
        edpGroup.EmptyText = UGMM.LT("请选择...");
        edpGroup.Items.CommaText = UGMM.LT("正常任务,标准组合任务,组合任务");
        edpGroup.ItemIndex = 0;
        edpGroup.Style = DropDownList;
      
        var edpParent = new TUgEdit(Result);
        edpParent.Name = "edpParent";
        edpParent.Height = 22;
        edpParent.Enabled = true;
        edpParent.Parent = Result;
        edpParent.FieldLabel = UGMM.LT("父任务ID");
        edpParent.FieldLabelSeparator = "";
        edpParent.FieldLabelAlign = laLeft;
        edpParent.Align = alTop;
        edpParent.Margins.Left = 8;
        edpParent.Margins.Right = 8;
        edpParent.AlignWithMargins = true;
        edpParent.EmptyText = UGMM.LT("请输入父任务ID");
        
        var edpDepend = new TUgEdit(Result);
        edpDepend.Name = "edpDepend";
        edpDepend.Height = 22;
        edpDepend.Enabled = true;
        edpDepend.Parent = Result;
        edpDepend.FieldLabel = UGMM.LT("依赖任务ID");
        edpDepend.FieldLabelSeparator = "";
        edpDepend.FieldLabelAlign = laLeft;
        edpDepend.Align = alTop;
        edpDepend.Margins.Left = 8;
        edpDepend.Margins.Right = 8;
        edpDepend.AlignWithMargins = true;
        edpDepend.EmptyText = UGMM.LT("请输入依赖任务ID");  
        
        var edpCaption = new TUgEdit(Result);
        edpCaption.Name = "edpCaption";
        edpCaption.Height = 22;
        edpCaption.Enabled = true;
        edpCaption.Parent = Result;
        edpCaption.FieldLabel = UGMM.LT("任务标题");
        edpCaption.FieldLabelSeparator = "";
        edpCaption.FieldLabelAlign = laLeft;
        edpCaption.Align = alTop;
        edpCaption.Margins.Left = 8;
        edpCaption.Margins.Right = 8;
        edpCaption.AlignWithMargins = true;
        edpCaption.EmptyText = "";  
        
        var edpNotes = new TUgEdit(Result);
        edpNotes.Name = "edpNotes";
        edpNotes.Height = 22;
        edpNotes.Enabled = true;
        edpNotes.Parent = Result;
        edpNotes.FieldLabel = UGMM.LT("详细说明");
        edpNotes.FieldLabelSeparator = "";
        edpNotes.FieldLabelAlign = laLeft;
        edpNotes.Align = alTop;
        edpNotes.Margins.Left = 8;
        edpNotes.Margins.Right = 8;
        edpNotes.AlignWithMargins = true;
        edpNotes.EmptyText = "";  
        
        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;  
      }
      
      1
      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
      156
      157
      158
      159
      160
      161
      162
      163
      164
      165
      166
      167
      168
      169
      170
      171
      172
      173
      174
      175
      176
      177
      178
      179
      180
      181
      182
      183
      184
      185
      186
      187
      188
      189
      190
      191
      192
      193
      194
      195
      196
      197
      198
      199
      200
      201
      202
      203
      204
      205
      206
      207
      208
      209
      210
      211
      212
      213
      214
      215
      216
      217
      218
      219
      220
      221
      222
      223
      224
      225
      226
      227
      //PasScript
      Function GetEditorForm:TUgWebForm;
      Var
        edpID:TUgNumberEdit;
        edpName:TUgEdit;
        edpStart:TUgDateTimePicker;
        edpEnd:TUgDateTimePicker;
        edpClass:TUgComboBox;
        edpLink:TUgEdit;
        edpMile:TUgCheckBox;
        edpRes:TUgComboBox;
        edpComp:TUgEdit;
        edpGroup:TUgComboBox;
        edpParent:TUgEdit;
        edpOpen:TUgCheckBox;
        edpDepend:TUgEdit;
        edpCaption:TUgEdit;
        edpNotes:TUgEdit;
        btOk:TUgButton;
      Begin
        Result := TUgWebForm.Create(UniApplication);
        Result.FreeOnClose := False;
        Result.Width := 400;
        Result.Height := 530;
        Result.Bordericons :=biSystemMenu;
        
        edpID:=TUgNumberEdit.Create(Result);
        edpID.Name := 'edpID';
        edpID.Height := 22;
        edpID.Enabled := true;
        edpID.Parent := Result;
        edpID.FieldLabel := UGMM.LT('任务ID');
        edpID.FieldLabelSeparator := '';
        edpID.FieldLabelAlign := laLeft;
        edpID.Align := alTop;
        edpID.Margins.Left := 8;
        edpID.Margins.Right := 8;
        edpID.AlignWithMargins := True;
        edpID.EmptyText:='pID';
        
        edpName:=TUgEdit.Create(Result);
        edpName.Name := 'edpName';
        edpName.Height := 22;
        edpName.Enabled := true;
        edpName.Parent := Result;
        edpName.FieldLabel := UGMM.LT('任务名称');
        edpName.FieldLabelSeparator := '';
        edpName.FieldLabelAlign := laLeft;
        edpName.Align := alTop;
        edpName.Margins.Left := 8;
        edpName.Margins.Right := 8;
        edpName.AlignWithMargins := True;
        edpName.EmptyText:= UGMM.LT('请输入任务名称');
        
        edpStart:=TUgDateTimePicker.Create(Result);
        edpStart.Name := 'edpStart';
        edpStart.Height := 22;
        edpStart.Parent := Result;
        edpStart.FieldLabel := UGMM.LT('任务开始日期');
        edpStart.FieldLabelSeparator := '';
        edpStart.FieldLabelAlign := laLeft;
        edpStart.Align := alTop;
        edpStart.Margins.Left := 8;
        edpStart.Margins.Right := 8;
        edpStart.AlignWithMargins := True;
        edpStart.DateTime := StrToDateTime(FormatdateTime('yyyy-mm-dd',now()) + ' 00:00:00');;
        edpStart.Kind := tUniDateTime; 
        
        edpEnd:=TUgDateTimePicker.Create(Result);
        edpEnd.Name := 'edpEnd';
        edpEnd.Height := 22;
        edpEnd.Parent := Result;
        edpEnd.FieldLabel := UGMM.LT('任务结束日期');
        edpEnd.FieldLabelSeparator := '';
        edpEnd.FieldLabelAlign := laLeft;
        edpEnd.Align := alTop;
        edpEnd.Margins.Left := 8;
        edpEnd.Margins.Right := 8;
        edpEnd.AlignWithMargins := True;
        edpEnd.DateTime := StrToDateTime(FormatdateTime('yyyy-mm-dd',now()) + ' 23:59:59');;
        edpEnd.Kind := tUniDateTime; 
        
        edpClass:=TUgComboBox.Create(Result);
        edpClass.Name := 'edpClass';
        edpClass.Height := 22;
        edpClass.Parent := Result;
        edpClass.FieldLabel := UGMM.LT('仪表样式');
        edpClass.FieldLabelSeparator := '';
        edpClass.FieldLabelAlign := laLeft;
        edpClass.Align := alTop;
        edpClass.Margins.Left := 8;
        edpClass.Margins.Right := 8;
        edpClass.AlignWithMargins := True;
        edpClass.EmptyText:= UGMM.LT('请选择...');
        edpClass.Items.CommaText := 'ggroupblack,gtaskblue,gtaskgreen,gtaskred,gtaskyellow,gtaskpurple,gtaskpink';
        edpClass.Style := csDropDownList;
        
        edpLink:=TUgEdit.Create(Result);
        edpLink.Name := 'edpLink';
        edpLink.Height := 22;
        edpLink.Enabled := true;
        edpLink.Parent := Result;
        edpLink.FieldLabel := UGMM.LT('任务链接');
        edpLink.FieldLabelSeparator := '';
        edpLink.FieldLabelAlign := laLeft;
        edpLink.Align := alTop;
        edpLink.Margins.Left := 8;
        edpLink.Margins.Right := 8;
        edpLink.AlignWithMargins := True;
        edpLink.EmptyText:= UGMM.LT('请输入任务链接');
        
        edpMile := TUgCheckBox.Create(Result);
        edpMile.Name := 'edpMile';
        edpMile.Height := 22;
        edpMile.Parent := Result;
        edpMile.FieldLabel := UGMM.LT('是否里程碑');
        edpMile.FieldLabelAlign := laLeft;
        edpMile.Align := alTop;
        edpMile.Margins.Left := 8;
        edpMile.Margins.Right := 8;
        edpMile.AlignWithMargins := True;
        
        edpOpen := TUgCheckBox.Create(Result);
        edpOpen.Name := 'edpOpen';
        edpOpen.Height := 22;
        edpOpen.Parent := Result;
        edpOpen.FieldLabel := UGMM.LT('是否展开');
        edpOpen.FieldLabelAlign := laLeft;
        edpOpen.Align := alTop;
        edpOpen.Margins.Left := 8;
        edpOpen.Margins.Right := 8;
        edpOpen.AlignWithMargins := True;
        
        
        edpRes:=TUgComboBox.Create(Result);
        edpRes.Name := 'edpRes';
        edpRes.Height := 22;
        edpRes.Parent := Result;
        edpRes.FieldLabel := UGMM.LT('资源');
        edpRes.FieldLabelSeparator := '';
        edpRes.FieldLabelAlign := laLeft;
        edpRes.Align := alTop;
        edpRes.Margins.Left := 8;
        edpRes.Margins.Right := 8;
        edpRes.AlignWithMargins := True;
        edpRes.EmptyText:= UGMM.LT('请选择...');
        edpRes.Items.CommaText := 'Roggie,Dean,Texta';
        edpRes.Style := csDropDownList;
        
        edpComp:=TUgEdit.Create(Result);
        edpComp.Name := 'edpComp';
        edpComp.Height := 22;
        edpComp.Parent := Result;
        edpComp.FieldLabel := UGMM.LT('百分比%');
        edpComp.FieldLabelSeparator := '';
        edpComp.FieldLabelAlign := laLeft;
        edpComp.Align := alTop;
        edpComp.Margins.Left := 8;
        edpComp.Margins.Right := 8;
        edpComp.AlignWithMargins := True;
        edpComp.EmptyText:='';
      
        edpGroup:=TUgComboBox.Create(Result);
        edpGroup.Name := 'edpGroup';
        edpGroup.Height := 22;
        edpGroup.Parent := Result;
        edpGroup.FieldLabel := UGMM.LT('是否组任务');
        edpGroup.FieldLabelSeparator := '';
        edpGroup.FieldLabelAlign := laLeft;
        edpGroup.Align := alTop;
        edpGroup.Margins.Left := 8;
        edpGroup.Margins.Right := 8;
        edpGroup.AlignWithMargins := True;
        edpGroup.EmptyText:= UGMM.LT('请选择...');
        edpGroup.Items.CommaText := UGMM.LT('正常任务,标准组合任务,组合任务');
        edpGroup.ItemIndex := 0;
        edpGroup.Style := csDropDownList;
      
        edpParent:=TUgEdit.Create(Result);
        edpParent.Name := 'edpParent';
        edpParent.Height := 22;
        edpParent.Enabled := true;
        edpParent.Parent := Result;
        edpParent.FieldLabel := UGMM.LT('父任务ID');
        edpParent.FieldLabelSeparator := '';
        edpParent.FieldLabelAlign := laLeft;
        edpParent.Align := alTop;
        edpParent.Margins.Left := 8;
        edpParent.Margins.Right := 8;
        edpParent.AlignWithMargins := True;
        edpParent.EmptyText:= UGMM.LT('请输入父任务ID');
        
        edpDepend:=TUgEdit.Create(Result);
        edpDepend.Name := 'edpDepend';
        edpDepend.Height := 22;
        edpDepend.Enabled := true;
        edpDepend.Parent := Result;
        edpDepend.FieldLabel := UGMM.LT('依赖任务ID');
        edpDepend.FieldLabelSeparator := '';
        edpDepend.FieldLabelAlign := laLeft;
        edpDepend.Align := alTop;
        edpDepend.Margins.Left := 8;
        edpDepend.Margins.Right := 8;
        edpDepend.AlignWithMargins := True;
        edpDepend.EmptyText:= UGMM.LT('请输入依赖任务ID');  
        
        edpCaption:=TUgEdit.Create(Result);
        edpCaption.Name := 'edpCaption';
        edpCaption.Height := 22;
        edpCaption.Enabled := true;
        edpCaption.Parent := Result;
        edpCaption.FieldLabel := UGMM.LT('任务标题');
        edpCaption.FieldLabelSeparator := '';
        edpCaption.FieldLabelAlign := laLeft;
        edpCaption.Align := alTop;
        edpCaption.Margins.Left := 8;
        edpCaption.Margins.Right := 8;
        edpCaption.AlignWithMargins := True;
        edpCaption.EmptyText:='';  
        
        edpNotes:=TUgEdit.Create(Result);
        edpNotes.Name := 'edpNotes';
        edpNotes.Height := 22;
        edpNotes.Enabled := true;
        edpNotes.Parent := Result;
        edpNotes.FieldLabel := UGMM.LT('详细说明');
        edpNotes.FieldLabelSeparator := '';
        edpNotes.FieldLabelAlign := laLeft;
        edpNotes.Align := alTop;
        edpNotes.Margins.Left := 8;
        edpNotes.Margins.Right := 8;
        edpNotes.AlignWithMargins := True;
        edpNotes.EmptyText:='';  
        
        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;
      
      1
      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
      156
      157
      158
      159
      160
      161
      162
      163
      164
      165
      166
      167
      168
      169
      170
      171
      172
      173
      174
      175
      176
      177
      178
      179
      180
      181
      182
      183
      184
      185
      186
      187
      188
      189
      190
      191
      192
      193
      194
      195
      196
      197
      198
      199
      200
      201
      202
      203
      204
      205
      206
      207
      208
      209
      210
      211
      212
      213
      214
      215
      216
      217
      218
      219
      220
      221
      222
      223
      224
      225
      226
      227
      228
      229
      230
      231
      232
      233
      234
      235
      236
      237
      238
      239
      240
      241
      242
      243
      244
      245
      246
      // Make sure to add code blocks to your code group

      # 3.2. 事件设置

      • 2:btnAddTask-OnClick事件

        点击以新增任务。

        //JScript
        function btnAddTaskOnClick(sender){
          var F = GetEditorForm();
          try{
          F.Caption = UGMM.LT("添加任务");
            var e ="";
            var b = true;
            While (b == true) {
            if (e != "") {
              MessageDlg(e,mtError,mbOK);
              }
              if (F.ShowModal == mrOK ){
              try{
              	if (TUgNumberEdit(F.FindComponent("edpID")).Value == 0) {
                    RaiseException(UGMM.LT("任务ID"));
                    }
                  //添加到内存表
                  cdsTask.Append;
                  var v = TUgNumberEdit(F.FindComponent("edpID")).Value;
                  cdsTask.FieldByName("pID").AsString = v;
                  cdsTask.FieldByName("pName").AsString   = TUgEdit(F.FindComponent("edpName")).Text;
                  cdsTask.FieldByName("pStart").AsDateTime  = TUgDateTimePicker(F.FindComponent("edpStart")).DateTime;
                  cdsTask.FieldByName("pEnd").AsDateTime    = TUgDateTimePicker(F.FindComponent("edpEnd")).DateTime;
                  cdsTask.FieldByName("pClass").AsString  = TUgComboBox(F.FindComponent("edpClass")).Text;
                  cdsTask.FieldByName("pLink").AsString   = TUgEdit(F.FindComponent("edpLink")).Text;
                  cdsTask.FieldByName("pMile").AsString   = IIF(TUgCheckBox(F.FindComponent("edpMile")).Checked,"1","0");
                  cdsTask.FieldByName("pRes").AsString    = TUgComboBox(F.FindComponent("edpRes")).Text;
                  cdsTask.FieldByName("pComp").AsString   = TUgEdit(F.FindComponent("edpComp")).Text;
                  cdsTask.FieldByName("pGroup").AsString  = IntToStr(TUgComboBox(F.FindComponent("edpGroup")).ItemIndex);
                  cdsTask.FieldByName("pParent").AsString = TUgEdit(F.FindComponent("edpParent")).Text;
                  cdsTask.FieldByName("pOpen").AsString   = IIF(TUgCheckBox(F.FindComponent("edpOpen")).Checked,"1","0");
                  cdsTask.FieldByName("pDepend").AsString = TUgEdit(F.FindComponent("edpDepend")).Text;
                  cdsTask.FieldByName("pCaption").AsString = TUgEdit(F.FindComponent("edpCaption")).Text;
                  cdsTask.FieldByName("pNotes").AsString  = TUgEdit(F.FindComponent("edpNotes")).Text;
                  cdsTask.Post;
                  
                  cdsTask.SubmitUpdates;
                  b = false;
                  }
                  Except{
                  	RaiseException(ExceptionMessage);
                  }
                }
                else{
                	b = false;
                }
              }
           }
           finally{
            F.Free;
            }
        }
        
        1
        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
        //PasScript
        procedure btnAddTaskOnClick(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('edpID')).Value = 0 then
                    RaiseException(UGMM.LT('任务ID'));
                  //添加到内存表
                  cdsTask.Append;
                  v := TUgNumberEdit(F.FindComponent('edpID')).Value;
                  cdsTask.FieldByName('pID').AsString := v;
                  cdsTask.FieldByName('pName').AsString   := TUgEdit(F.FindComponent('edpName')).Text;
                  cdsTask.FieldByName('pStart').AsDateTime  := TUgDateTimePicker(F.FindComponent('edpStart')).DateTime;
                  cdsTask.FieldByName('pEnd').AsDateTime    := TUgDateTimePicker(F.FindComponent('edpEnd')).DateTime;
                  cdsTask.FieldByName('pClass').AsString  := TUgComboBox(F.FindComponent('edpClass')).Text;
                  cdsTask.FieldByName('pLink').AsString   := TUgEdit(F.FindComponent('edpLink')).Text;
                  cdsTask.FieldByName('pMile').AsString   := IIF(TUgCheckBox(F.FindComponent('edpMile')).Checked,'1','0');
                  cdsTask.FieldByName('pRes').AsString    := TUgComboBox(F.FindComponent('edpRes')).Text;
                  cdsTask.FieldByName('pComp').AsString   := TUgEdit(F.FindComponent('edpComp')).Text;
                  cdsTask.FieldByName('pGroup').AsString  := IntToStr(TUgComboBox(F.FindComponent('edpGroup')).ItemIndex);
                  cdsTask.FieldByName('pParent').AsString := TUgEdit(F.FindComponent('edpParent')).Text;
                  cdsTask.FieldByName('pOpen').AsString   := IIF(TUgCheckBox(F.FindComponent('edpOpen')).Checked,'1','0');
                  cdsTask.FieldByName('pDepend').AsString := TUgEdit(F.FindComponent('edpDepend')).Text;
                  cdsTask.FieldByName('pCaption').AsString:= TUgEdit(F.FindComponent('edpCaption')).Text;
                  cdsTask.FieldByName('pNotes').AsString  := TUgEdit(F.FindComponent('edpNotes')).Text;
                  cdsTask.Post;
                  
                  cdsTask.SubmitUpdates;
                  b := False;
                Except{ExceptionMessage}
                  e:=ExceptionMessage;
                end;
              End else
                b:=False;
            End;
          Finally
            F.Free;
          end;
        end;
        
        1
        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
        // Make sure to add code blocks to your code group
        • 3:btnEditTask-OnClick事件

          点击以打开选择的任务进行编辑。

          //JScript
          function btnEditTaskOnClick(sender){
            var F = GetEditorForm();
            try{
              F.Caption = UGMM.LT("修改任务");
              var e = "";
              var b = true;
              TUgNumberEdit(F.FindComponent("edpID")).Value = cdsTask.FieldByName("pID").AsInteger;
              TUgEdit(F.FindComponent("edpName")).Text = cdsTask.FieldByName("pName").AsString;
              TUgDateTimePicker(F.FindComponent("edpStart")).DateTime = cdsTask.FieldByName("pStart").AsDateTime;
              TUgDateTimePicker(F.FindComponent("edpEnd")).DateTime = cdsTask.FieldByName("pEnd").AsDateTime;
              TUgComboBox(F.FindComponent("edpClass")).Text = cdsTask.FieldByName("pClass").AsString;
              TUgEdit(F.FindComponent("edpLink")).Text = cdsTask.FieldByName("pLink").AsString;
              TUgCheckBox(F.FindComponent("edpMile")).Checked = (cdsTask.FieldByName("pMile").AsInteger == 1);
              TUgComboBox(F.FindComponent("edpRes")).Text = cdsTask.FieldByName("pRes").AsString;
              TUgEdit(F.FindComponent("edpComp")).Text = cdsTask.FieldByName("pComp").AsString;
              TUgComboBox(F.FindComponent("edpGroup")).ItemIndex = cdsTask.FieldByName("pGroup").AsInteger;
              TUgEdit(F.FindComponent("edpParent")).Text = cdsTask.FieldByName("pParent").AsString;
              TUgCheckBox(F.FindComponent("edpOpen")).Checked = (cdsTask.FieldByName("pOpen").AsString == "1");
              TUgEdit(F.FindComponent("edpDepend")).Text = cdsTask.FieldByName("pDepend").AsString;
              TUgEdit(F.FindComponent("edpCaption")).Text = cdsTask.FieldByName("pCaption").AsString;
              TUgEdit(F.FindComponent("edpNotes")).Text = cdsTask.FieldByName("pNotes").AsString;
              While (b == true)
              {
              if (e != "") {
                MessageDlg(e,mtError,mbOK);
                }
                if (F.ShowModal == mrOK) { 
                	try{
                	if (TUgNumberEdit(F.FindComponent("edpID")).Value == 0){
                      RaiseException(UGMM.LT("任务ID"));
                      }
                    //添加到内存表
                    cdsTask.Edit;
                    v = TUgNumberEdit(F.FindComponent("edpID")).Value;
                    cdsTask.FieldByName("pID").AsString = v;
                    cdsTask.FieldByName("pName").AsString   = TUgEdit(F.FindComponent("edpName")).Text;
                    cdsTask.FieldByName("pStart").AsDateTime  = TUgDateTimePicker(F.FindComponent("edpStart")).DateTime;
                    cdsTask.FieldByName("pEnd").AsDateTime    = TUgDateTimePicker(F.FindComponent("edpEnd")).DateTime;
                    cdsTask.FieldByName("pClass").AsString  = TUgComboBox(F.FindComponent("edpClass")).Text;
                    cdsTask.FieldByName("pLink").AsString   = TUgEdit(F.FindComponent("edpLink")).Text;
                    cdsTask.FieldByName("pMile").AsString   = IIF(TUgCheckBox(F.FindComponent("edpMile")).Checked,"1","0");
                    cdsTask.FieldByName("pRes").AsString    = TUgComboBox(F.FindComponent("edpRes")).Text;
                    cdsTask.FieldByName("pComp").AsString   = TUgEdit(F.FindComponent("edpComp")).Text;
                    cdsTask.FieldByName("pGroup").AsString  = IntToStr(TUgComboBox(F.FindComponent("edpGroup")).ItemIndex);
                    cdsTask.FieldByName("pParent").AsString = TUgEdit(F.FindComponent("edpParent")).Text;
                    cdsTask.FieldByName("pOpen").AsString   = IIF(TUgCheckBox(F.FindComponent("edpOpen")).Checked,"1","0");
                    cdsTask.FieldByName("pDepend").AsString = TUgEdit(F.FindComponent("edpDepend")).Text;
                    cdsTask.FieldByName("pCaption").AsString= TUgEdit(F.FindComponent("edpCaption")).Text;
                    cdsTask.FieldByName("pNotes").AsString  = TUgEdit(F.FindComponent("edpNotes")).Text;
                    cdsTask.Post;
                    
                    cdsTask.SubmitUpdates;
                    b = false;
                    }
                    Except{
                      RaiseException(ExceptionMessage);
                    	}
                    }
                  else{
                  	b = false;
                  }
                }
             }
             finally{
              F.Free;
              }
          }
          
          1
          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
          //PasScript
          procedure btnEditTaskOnClick(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('edpID')).Value := cdsTask.FieldByName('pID').AsInteger;
              TUgEdit(F.FindComponent('edpName')).Text := cdsTask.FieldByName('pName').AsString;
              TUgDateTimePicker(F.FindComponent('edpStart')).DateTime := cdsTask.FieldByName('pStart').AsDateTime;
              TUgDateTimePicker(F.FindComponent('edpEnd')).DateTime := cdsTask.FieldByName('pEnd').AsDateTime;
              TUgComboBox(F.FindComponent('edpClass')).Text := cdsTask.FieldByName('pClass').AsString;
              TUgEdit(F.FindComponent('edpLink')).Text := cdsTask.FieldByName('pLink').AsString;
              TUgCheckBox(F.FindComponent('edpMile')).Checked := (cdsTask.FieldByName('pMile').AsInteger = 1);
              TUgComboBox(F.FindComponent('edpRes')).Text := cdsTask.FieldByName('pRes').AsString;
              TUgEdit(F.FindComponent('edpComp')).Text := cdsTask.FieldByName('pComp').AsString;
              TUgComboBox(F.FindComponent('edpGroup')).ItemIndex := cdsTask.FieldByName('pGroup').AsInteger;
              TUgEdit(F.FindComponent('edpParent')).Text := cdsTask.FieldByName('pParent').AsString;
              TUgCheckBox(F.FindComponent('edpOpen')).Checked := cdsTask.FieldByName('pOpen').AsString = '1';
              TUgEdit(F.FindComponent('edpDepend')).Text := cdsTask.FieldByName('pDepend').AsString;
              TUgEdit(F.FindComponent('edpCaption')).Text := cdsTask.FieldByName('pCaption').AsString;
              TUgEdit(F.FindComponent('edpNotes')).Text := cdsTask.FieldByName('pNotes').AsString;
              While b do
              Begin
                if e<>'' then
                MessageDlg(e,mtError,mbOK);
                if F.ShowModal = mrOK then 
                Begin
                  Try
                    if TUgNumberEdit(F.FindComponent('edpID')).Value = 0 then
                      RaiseException(UGMM.LT('任务ID'));
                    //添加到内存表
                    cdsTask.Edit;
                    v := TUgNumberEdit(F.FindComponent('edpID')).Value;
                    cdsTask.FieldByName('pID').AsString := v;
                    cdsTask.FieldByName('pName').AsString   := TUgEdit(F.FindComponent('edpName')).Text;
                    cdsTask.FieldByName('pStart').AsDateTime  := TUgDateTimePicker(F.FindComponent('edpStart')).DateTime;
                    cdsTask.FieldByName('pEnd').AsDateTime    := TUgDateTimePicker(F.FindComponent('edpEnd')).DateTime;
                    cdsTask.FieldByName('pClass').AsString  := TUgComboBox(F.FindComponent('edpClass')).Text;
                    cdsTask.FieldByName('pLink').AsString   := TUgEdit(F.FindComponent('edpLink')).Text;
                    cdsTask.FieldByName('pMile').AsString   := IIF(TUgCheckBox(F.FindComponent('edpMile')).Checked,'1','0');
                    cdsTask.FieldByName('pRes').AsString    := TUgComboBox(F.FindComponent('edpRes')).Text;
                    cdsTask.FieldByName('pComp').AsString   := TUgEdit(F.FindComponent('edpComp')).Text;
                    cdsTask.FieldByName('pGroup').AsString  := IntToStr(TUgComboBox(F.FindComponent('edpGroup')).ItemIndex);
                    cdsTask.FieldByName('pParent').AsString := TUgEdit(F.FindComponent('edpParent')).Text;
                    cdsTask.FieldByName('pOpen').AsString   := IIF(TUgCheckBox(F.FindComponent('edpOpen')).Checked,'1','0');
                    cdsTask.FieldByName('pDepend').AsString := TUgEdit(F.FindComponent('edpDepend')).Text;
                    cdsTask.FieldByName('pCaption').AsString:= TUgEdit(F.FindComponent('edpCaption')).Text;
                    cdsTask.FieldByName('pNotes').AsString  := TUgEdit(F.FindComponent('edpNotes')).Text;
                    cdsTask.Post;
                    
                    cdsTask.SubmitUpdates;
                    b := False;
                  Except{ExceptionMessage}
                    e:=ExceptionMessage;
                  end;
                End else
                  b:=False;
              End;
            Finally
              F.Free;
            end;
          end;
          
          1
          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
          // Make sure to add code blocks to your code group
          • 4:btnDelTask-OnClick事件

            点击按钮后,选择的任务项将被删除。

            //JScript
            function btnDelTaskOnClick(sender){
            	if (cdsTask.IsEmpty){  
              	RaiseException(UGMM.LT("没有记录无法删除"));
              }
              
              if (MessageDlg(UGMM.LT("注意:是否删除该笔任务?"),mtWarning,mbYes + mbNo) == mrYes){
                 cdsTask.Delete;
                 cdsTask.SubmitUpdates;
              }
            }
            
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            //PasScript
            procedure btnDelTaskOnClick(sender: tobject);
            begin
              if cdsTask.IsEmpty then
              RaiseException(UGMM.LT('没有记录无法删除'));
              
              if MessageDlg(UGMM.LT('注意:是否删除该笔任务?'),mtWarning,mbYes + mbNo) = mrYes then
              Begin
                 cdsTask.Delete;
                 cdsTask.SubmitUpdates;
              end;
            end;
            
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            // Make sure to add code blocks to your code group
            • 5:btnCreateGantt-OnClick事件

              点击按钮后,生成甘特图。

              //JScript
              function btnCreateGanttOnClick(sender){
                UgGanttChart01.ClearTasks;
                UgGanttChart01.Draw;
                var TaskItem = new TTaskItem();
                cdsTask.First;
                While (!(cdsTask.Eof)){
                   TaskItem.pID = cdsTask.FieldByName("pID").AsString;
                   TaskItem.pName = cdsTask.FieldByName("pName").AsString;
                   TaskItem.pStart = cdsTask.FieldByName("pStart").AsString;
                   TaskItem.pEnd = cdsTask.FieldByName("pEnd").AsString;
                   TaskItem.pClass= cdsTask.FieldByName("pClass").AsString;
                   TaskItem.pLink = cdsTask.FieldByName("pLink").AsString;
                   TaskItem.pMile = cdsTask.FieldByName("pMile").AsString;
                   TaskItem.pRes = cdsTask.FieldByName("pRes").AsString;
                   TaskItem.pComp= cdsTask.FieldByName("pComp").AsString;
                   TaskItem.pGroup = cdsTask.FieldByName("pGroup").AsString;
                   TaskItem.pParent = cdsTask.FieldByName("pParent").AsString;
                   TaskItem.pOpen = cdsTask.FieldByName("pOpen").AsString;
                   TaskItem.pDepend = cdsTask.FieldByName("pDepend").AsString;
                   TaskItem.pCaption = cdsTask.FieldByName("pCaption").AsString;
                   TaskItem.pNotes = cdsTask.FieldByName("pNotes").AsString;
                   
                   UgGanttChart01.AddTaskItemObject(TaskItem);
                   cdsTask.Next;
                 }
                
                UgGanttChart01.Draw;
                
                UgPageControl01.TabIndex = 1;
                TaskItem.Free;
              }
              
              1
              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
              //PasScript
              procedure btnCreateGanttOnClick(sender: tobject);
              Var
                TaskItem:TTaskItem;
              begin
                UgGanttChart01.ClearTasks;
                UgGanttChart01.Draw;
                TaskItem := TTaskItem.Create;
                cdsTask.First;
                While not cdsTask.Eof Do
                Begin
                   TaskItem.pID := cdsTask.FieldByName('pID').AsString;
                   TaskItem.pName := cdsTask.FieldByName('pName').AsString;
                   TaskItem.pStart := cdsTask.FieldByName('pStart').AsString;
                   TaskItem.pEnd := cdsTask.FieldByName('pEnd').AsString;
                   TaskItem.pClass:= cdsTask.FieldByName('pClass').AsString;
                   TaskItem.pLink := cdsTask.FieldByName('pLink').AsString;
                   TaskItem.pMile := cdsTask.FieldByName('pMile').AsString;
                   TaskItem.pRes := cdsTask.FieldByName('pRes').AsString;
                   TaskItem.pComp:= cdsTask.FieldByName('pComp').AsString;
                   TaskItem.pGroup := cdsTask.FieldByName('pGroup').AsString;
                   TaskItem.pParent := cdsTask.FieldByName('pParent').AsString;
                   TaskItem.pOpen := cdsTask.FieldByName('pOpen').AsString;
                   TaskItem.pDepend := cdsTask.FieldByName('pDepend').AsString;
                   TaskItem.pCaption := cdsTask.FieldByName('pCaption').AsString;
                   TaskItem.pNotes := cdsTask.FieldByName('pNotes').AsString;
                   
                   UgGanttChart01.AddTaskItemObject(TaskItem);
                   cdsTask.Next;
                end;
                
                UgGanttChart01.Draw;
                
                UgPageControl01.TabIndex := 1;
              end;
              
              1
              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
              // Make sure to add code blocks to your code group

              # 4. 运行结果

                使用鼠标在FastWeb菜单,点击[保存至数据库]按钮,将其保存至数据库,点击[调试运行]确认能够正常打开。

                可在任务界面进行任务的新增、编辑以及删除操作,点击生成甘特图按钮可切换至甘特图标签页,并根据标签页中的内容显示甘特图。

              Google图表(WEB)
              商务月历(WEB)

              ← Google图表(WEB) 商务月历(WEB)→

              Copyright © 2021-2025 爱招飞IsoFace | ALL Rights Reserved
              • 跟随系统
              • 浅色模式
              • 深色模式
              • 阅读模式