123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- unit ProjectPropertyDM;
- interface
- uses
- SysUtils, Classes, DBClient, Provider, DB, ADODB;
- type
- TProjPropertyDM = class(TDataModule)
- atProjProperty: TADOTable;
- dspProjProperty: TDataSetProvider;
- cdsProjProperty: TClientDataSet;
- cdsProjPropertyID: TIntegerField;
- cdsProjPropertyName: TWideStringField;
- cdsProjPropertyItemValue: TWideStringField;
- atProjData: TADOTable;
- dspProjData: TDataSetProvider;
- cdsProjData: TClientDataSet;
- cdsProjDataBuildProjectID: TIntegerField;
- cdsProjDataBuildProjectName: TWideStringField;
- cdsProjDataProjectLocation: TWideStringField;
- cdsProjDataBuildUnit: TWideStringField;
- cdsProjDataAuthorUnit: TWideStringField;
- cdsProjDataBidder: TWideStringField;
- cdsProjDataAuthor: TWideStringField;
- cdsProjDataAuthorCertificate: TWideStringField;
- cdsProjDataAuditor: TWideStringField;
- cdsProjDataAuditorCertificate: TWideStringField;
- cdsProjDataBudgetProjectName: TWideStringField;
- cdsProjDataEditRange: TWideStringField;
- cdsProjDataEditDate: TDateTimeField;
- cdsProjDataMachineBBFeeRate: TFloatField;
- cdsProjDataFZFeeRate: TFloatField;
- cdsProjDataIsCalcGYFeeRate: TBooleanField;
- cdsProjDataRoadLength: TFloatField;
- cdsProjDataAvgMaintMonth: TFloatField;
- cdsProjDataRoadClass: TIntegerField;
- cdsProjDataIsNew: TBooleanField;
- cdsProjDataLandForm: TIntegerField;
- cdsProjDataDJZG: TFloatField;
- cdsProjDataYJZG: TFloatField;
- cdsProjDataNightZG: TFloatField;
- cdsProjDataRaiseRateByYear: TFloatField;
- cdsProjDataRaiseYear: TFloatField;
- cdsProjDataBuildManageFeeFile: TIntegerField;
- private
- FConnection: TADOConnection;
- procedure SetConnection(const Value: TADOConnection);
- procedure SetActive(const Value: Boolean);
- function GetActive: Boolean;
- procedure CheckActive;
- procedure EditProperty(aProjType: Integer);
- procedure EditProjData;
- property Active: Boolean read GetActive write SetActive;
- public
- property Connection: TADOConnection read FConnection write SetConnection;
- procedure EditProjProperty(aProjType: Integer);
- procedure Save;
- function GetProjectType: Integer;
- end;
- implementation
- uses
- Math, ConstVarUnit;
- {$R *.dfm}
- { TProjPropertyDM }
- procedure TProjPropertyDM.CheckActive;
- begin
- if not Active then
- Active := True;
- end;
- procedure TProjPropertyDM.EditProjData;
- begin
- cdsProjData.First;
- while not cdsProjData.Eof do
- begin
- cdsProjData.Edit;
- cdsProjDataEditDate.Value := Now;
- cdsProjData.Post;
- cdsProjData.Next;
- end;
- end;
- procedure TProjPropertyDM.EditProjProperty(aProjType: Integer);
- begin
- CheckActive;
- EditProperty(aProjType);
- EditProjData;
- end;
- procedure TProjPropertyDM.EditProperty(aProjType: Integer);
- begin
- cdsProjProperty.First;
- while not cdsProjProperty.Eof do
- begin
- if cdsProjPropertyName.Value = sProjType then
- begin
- cdsProjProperty.Edit;
- cdsProjPropertyItemValue.Value := IntToStr(aProjType);
- cdsProjProperty.Post;
- Break;
- end;
- cdsProjProperty.Next;
- end;
- end;
- function TProjPropertyDM.GetActive: Boolean;
- begin
- Result := cdsProjProperty.Active and cdsProjData.Active;
- end;
- function TProjPropertyDM.GetProjectType: Integer;
- begin
- Result := -1;
- cdsProjProperty.First;
- while not cdsProjProperty.Eof do
- begin
- if cdsProjPropertyName.Value = sProjType then
- begin
- Result := StrToIntDef(cdsProjPropertyItemValue.Value, 1);
- Break;
- end;
- cdsProjProperty.Next;
- end;
- end;
- procedure TProjPropertyDM.Save;
- begin
- cdsProjProperty.ApplyUpdates(0);
- cdsProjData.ApplyUpdates(0);
- end;
- procedure TProjPropertyDM.SetActive(const Value: Boolean);
- begin
- cdsProjProperty.Active := Value;
- cdsProjData.Active := Value;
- end;
- procedure TProjPropertyDM.SetConnection(const Value: TADOConnection);
- begin
- FConnection := Value;
- if Assigned(FConnection) then
- begin
- atProjProperty.Connection := FConnection;
- atProjData.Connection := FConnection;
- { TODO : open cds }
- Active := True;
- end;
- end;
- end.
|