用窗体的“决策数据集控件”是可以的,代码如下:
procedure TMainGLFZZDYBB.Button2Click(Sender: TObject);
var
ddd: TDecisionDimensionDef;
dsd: TDecisionSummaryDef;
begin
DataSetJCSJJ2.Close();
DataSetJCSJJ2.DecisionDef.DimensionDefs.Clear();
ddd:=DataSetJCSJJ2.DecisionDef.DimensionDefs.Add;
ddd.FieldName:= 'ccus_id';
ddd.TableName:= 'VIEW_das';
ddd.FieldType:= TFieldType.ftString;
ddd.DisplayName:='客户编码';
ddd.IsPrimaryKey := False;
ddd.IsAgg := False;
ddd.DimType :=TDecisionDimType.dtDataDim;
ddd.DimStyleDefType :=TDecisionDimstyleDefType.dfColDim;
ddd.DimIndexDef := 0;
ddd.ShowSubTotal := False;
ddd.CustomDim.FieldType :=TCustomDimType.cdtString;
ddd.BinType := TBinType.binNone;
ddd:=DataSetJCSJJ2.DecisionDef.DimensionDefs.Add;
ddd.FieldName:= 'Periodid';
ddd.TableName:= 'VIEW_das';
ddd.FieldType:=TFieldType.ftString;
ddd.DisplayName:='期间';
ddd.IsPrimaryKey := False;
ddd.IsAgg := False;
ddd.DimType :=TDecisionDimType.dtDataDim;
ddd.DimStyleDefType := TDecisionDimstyleDefType.dfColDim;
ddd.DimIndexDef := 0;
ddd.ShowSubTotal := False;
ddd.CustomDim.FieldType := TCustomDimType.cdtString;
ddd.BinType := TBinType.binNone;
DataSetJCSJJ2.DecisionDef.SummaryDefs.Clear();
dsd:=DataSetJCSJJ2.DecisionDef.SummaryDefs.Add();
dsd.FieldName := 'SUM(VIEW_das.md_f)';
dsd.TableName := 'VIEW_das';
dsd.FieldType := TFieldType.ftString;
dsd.DisplayName :='aaaaasfsaf';
dsd.Origin := 'md_f';
dsd.IsPrimaryKey := False;
dsd.IsAgg := True ;
dsd.SummType := TdecisionSummtype.dtAggSumm;
dsd.SummFlags := TSummFlags.sfSum;
DataSetJCSJJ2.Database.URL:= 'Biz:\ZWXT\financeSys.Database';
DataSetJCSJJ2.SQL.Text:='SELECT VIEW_das.ccus_id AS "客户编码", VIEW_das.Periodid AS "会计期间", SUM(VIEW_das.md_f) AS "合计_分录借方" FROM VIEW_das WHERE VIEW_das.ino_id = ''0'' GROUP BY VIEW_das.ccus_id, VIEW_das.Periodid ORDER BY VIEW_das.ccus_id, VIEW_das.Periodidne';
DataSetJCSJJ2.DecisionDef.ShowFieldName := False;
DataSetJCSJJ2.DecisionDef.SummAreaWidth := 1;
DataSetJCSJJ2.DecisionDef.SummAreaHeight := 1;
DataSetJCSJJ2.DecisionDef.MaxDims := 5;
DataSetJCSJJ2.DecisionDef.MaxSums := 10;
DataSetJCSJJ2.DecisionDef.MaxCells := 0;
DataSetJCSJJ2.DecisionDef.DecisionType := TDecisionType.dctStatistics;
DataSetJCSJJ2.DecisionDef.DatabaseURL := 'Biz:\ZWXT\financeSys.Database';
DataSetJCSJJ2.DecisionDef.OriginalSQL.Text := 'SELECT * FROM VIEW_das WHERE VIEW_das.ino_id = ''0''';
DataSetJCSJJ2.Open();
end; |