rpgGatherProjDm.pas 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. unit rpgGatherProjDm;
  2. interface
  3. uses
  4. SysUtils, Classes, sdProvider, sdDB, GatherProjInfo, ADODB;
  5. type
  6. TrpgGatherProjData = class(TDataModule)
  7. sdpGatherProj: TsdADOProvider;
  8. sddGatherProj: TsdDataSet;
  9. private
  10. procedure SaveGatherInfo(AProjs: TList);
  11. public
  12. constructor Create(AConnection: TADOConnection);
  13. procedure SaveDataTo(AProjs, ASProjs: TList; const ATableName: string);
  14. end;
  15. implementation
  16. {$R *.dfm}
  17. { TrpgGatherProjData }
  18. constructor TrpgGatherProjData.Create(AConnection: TADOConnection);
  19. begin
  20. inherited Create(nil);
  21. sdpGatherProj.Connection := AConnection;
  22. end;
  23. procedure TrpgGatherProjData.SaveDataTo(AProjs, ASProjs: TList; const ATableName: string);
  24. begin
  25. sdpGatherProj.TableName := ATableName;
  26. sddGatherProj.Open;
  27. sddGatherProj.BeginUpdate;
  28. try
  29. SaveGatherInfo(AProjs);
  30. SaveGatherInfo(ASProjs);
  31. finally
  32. sddGatherProj.EndUpdate;
  33. sddGatherProj.Save;
  34. end;
  35. end;
  36. procedure TrpgGatherProjData.SaveGatherInfo(AProjs: TList);
  37. var
  38. i: Integer;
  39. Rec: TsdDataRecord;
  40. ProjInfo: TGatherProjInfo;
  41. begin
  42. for i := 0 to AProjs.Count - 1 do
  43. begin
  44. ProjInfo := TGatherProjInfo(AProjs.Items[i]);
  45. Rec := sddGatherProj.Add;
  46. if ProjInfo.ProjType = 0 then
  47. Rec.ValueByName('ID').AsInteger := i
  48. else
  49. Rec.ValueByName('ID').AsInteger := -3;
  50. Rec.ValueByName('ProjectID').AsInteger := ProjInfo.ProjectID;
  51. Rec.ValueByName('ProjectName').AsString := ProjInfo.ProjectName;
  52. Rec.ValueByName('ProjType').AsInteger := ProjInfo.ProjType;
  53. Rec.ValueByName('ParentName').AsString := ProjInfo.ParentName;
  54. Rec.ValueByName('TopParentName').AsString := ProjInfo.TopParentName;
  55. Rec.ValueByName('PhaseCount').AsInteger := ProjInfo.ProjRec.ValueByName('PhaseCount').AsInteger;
  56. Rec.ValueByName('AuditStatus').AsInteger := ProjInfo.ProjRec.ValueByName('AuditStatus').AsInteger;
  57. end;
  58. end;
  59. end.