123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- unit rpgGatherControl;
- interface
- uses
- Classes, rpgGatherData, ADODB, ReportManager;
- type
- TrpgGatherControl = class
- private
- // 当前打开项目,根据其筛选项目
- FProjectID: Integer;
- // 当前汇总的报表 -- 主要用于读取报表中的附加信息
- FTemplate: TTemplateNode;
- FHistroyProjs: TList;
- // 选择的汇总项目
- FSelectProjs: TList;
- // 汇总数据
- FGatherData: TrpgGatherData;
- function SelectProject: Boolean;
- function SameSelect: Boolean;
- procedure RefreshGather;
- public
- constructor Create(AProjectID: Integer);
- destructor Destroy; override;
- function RefreshConnection(ATemplate: TTemplateNode): TADOConnection;
- end;
- implementation
- uses
- ZhAPI, GatherProjInfo, ProjGather, ProjGatherSelectFrm, Globals, Forms,
- Controls;
- { TrpgGatherControl }
- constructor TrpgGatherControl.Create(AProjectID: Integer);
- begin
- FProjectID := AProjectID;
- FHistroyProjs := TList.Create;
- FSelectProjs := TList.Create;
- FGatherData := TrpgGatherData.Create;
- end;
- destructor TrpgGatherControl.Destroy;
- begin
- FGatherData.Free;
- FSelectProjs.Free;
- ClearObjects(FHistroyProjs);
- FHistroyProjs.Free;
- inherited;
- end;
- function TrpgGatherControl.RefreshConnection(ATemplate: TTemplateNode): TADOConnection;
- begin
- FTemplate := ATemplate;
- if SelectProject then
- begin
- if not SameSelect then
- RefreshGather
- else if Assigned(ATemplate.InteractInfo) then
- FGatherData.UpdateDataBase(ATemplate.InteractInfo.SpecialProjGatherTypes);
- end;
- Result := FGatherData.Connection;
- end;
- procedure TrpgGatherControl.RefreshGather;
- var
- Gather: TProjGather;
- begin
- Screen.Cursor := crHourGlass;
- Gather := TProjGather.Create(FGatherData.WriteGatherData,
- ReportConfig.XmjCompare, ReportConfig.GclCompare);
- try
- if Assigned(FTemplate.InteractInfo) then
- Gather.Gather(FSelectProjs, FTemplate.InteractInfo.SpecialProjGatherTypes)
- else
- Gather.Gather(FSelectProjs, nil);
- FGatherData.LoadRelaData(FProjectID);
- ClearObjects(FHistroyProjs);
- FHistroyProjs.Assign(FSelectProjs);
- finally
- Gather.Free;
- Screen.Cursor := crDefault;
- end;
- end;
- function TrpgGatherControl.SameSelect: Boolean;
- function IncludeProj(AList: TList; AProj: TGatherProjInfo): Boolean;
- var
- i: Integer;
- vProj: TGatherProjInfo;
- begin
- Result := False;
- for i := 0 to AList.Count - 1 do
- begin
- vProj := TGatherProjInfo(AList.Items[i]);
- if (AProj.ProjectID = vProj.ProjectID) and (AProj.ProjType = vProj.ProjType) then
- begin
- Result := True;
- Break;
- end;
- end;
- end;
- function IncludeList(ALarge, ASmall: TList): Boolean;
- var
- iSmall: Integer;
- begin
- Result := True;
- for iSmall := 0 to ASmall.Count - 1 do
- begin
- if not IncludeProj(ALarge, TGatherProjInfo(ASmall.Items[iSmall])) then
- begin
- Result := False;
- Break;
- end;
- end;
- end;
- begin
- if FHistroyProjs.Count = FSelectProjs.Count then
- Result := IncludeList(FHistroyProjs, FSelectProjs) and IncludeList(FSelectProjs, FHistroyProjs)
- else
- Result := False;
- end;
- function TrpgGatherControl.SelectProject: Boolean;
- begin
- if FTemplate.IsExtra then
- Result := SelectGatherProject(FProjectID, FHistroyProjs, FSelectProjs, FTemplate.InteractInfo.SpecialProjGatherTypes)
- else
- Result := SelectGatherProject(FProjectID, FHistroyProjs, FSelectProjs);
- end;
- end.
|