ProjectPropertyDM.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. unit ProjectPropertyDM;
  2. interface
  3. uses
  4. SysUtils, Classes, DBClient, Provider, DB, ADODB;
  5. type
  6. TProjPropertyDM = class(TDataModule)
  7. atProjProperty: TADOTable;
  8. dspProjProperty: TDataSetProvider;
  9. cdsProjProperty: TClientDataSet;
  10. cdsProjPropertyID: TIntegerField;
  11. cdsProjPropertyName: TWideStringField;
  12. cdsProjPropertyItemValue: TWideStringField;
  13. atProjData: TADOTable;
  14. dspProjData: TDataSetProvider;
  15. cdsProjData: TClientDataSet;
  16. cdsProjDataBuildProjectID: TIntegerField;
  17. cdsProjDataBuildProjectName: TWideStringField;
  18. cdsProjDataProjectLocation: TWideStringField;
  19. cdsProjDataBuildUnit: TWideStringField;
  20. cdsProjDataAuthorUnit: TWideStringField;
  21. cdsProjDataBidder: TWideStringField;
  22. cdsProjDataAuthor: TWideStringField;
  23. cdsProjDataAuthorCertificate: TWideStringField;
  24. cdsProjDataAuditor: TWideStringField;
  25. cdsProjDataAuditorCertificate: TWideStringField;
  26. cdsProjDataBudgetProjectName: TWideStringField;
  27. cdsProjDataEditRange: TWideStringField;
  28. cdsProjDataEditDate: TDateTimeField;
  29. cdsProjDataMachineBBFeeRate: TFloatField;
  30. cdsProjDataFZFeeRate: TFloatField;
  31. cdsProjDataIsCalcGYFeeRate: TBooleanField;
  32. cdsProjDataRoadLength: TFloatField;
  33. cdsProjDataAvgMaintMonth: TFloatField;
  34. cdsProjDataRoadClass: TIntegerField;
  35. cdsProjDataIsNew: TBooleanField;
  36. cdsProjDataLandForm: TIntegerField;
  37. cdsProjDataDJZG: TFloatField;
  38. cdsProjDataYJZG: TFloatField;
  39. cdsProjDataNightZG: TFloatField;
  40. cdsProjDataRaiseRateByYear: TFloatField;
  41. cdsProjDataRaiseYear: TFloatField;
  42. cdsProjDataBuildManageFeeFile: TIntegerField;
  43. private
  44. FConnection: TADOConnection;
  45. procedure SetConnection(const Value: TADOConnection);
  46. procedure SetActive(const Value: Boolean);
  47. function GetActive: Boolean;
  48. procedure CheckActive;
  49. procedure EditProperty(aProjType: Integer);
  50. procedure EditProjData;
  51. property Active: Boolean read GetActive write SetActive;
  52. public
  53. property Connection: TADOConnection read FConnection write SetConnection;
  54. procedure EditProjProperty(aProjType: Integer);
  55. procedure Save;
  56. function GetProjectType: Integer;
  57. end;
  58. implementation
  59. uses
  60. Math, ConstVarUnit;
  61. {$R *.dfm}
  62. { TProjPropertyDM }
  63. procedure TProjPropertyDM.CheckActive;
  64. begin
  65. if not Active then
  66. Active := True;
  67. end;
  68. procedure TProjPropertyDM.EditProjData;
  69. begin
  70. cdsProjData.First;
  71. while not cdsProjData.Eof do
  72. begin
  73. cdsProjData.Edit;
  74. cdsProjDataEditDate.Value := Now;
  75. cdsProjData.Post;
  76. cdsProjData.Next;
  77. end;
  78. end;
  79. procedure TProjPropertyDM.EditProjProperty(aProjType: Integer);
  80. begin
  81. CheckActive;
  82. EditProperty(aProjType);
  83. EditProjData;
  84. end;
  85. procedure TProjPropertyDM.EditProperty(aProjType: Integer);
  86. begin
  87. cdsProjProperty.First;
  88. while not cdsProjProperty.Eof do
  89. begin
  90. if cdsProjPropertyName.Value = sProjType then
  91. begin
  92. cdsProjProperty.Edit;
  93. cdsProjPropertyItemValue.Value := IntToStr(aProjType);
  94. cdsProjProperty.Post;
  95. Break;
  96. end;
  97. cdsProjProperty.Next;
  98. end;
  99. end;
  100. function TProjPropertyDM.GetActive: Boolean;
  101. begin
  102. Result := cdsProjProperty.Active and cdsProjData.Active;
  103. end;
  104. function TProjPropertyDM.GetProjectType: Integer;
  105. begin
  106. Result := -1;
  107. cdsProjProperty.First;
  108. while not cdsProjProperty.Eof do
  109. begin
  110. if cdsProjPropertyName.Value = sProjType then
  111. begin
  112. Result := StrToIntDef(cdsProjPropertyItemValue.Value, 1);
  113. Break;
  114. end;
  115. cdsProjProperty.Next;
  116. end;
  117. end;
  118. procedure TProjPropertyDM.Save;
  119. begin
  120. cdsProjProperty.ApplyUpdates(0);
  121. cdsProjData.ApplyUpdates(0);
  122. end;
  123. procedure TProjPropertyDM.SetActive(const Value: Boolean);
  124. begin
  125. cdsProjProperty.Active := Value;
  126. cdsProjData.Active := Value;
  127. end;
  128. procedure TProjPropertyDM.SetConnection(const Value: TADOConnection);
  129. begin
  130. FConnection := Value;
  131. if Assigned(FConnection) then
  132. begin
  133. atProjProperty.Connection := FConnection;
  134. atProjData.Connection := FConnection;
  135. { TODO : open cds }
  136. Active := True;
  137. end;
  138. end;
  139. end.