汇总GroupFooter1数据中的GroupFooter2数据

时间:2016-11-16 13:40:12

标签: delphi fastreport

有没有办法在FastReports 5 Embarcadero Edition中汇总另一组的页脚区域中的数据?

我有一个FastReport,显示每月的每周时间表。 MasterBand1中显示每日进出时间和已用时间。时间,可计时小时和直线时间的计算在GroupFooter1的每周摘要中。我还需要在GroupFooter2中总结本月的这些信息。

时钟是员工实际工作的时间。生病,个人和休假时间都不包括在内。总时数包括可闹钟和非时钟。

加班时间计算为一周内超过40小时的可计时小时数。我可以使用变量来计算(每周)GroupFooter1库中的每一个。为了使加班和直接时间的月总数准确,我必须从每周波段而不是主数据波段累计直线和随时间变化。由于FastReports Embarcadero Edition不包含脚本,我不知道如何使用变量来做到这一点。我能想到的唯一选择是在"月"中创建计算字段。每个员工的数据集,并将该数据集链接到GroupFooter2。然而,通过呈现来自两个不同来源的数据,可以产生错误的可能性。有没有办法在FastReports中执行此操作?

以下是表单的.pas。

unit YTDPayRpt;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf, FireDAC.Stan.Def,
  FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.Phys.FB,
  FireDAC.Phys.FBDef, FireDAC.VCLUI.Wait, FireDAC.Stan.Param, FireDAC.DatS,
  FireDAC.DApt.Intf, FireDAC.DApt, Vcl.StdCtrls, frxClass, frxDBSet, Data.DB,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client, FireDAC.Comp.UI, frxChBox;

type
  TForm2 = class(TForm)
    Connection: TFDConnection;
    WaitCursor: TFDGUIxWaitCursor;
    WorkshiftDataset: TFDTable;
    Report: TfrxReport;
    frxDBDataset1: TfrxDBDataset;
    Button1: TButton;
    frxCheckBoxObject1: TfrxCheckBoxObject;
    WorkshiftDatasetID: TLargeintField;
    WorkshiftDatasetEMPLOYEEID: TLargeintField;
    WorkshiftDatasetJOBCODE: TSmallintField;
    WorkshiftDatasetCLOCKABLE: TBooleanField;
    WorkshiftDatasetDAYOFWEEK: TStringField;
    WorkshiftDatasetDATEIN: TDateField;
    WorkshiftDatasetTIMEIN: TTimeField;
    WorkshiftDatasetDATEOUT: TDateField;
    WorkshiftDatasetTIMEOUT: TTimeField;
    WorkshiftDatasetNOTE: TMemoField;
    WorkshiftDatasetTIMEELAPSED: TFMTBCDField;
    WorkshiftDatasetWEEKOF: TDateField;
    WorkshiftDatasetROWNBR: TSmallintField;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
  Report.ShowReport();
end;

end.

以下是包含报告所需组件的表单的文本文件。

object Form2: TForm2
  Left = 0
  Top = 0
  Caption = 'Form2'
  ClientHeight = 211
  ClientWidth = 418
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 184
    Top = 112
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Connection: TFDConnection
    Params.Strings = (
      'ConnectionDef=Timedata - Local')
    Connected = True
    LoginPrompt = False
    Left = 96
    Top = 24
  end
  object WaitCursor: TFDGUIxWaitCursor
    Provider = 'Forms'
    Left = 208
    Top = 24
  end
  object WorkshiftDataset: TFDTable
    Active = True
    IndexFieldNames = 'ID;DATEIN;ROWNBR'
    Connection = Connection
    UpdateOptions.UpdateTableName = 'V_WORKSHIFT'
    TableName = 'V_WORKSHIFT'
    Left = 288
    Top = 32
    object WorkshiftDatasetID: TLargeintField
      FieldName = 'ID'
      Origin = 'ID'
    end
    object WorkshiftDatasetEMPLOYEEID: TLargeintField
      FieldName = 'EMPLOYEEID'
      Origin = 'EMPLOYEEID'
    end
    object WorkshiftDatasetJOBCODE: TSmallintField
      FieldName = 'JOBCODE'
      Origin = 'JOBCODE'
    end
    object WorkshiftDatasetCLOCKABLE: TBooleanField
      FieldName = 'CLOCKABLE'
      Origin = 'CLOCKABLE'
    end
    object WorkshiftDatasetDAYOFWEEK: TStringField
      FieldName = 'DAYOFWEEK'
      Origin = 'DAYOFWEEK'
      Size = 10
    end
    object WorkshiftDatasetDATEIN: TDateField
      FieldName = 'DATEIN'
      Origin = 'DATEIN'
    end
    object WorkshiftDatasetTIMEIN: TTimeField
      FieldName = 'TIMEIN'
      Origin = 'TIMEIN'
    end
    object WorkshiftDatasetDATEOUT: TDateField
      FieldName = 'DATEOUT'
      Origin = 'DATEOUT'
    end
    object WorkshiftDatasetTIMEOUT: TTimeField
      FieldName = 'TIMEOUT'
      Origin = 'TIMEOUT'
    end
    object WorkshiftDatasetNOTE: TMemoField
      FieldName = 'NOTE'
      Origin = 'NOTE'
      BlobType = ftMemo
    end
    object WorkshiftDatasetTIMEELAPSED: TFMTBCDField
      FieldName = 'TIMEELAPSED'
      Origin = 'TIMEELAPSED'
      Precision = 18
      Size = 9
    end
    object WorkshiftDatasetWEEKOF: TDateField
      FieldName = 'WEEKOF'
      Origin = 'WEEKOF'
    end
    object WorkshiftDatasetROWNBR: TSmallintField
      FieldName = 'ROWNBR'
      Origin = 'ROWNBR'
    end
  end
  object Report: TfrxReport
    Version = '5.3.14'
    DotMatrixReport = False
    IniFile = '\Software\Fast Reports'
    PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick]
    PreviewOptions.Zoom = 1.000000000000000000
    PrintOptions.Printer = 'Default'
    PrintOptions.PrintOnSheet = 0
    ReportOptions.CreateDate = 42689.921906956000000000
    ReportOptions.LastChange = 42689.930818541700000000
    ScriptLanguage = 'PascalScript'
    ScriptText.Strings = (
      ''
      'begin'
      ''
      'end.')
    Left = 56
    Top = 103
    Datasets = <
      item
        DataSet = frxDBDataset1
        DataSetName = 'frxDBDataset1'
      end>
    Variables = <
      item
        Name = ' Workshift'
        Value = Null
      end
      item
        Name = 'ClockableTime'
        Value = 
          'iif(<frxDBDataset1."CLOCKABLE"> = true, <frxDBDataset1."TIMEELAP' +
          'SED"> * 24, 0)'
      end
      item
        Name = 'WeeklyTimeElapsed'
        Value = 'SUM(<frxDBDataset1."TIMEELAPSED"> * 24,MasterData1)'
      end
      item
        Name = 'WeeklyClockableTime'
        Value = 'sum(<ClockableTime>)'
      end
      item
        Name = 'WeeklyStraightTime'
        Value = '<WeeklyTimeElapsed> - <WeeklyOvertime>'
      end
      item
        Name = 'WeeklyOvertime'
        Value = 'iif(<WeeklyClockableTime> > 40, <WeeklyTimeElapsed> - 40, 0)'
      end
      item
        Name = 'EmployeeTimeElapsed'
        Value = 'sum(<frxDBDataset1."TIMEELAPSED">, MasterData1)'
      end>
    Style = <>
    object Data: TfrxDataPage
      Height = 1000.000000000000000000
      Width = 1000.000000000000000000
    end
    object Page1: TfrxReportPage
      PaperWidth = 215.900000000000000000
      PaperHeight = 279.400000000000000000
      PaperSize = 1
      LeftMargin = 10.000000000000000000
      RightMargin = 10.000000000000000000
      TopMargin = 10.000000000000000000
      BottomMargin = 10.000000000000000000
      object MasterData1: TfrxMasterData
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 201.600000000000000000
        Width = 740.409927000000000000
        DataSet = frxDBDataset1
        DataSetName = 'frxDBDataset1'
        RowCount = 0
        object frxDBDataset1JOBCODE: TfrxMemoView
          Left = 172.800000000000000000
          Width = 124.800000000000000000
          Height = 19.200000000000000000
          DataField = 'JOBCODE'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            '[frxDBDataset1."JOBCODE"]')
        end
        object frxDBDataset1DATEIN: TfrxMemoView
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DataField = 'DATEIN'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            '[frxDBDataset1."DATEIN"]')
        end
        object frxDBDataset1DAYOFWEEK: TfrxMemoView
          Left = 86.400000000000000000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DataField = 'DAYOFWEEK'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            '[frxDBDataset1."DAYOFWEEK"]')
        end
        object frxDBDataset1TIMEIN: TfrxMemoView
          Left = 307.200000000000000000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DataField = 'TIMEIN'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            '[frxDBDataset1."TIMEIN"]')
        end
        object frxDBDataset1TIMEOUT: TfrxMemoView
          Left = 393.600000000000000000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DataField = 'TIMEOUT'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            '[frxDBDataset1."TIMEOUT"]')
        end
        object frxDBDataset1TIMEELAPSED: TfrxMemoView
          Left = 480.000000000000000000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clBlack
          Font.Height = -13
          Font.Name = 'Arial'
          Font.Style = []
          HAlign = haRight
          Memo.UTF8W = (
            '[<frxDBDataset1."TIMEELAPSED"> * 24]')
          ParentFont = False
        end
        object Memo3: TfrxMemoView
          Left = 566.400000000000000000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clBlack
          Font.Height = -13
          Font.Name = 'Arial'
          Font.Style = []
          HAlign = haRight
          Memo.UTF8W = (
            '[ClockableTime]')
          ParentFont = False
        end
        object CheckBox1: TfrxCheckBoxView
          Left = 662.400000000000000000
          Width = 18.897650000000000000
          Height = 18.897650000000000000
          CheckColor = clBlack
          CheckStyle = csCheck
          DataField = 'CLOCKABLE'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
        end
      end
      object PageFooter1: TfrxPageFooter
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 441.600000000000000000
        Width = 740.409927000000000000
        object Memo1: TfrxMemoView
          Left = 665.197280000000000000
          Width = 75.590600000000000000
          Height = 18.897650000000000000
          HAlign = haRight
          Memo.UTF8W = (
            '[Page#]')
        end
      end
      object PageHeader1: TfrxPageHeader
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 19.200000000000000000
        Width = 740.409927000000000000
      end
      object ReportSummary1: TfrxReportSummary
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 393.600000000000000000
        Width = 740.409927000000000000
      end
      object GroupHeader1: TfrxGroupHeader
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 105.600000000000000000
        Width = 740.409927000000000000
        Condition = 'frxDBDataset1."EMPLOYEEID"'
        StartNewPage = True
        object frxDBDataset1EMPLOYEEID: TfrxMemoView
          Width = 115.200000000000000000
          Height = 19.200000000000000000
          DataField = 'EMPLOYEEID'
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            '[frxDBDataset1."EMPLOYEEID"]')
        end
      end
      object GroupFooter1: TfrxGroupFooter
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 307.200000000000000000
        Width = 740.409927000000000000
        object Memo7: TfrxMemoView
          Left = 460.800000000000000000
          Top = 9.600000000000023000
          Width = 96.000000000000000000
          Height = 19.200000000000000000
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clBlack
          Font.Height = -13
          Font.Name = 'Arial'
          Font.Style = []
          HAlign = haRight
          Memo.UTF8W = (
            '[SUM(<frxDBDataset1."TIMEELAPSED"> * 24,MasterData1)]')
          ParentFont = False
        end
      end
      object GroupHeader2: TfrxGroupHeader
        FillType = ftBrush
        Height = 28.800000000000000000
        Top = 153.600000000000000000
        Width = 740.409927000000000000
        Condition = 'frxDBDataset1."WEEKOF"'
        object frxDBDataset1WEEKOF: TfrxMemoView
          Width = 105.600000000000000000
          Height = 19.200000000000000000
          DataSet = frxDBDataset1
          DataSetName = 'frxDBDataset1'
          Memo.UTF8W = (
            'w/o [frxDBDataset1."WEEKOF"]')
        end
      end
      object GroupFooter2: TfrxGroupFooter
        FillType = ftBrush
        Height = 38.400000000000000000
        Top = 249.600000000000000000
        Width = 740.409927000000000000
        object Memo2: TfrxMemoView
          Left = 480.000000000000000000
          Top = 9.599999999999995000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clBlack
          Font.Height = -13
          Font.Name = 'Arial'
          Font.Style = []
          HAlign = haRight
          Memo.UTF8W = (
            '[WeeklyTimeElapsed]')
          ParentFont = False
        end
        object Memo4: TfrxMemoView
          Left = 566.400000000000000000
          Top = 9.599999999999995000
          Width = 76.800000000000000000
          Height = 19.200000000000000000
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clBlack
          Font.Height = -13
          Font.Name = 'Arial'
          Font.Style = []
          HAlign = haRight
          Memo.UTF8W = (
            '[WeeklyClockableTime]')
          ParentFont = False
        end
        object Memo5: TfrxMemoView
          Left = 9.600000000000000000
          Top = 9.599999999999995000
          Width = 201.600000000000000000
          Height = 19.200000000000000000
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Memo.UTF8W = (
            'Straight Time:  [WeeklyStraightTime]')
        end
        object Memo6: TfrxMemoView
          Left = 220.800000000000000000
          Top = 9.599999999999995000
          Width = 172.800000000000000000
          Height = 19.200000000000000000
          DisplayFormat.FormatStr = '%2.2n'
          DisplayFormat.Kind = fkNumeric
          Memo.UTF8W = (
            'Overtime hours:  [WeeklyOvertime]')
        end
      end
    end
  end
  object frxDBDataset1: TfrxDBDataset
    UserName = 'frxDBDataset1'
    CloseDataSource = False
    DataSet = WorkshiftDataset
    BCDToCurrency = False
    Left = 360
    Top = 32
  end
  object frxCheckBoxObject1: TfrxCheckBoxObject
    Left = 112
    Top = 112
  end
end

1 个答案:

答案 0 :(得分:0)

尝试使用

SUM(iif(<frxDBDataset1."CLOCKABLE"> = true, <frxDBDataset1."TIMEELAP' +
          'SED"> * 24, 0), MasterData1)
在GroupFooter2上的TfrxMemoView中的

表达式