PhaseProperty.pas 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. unit PhaseProperty;
  2. interface
  3. uses
  4. ProjectProperty, ADODB, Variants, SysUtils;
  5. type
  6. TPhaseProperties = class
  7. private
  8. FPropertyInqurity: TPropertyInquiry;
  9. FFinalAudit: Boolean;
  10. FAuditCount: Integer;
  11. FPayablePrice: Double;
  12. function GetBoolPropertyDef(const AName: string; ADef: Boolean): Boolean;
  13. function GetIntPropertyDef(const AName: string; ADef: Integer): Integer;
  14. function GetStrPropertyDef(const AName, ADef: string): string;
  15. function GetFloatPropertyDef(const AName: string; ADef: Double): Double;
  16. procedure CreateInqurity(AConnection: TADOConnection);
  17. procedure LoadBaseProperties;
  18. procedure SetFinalAudit(const Value: Boolean);
  19. procedure SetAuditCount(const Value: Integer);
  20. function GetZJJLType: Integer;
  21. procedure SetZJJLType(const Value: Integer);
  22. public
  23. constructor Create(AConnection: TADOConnection);
  24. destructor Destroy; override;
  25. procedure Open;
  26. procedure Save;
  27. property AuditCount: Integer read FAuditCount write SetAuditCount;
  28. property FinalAudit: Boolean read FFinalAudit write SetFinalAudit;
  29. property ZJJLType: Integer read GetZJJLType write SetZJJLType;
  30. end;
  31. implementation
  32. { TPhaseProperties }
  33. constructor TPhaseProperties.Create(AConnection: TADOConnection);
  34. begin
  35. CreateInqurity(AConnection);
  36. end;
  37. procedure TPhaseProperties.CreateInqurity(AConnection: TADOConnection);
  38. begin
  39. FPropertyInqurity := TPropertyInquiry.Create(AConnection);
  40. FPropertyInqurity.TableName := 'PhaseProperty';
  41. end;
  42. destructor TPhaseProperties.Destroy;
  43. begin
  44. FPropertyInqurity.Free;
  45. inherited;
  46. end;
  47. function TPhaseProperties.GetBoolPropertyDef(const AName: string;
  48. ADef: Boolean): Boolean;
  49. var
  50. vProperty: Variant;
  51. begin
  52. vProperty := FPropertyInqurity.Value[AName];
  53. if VarIsNull(vProperty) then
  54. Result := ADef
  55. else
  56. Result := Boolean(vProperty);
  57. end;
  58. function TPhaseProperties.GetFloatPropertyDef(const AName: string;
  59. ADef: Double): Double;
  60. var
  61. sValue: Variant;
  62. begin
  63. sValue := GetStrPropertyDef(AName, FloatToStr(ADef));
  64. Result := StrToFloatDef(sValue, ADef);
  65. end;
  66. function TPhaseProperties.GetIntPropertyDef(const AName: string;
  67. ADef: Integer): Integer;
  68. var
  69. sValue: Variant;
  70. begin
  71. sValue := GetStrPropertyDef(AName, IntToStr(ADef));
  72. Result := StrToIntDef(sValue, ADef);
  73. end;
  74. function TPhaseProperties.GetStrPropertyDef(const AName,
  75. ADef: string): string;
  76. var
  77. vProperty: Variant;
  78. begin
  79. vProperty := FPropertyInqurity.Value[AName];
  80. Result := VarToStrDef(vProperty, ADef);
  81. end;
  82. function TPhaseProperties.GetZJJLType: Integer;
  83. begin
  84. Result := GetIntPropertyDef('ZJJLType', 0);
  85. end;
  86. procedure TPhaseProperties.LoadBaseProperties;
  87. begin
  88. FFinalAudit := GetBoolPropertyDef('FinalAudit', False);
  89. FAuditCount := GetIntPropertyDef('AuditCount', 0);
  90. end;
  91. procedure TPhaseProperties.Open;
  92. begin
  93. LoadBaseProperties;
  94. end;
  95. procedure TPhaseProperties.Save;
  96. begin
  97. end;
  98. procedure TPhaseProperties.SetAuditCount(const Value: Integer);
  99. begin
  100. FAuditCount := Value;
  101. FPropertyInqurity.Value['AuditCount'] := FAuditCount;
  102. end;
  103. procedure TPhaseProperties.SetFinalAudit(const Value: Boolean);
  104. begin
  105. FFinalAudit := Value;
  106. FPropertyInqurity.Value['FinalAudit'] := FFinalAudit;
  107. end;
  108. procedure TPhaseProperties.SetZJJLType(const Value: Integer);
  109. begin
  110. FPropertyInqurity.Value['ZJJLType'] := Value;
  111. end;
  112. end.