| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639 | unit ProjectProperty;interfaceuses  Classes, SysUtils, Variants, DB, ADODB, ZhAPI, CalcDecimal;type  TPropertyInquiry = class  private    FInquriyQuery: TADOQuery;    FConnection: TADOConnection;    FTableName: string;    FSql: string;    function GetValue(const AName: string): Variant;    procedure SetValue(const AName: string; const Value: Variant);    function GetNewID: Integer;    procedure ExecuteSql(AIsSelect: Boolean = True);    function CheckPropertyExist(const AName: string): Boolean;  public    constructor Create(AConnection: TADOConnection);    destructor Destroy; override;    property TableName: string read FTableName write FTableName;    property Value[const AName: string]: Variant read GetValue write SetValue; default;  end;  TProjProperties = class  private    FProjectData: TObject;    FPropertyInqurity: TPropertyInquiry;    FShowPriceChange: Boolean;    FPhaseCount: Integer;    FLockedLedgerData: Boolean;    FStartedSubsist: Double;    FContractPrice: Double;    FMaterialSubsist: Double;    FBLegal: string;    FDealName: string;    FDealIndex: string;    FCLegal: string;    FCDate: string;    FBName: string;    FProjectName: string;    FBDate: string;    FCName: string;    FSDate: string;    FSName: string;    FSLegal: string;    FLoadLength: Double;    FLaneCount: Integer;    FLoadLevel: Integer;    FEndPeg: string;    FStartPeg: string;    FShowBGLCode: Boolean;    FZJJLPreText: string;    FUnlockInfoPassword: string;    FPhaseIndex: Integer;    FShowDesignQuantity: Boolean;    FDealType: string;    FShowAlias: Boolean;    FDecimalManager: TDecimalManager;    FTotalPriceDigit: Integer;    FTotalPriceFormat: string;    FQuantityDigit: Integer;    FQuantityFormat: string;    FPriceDigit: Integer;    FPriceFormat: string;    FUpdateFlag: Integer;    function GetBoolPropertyDef(const AName: string; ADef: Boolean): Boolean;    function GetIntPropertyDef(const AName: string; ADef: Integer): Integer;    function GetStrPropertyDef(const AName, ADef: string): string;    function GetFloatPropertyDef(const AName: string; ADef: Double): Double;    function GetDisplayFormat(ADigit: Integer): string;    procedure LoadBaseProperties;    procedure LoadViewProperties;    procedure LoadDealInfo;    procedure LoadTechParameters;    procedure LoadCalcParameters;    procedure SaveDealInfo;    procedure SaveTechParameters;    procedure SaveCalcParameters;    procedure SetShowPriceChange(const Value: Boolean);    procedure SetPhaseCount(const Value: Integer);    procedure SetLockedLedgerData(const Value: Boolean);    function GetFinalAuditCount: Integer;    procedure SetFinalAuditCount(const Value: Integer);    function GetAuditStatus: Integer;    procedure SetAuditStatus(const Value: Integer);    function GetAuditStatusStr: string;    procedure SetContractPrice(const Value: Double);    procedure SetMaterialSubsist(const Value: Double);    procedure SetStartedSubsist(const Value: Double);    function GetAuditCompany: string;    procedure SetAuditCompany(const Value: string);    procedure SetShowBGLCode(const Value: Boolean);    procedure SetZJJLPreText(const Value: string);    procedure SetUnlockInfoPassword(const Value: string);    procedure SetPhaseIndex(const Value: Integer);    procedure SetShowDesignQuantity(const Value: Boolean);    procedure SetShowAlias(const Value: Boolean);    procedure SetQuantityDigit(const Value: Integer);    procedure SetTotalPriceDigit(const Value: Integer);    procedure SetUpdateFlag(const Value: Integer);  public    constructor Create(AProjectData: TObject);    destructor Destroy; override;    procedure Open(AConnection: TADOConnection);    procedure Save;    {Submit-Audit-Reply}    // 共计终审计量期数    property FinalAuditCount: Integer read GetFinalAuditCount write SetFinalAuditCount;    // 当前审核状态    property AuditStatus: Integer read GetAuditStatus write SetAuditStatus;    property AuditStatusStr: string read GetAuditStatusStr;    property AuditCompany: string read GetAuditCompany write SetAuditCompany;    {合同信息}    // 建设项目名称    property ProjectName: string read FProjectName write FProjectName;    // 合同名称    property DealName: string read FDealName write FDealName;    // 合同编号    property DealIndex: string read FDealIndex write FDealIndex;    // 合同类别    property DealType: string read FDealType write FDealType;    // 建设单位    // 名称    property BName: string read FBName write FBName;    // 法人代表    property BLegal: string read FBLegal write FBLegal;    // 签订日期    property BDate: string read FBDate write FBDate;    // 施工单位    // 名称    property CName: string read FCName write FCName;    // 法人代表    property CLegal: string read FCLegal write FCLegal;    // 签订日期    property CDate: string read FCDate write FCDate;    // 监理单位    // 名称    property SName: string read FSName write FSName;    // 法人代表    property SLegal: string read FSLegal write FSLegal;    // 签订日期    property SDate: string read FSDate write FSDate;    {技术参数}    // 公路等级    property LoadLevel: Integer read FLoadLevel write FLoadLevel;    // 起点桩号    property StartPeg: string read FStartPeg write FStartPeg;    // 终点桩号    property EndPeg: string read FEndPeg write FEndPeg;    // 长度    property LoadLength: Double read FLoadLength write FLoadLength;    // 车道数    property LaneCount: Integer read FLaneCount write FLaneCount;    {合同支付}    property ContractPrice: Double read FContractPrice write SetContractPrice;    property MaterialSubsist: Double read FMaterialSubsist write SetMaterialSubsist;    property StartedSubsisit: Double read FStartedSubsist write SetStartedSubsist;    {密码}    // 解锁台账编辑节点密码    property UnlockInfoPassword: string read FUnlockInfoPassword write SetUnlockInfoPassword;    {小数位数}    property DecimalManager: TDecimalManager read FDecimalManager;    // 数量    property QuantityDigit: Integer read FQuantityDigit write SetQuantityDigit;    property QuantityFormat: string read FQuantityFormat;    // 金额    property TotalPriceDigit: Integer read FTotalPriceDigit write SetTotalPriceDigit;    property TotalPriceFormat: string read FTotalPriceFormat;    // 单价    property PriceDigit: Integer read FPriceDigit;    property PriceFormat: string read FPriceFormat;    {升级标记}    property UpdateFlag: Integer read FUpdateFlag write SetUpdateFlag;    {Base}    // 计量期数    property PhaseIndex: Integer read FPhaseIndex write SetPhaseIndex;    property PhaseCount: Integer read FPhaseCount write SetPhaseCount;    property ZJJLPreText: string read FZJJLPreText write SetZJJLPreText;    {View}    // Can Modify In ProjectPropertiesFrm    property ShowPriceChange: Boolean read FShowPriceChange write SetShowPriceChange;    property ShowBGLCode: Boolean read FShowBGLCode write SetShowBGLCode;    property ShowDesignQuantity: Boolean read FShowDesignQuantity write SetShowDesignQuantity;    property ShowAlias: Boolean read FShowAlias write SetShowAlias;  end;implementation{ TPropertyInquiry }function TPropertyInquiry.CheckPropertyExist(const AName: string): Boolean;begin  Result := False;  FSql := Format('Select * From %s Where Name = ''%s''', [TableName, UpperCase(AName)]);  ExecuteSql;  Result := FInquriyQuery.RecordCount > 0;  FInquriyQuery.Close;end;constructor TPropertyInquiry.Create(AConnection: TADOConnection);begin  FConnection := AConnection;  FInquriyQuery := TADOQuery.Create(nil);  FInquriyQuery.Connection := FConnection;end;destructor TPropertyInquiry.Destroy;begin  FInquriyQuery.Free;  inherited;end;procedure TPropertyInquiry.ExecuteSql(AIsSelect: Boolean);begin  FInquriyQuery.Close;  FInquriyQuery.SQL.Clear;  FInquriyQuery.SQL.Add(FSql);  if AIsSelect then    FInquriyQuery.Open  else    FInquriyQuery.ExecSQL;end;function TPropertyInquiry.GetNewID: Integer;begin  FSql := Format('Select Max(ID) As MaxID From %s', [TableName]);  ExecuteSql;  if FInquriyQuery.RecordCount > 0 then    Result := FInquriyQuery.FieldByName('MaxID').AsInteger + 1  else    Result := 0;  FInquriyQuery.Close;end;function TPropertyInquiry.GetValue(const AName: string): Variant;begin  FSql := Format('Select * From %s Where Name = ''%s''', [TableName, UpperCase(AName)]);  ExecuteSql;  if FInquriyQuery.RecordCount > 0 then    Result := FInquriyQuery.FieldByName('PropValue').AsVariant  else    Result := Null;  FInquriyQuery.Close;end;procedure TPropertyInquiry.SetValue(const AName: string;  const Value: Variant);  function GetUpdateSql: string;  begin    if VarIsNull(Value) then      Result := Format('Delete From %s Where Name = ''%s''', [TableName, UpperCase(AName)])    else    begin      if CheckPropertyExist(AName) then        Result := Format('Update %s Set PropValue = ''%s'' Where Name = ''%s''',          [TableName, VarToStr(Value), UpperCase(AName)])      else        Result := Format('Insert Into %s (ID, Name, PropValue) Values (%d, ''%s'', ''%s'')',          [TableName, GetNewID, UpperCase(AName), VarToStr(Value)]);    end;  end;begin  FSql := GetUpdateSql;  ExecuteSql(False);  FInquriyQuery.Close;end;{ TProjProperties }constructor TProjProperties.Create(AProjectData: TObject);begin  FProjectData := AProjectData;  FDecimalManager := TDecimalManager.Create(AProjectData);end;destructor TProjProperties.Destroy;begin  FPropertyInqurity.Free;  FDecimalManager.Free;  inherited;end;function TProjProperties.GetAuditCompany: string;begin  Result := GetStrPropertyDef('AuditCompany', '');end;function TProjProperties.GetAuditStatus: Integer;begin  Result := GetIntPropertyDef('AuditStatus', -1);end;function TProjProperties.GetAuditStatusStr: string;begin  case AuditStatus of    -1:      if PhaseCount = 0 then        Result := '原报'      else        Result := '批复';    0:      Result := '原报';  else    Result := Format('%d 审', [AuditStatus]);  end;end;function TProjProperties.GetBoolPropertyDef(const AName: string;  ADef: Boolean): Boolean;var  vProperty: Variant;begin  vProperty := FPropertyInqurity.Value[AName];  if VarIsNull(vProperty) then    Result := ADef  else    Result := Boolean(vProperty);end;function TProjProperties.GetDisplayFormat(ADigit: Integer): string;begin  case ADigit of    0: Result := '#';    1: Result := '#.#';    2: Result := '#.##';    3: Result := '#.###';    4: Result := '#.####';    5: Result := '#.#####';    6: Result := '#.######';    7: Result := '#.#######';    8: Result := '#.########';    9: Result := '#.#########';  else    Result := '#.##########';  end;end;function TProjProperties.GetFinalAuditCount: Integer;begin  Result := GetIntPropertyDef('FinalAuditCount', 0);end;function TProjProperties.GetFloatPropertyDef(const AName: string;  ADef: Double): Double;var  sValue: Variant;begin  sValue := GetStrPropertyDef(AName, FloatToStr(ADef));  Result := StrToFloatDef(sValue, ADef);end;function TProjProperties.GetIntPropertyDef(const AName: string;  ADef: Integer): Integer;var  sValue: Variant;begin  sValue := GetStrPropertyDef(AName, IntToStr(ADef));  Result := StrToIntDef(sValue, ADef);end;function TProjProperties.GetStrPropertyDef(const AName,  ADef: string): string;var  vProperty: Variant;begin  vProperty := FPropertyInqurity.Value[AName];  Result := VarToStrDef(vProperty, ADef);end;procedure TProjProperties.LoadBaseProperties;begin  FPhaseCount := GetIntPropertyDef('PhaseCount', 0);  FLockedLedgerData := GetBoolPropertyDef('LockedLedgerData', False);  FContractPrice := GetFloatPropertyDef('ContractPrice', 0);  FStartedSubsist := GetFloatPropertyDef('StartedSubsist', 0);  FMaterialSubsist := GetFloatPropertyDef('MaterialSubsist', 0);  FZJJLPreText := GetStrPropertyDef('ZJJLPreText', '');end;procedure TProjProperties.LoadCalcParameters;begin  FQuantityDigit := GetIntPropertyDef('QuantityDigit', 3);  FQuantityFormat := GetDisplayFormat(FQuantityDigit);  FTotalPriceDigit := GetIntPropertyDef('TotalPriceDigit', 0);  FTotalPriceFormat := GetDisplayFormat(FTotalPriceDigit);  FPriceDigit := 2;  FPriceFormat := GetDisplayFormat(FPriceDigit);  with FDecimalManager.Common do  begin    Quantity.Digit := GetIntPropertyDef('QuantityDigit', 3);    TotalPrice.Digit := GetIntPropertyDef('TotalPriceDigit', 0);    Price.Digit := 2;  end;  with FDecimalManager do  begin    Compile.Quantity.Digit := GetIntPropertyDef('QuantityDigit1', Common.Quantity.Digit);    Compile.TotalPrice.Digit := GetIntPropertyDef('TotalPriceDigit1', Common.TotalPrice.Digit);    Compile.Price.Digit := 2;  end;  with FDecimalManager do  begin    PriceMargin.Quantity.Digit := Common.Quantity.Digit;    PriceMargin.TotalPrice.Digit := Common.TotalPrice.Digit;    PriceMargin.Price.Digit := GetIntPropertyDef('PM_PriceDigit', Common.Price.Digit);  end;end;procedure TProjProperties.LoadDealInfo;begin  FProjectName := GetStrPropertyDef('ProjectName', '');  FDealName := GetStrPropertyDef('DealName', '');  FDealIndex := GetStrPropertyDef('DealIndex', '');  FDealType := GetStrPropertyDef('DealType', '');  FBName := GetStrPropertyDef('BName', '');  FBLegal := GetStrPropertyDef('BLegal', '');  FBDate := GetStrPropertyDef('BDate', '');  FCName := GetStrPropertyDef('CName', '');  FCLegal := GetStrPropertyDef('CLegal', '');  FCDate := GetStrPropertyDef('CDate', '');  FSName := GetStrPropertyDef('SName', '');  FSLegal := GetStrPropertyDef('SLegal', '');  FSDate := GetStrPropertyDef('SDate', '');end;procedure TProjProperties.LoadTechParameters;begin  FLoadLevel := GetIntPropertyDef('LoadLevel', 0);  FStartPeg := GetStrPropertyDef('StartPeg', '');  FEndPeg := GetStrPropertyDef('EndPeg', '');  FLoadLength := GetFloatPropertyDef('LoadLength', 0);  FLaneCount := GetIntPropertyDef('LaneCount', 0);end;procedure TProjProperties.LoadViewProperties;begin  FShowPriceChange := GetBoolPropertyDef('ShowPriceChange', False);  FShowBGLCode := GetBoolPropertyDef('ShowBGLCode', True);  FShowDesignQuantity := GetBoolPropertyDef('ShowDesignQuantity', False);  FShowAlias := GetBoolPropertyDef('ShowAlias', False);end;procedure TProjProperties.Open(AConnection: TADOConnection);begin  FPropertyInqurity := TPropertyInquiry.Create(AConnection);  FPropertyInqurity.TableName := 'ProjProperties';  LoadBaseProperties;  LoadViewProperties;  LoadDealInfo;  LoadTechParameters;  LoadCalcParameters;  FUnlockInfoPassword := GetStrPropertyDef('UnlockInfoPassword', '');  FUpdateFlag := GetIntPropertyDef('UpdateFlag', 0);end;procedure TProjProperties.Save;begin  SaveDealInfo;  SaveTechParameters;  SaveCalcParameters;end;procedure TProjProperties.SaveCalcParameters;begin  with FDecimalManager do  begin    {FPropertyInqurity.Value['QuantityDigit'] := Common.Quantity.Digit;    FPropertyInqurity.Value['TotalPriceDigit'] := Common.TotalPrice.Digit;    FPropertyInqurity.Value['QuantityDigit1'] := Compile.Quantity.Digit;    FPropertyInqurity.Value['TotalPriceDigit1'] := Compile.TotalPrice.Digit;}        FPropertyInqurity.Value['PM_PriceDigit'] := PriceMargin.Price.Digit;  end;end;procedure TProjProperties.SaveDealInfo;begin  FPropertyInqurity.Value['ProjectName'] := FProjectName;  FPropertyInqurity.Value['DealName'] := FDealName;  FPropertyInqurity.Value['DealIndex'] := FDealIndex;  FPropertyInqurity.Value['DealType'] := FDealType;  FPropertyInqurity.Value['BName'] := FBName;  FPropertyInqurity.Value['BLegal'] := FBLegal;  FPropertyInqurity.Value['BDate'] := FBDate;  FPropertyInqurity.Value['CName'] := FCName;  FPropertyInqurity.Value['CLegal'] := FCLegal;  FPropertyInqurity.Value['CDate'] := FCDate;  FPropertyInqurity.Value['SName'] := FSName;  FPropertyInqurity.Value['SLegal'] := FSLegal;  FPropertyInqurity.Value['SDate'] := FSDate;end;procedure TProjProperties.SaveTechParameters;begin  FPropertyInqurity.Value['LoadLevel'] := FLoadLevel;  FPropertyInqurity.Value['StartPeg'] := FStartPeg;  FPropertyInqurity.Value['EndPeg'] := FEndPeg;  FPropertyInqurity.Value['LoadLength'] := FLoadLength;  FPropertyInqurity.Value['LaneCount'] := FLaneCount;end;procedure TProjProperties.SetAuditCompany(const Value: string);begin  FPropertyInqurity.Value['AuditCompany'] := Value;end;procedure TProjProperties.SetAuditStatus(const Value: Integer);begin  FPropertyInqurity.Value['AuditStatus'] := Value;end;procedure TProjProperties.SetContractPrice(const Value: Double);begin  FContractPrice := Value;  FPropertyInqurity.Value['ContractPrice'] := Value;end;procedure TProjProperties.SetFinalAuditCount(const Value: Integer);begin  FPropertyInqurity.Value['FinalAuditCount'] := Value;end;procedure TProjProperties.SetLockedLedgerData(const Value: Boolean);begin  FLockedLedgerData := Value;  FPropertyInqurity.Value['LockedLedgerData'] := Value;end;procedure TProjProperties.SetMaterialSubsist(const Value: Double);begin  FMaterialSubsist := Value;  FPropertyInqurity.Value['MaterialSubsist'] := Value;end;procedure TProjProperties.SetPhaseCount(const Value: Integer);begin  FPhaseCount := Value;  FPropertyInqurity.Value['PhaseCount'] := Value;end;procedure TProjProperties.SetPhaseIndex(const Value: Integer);begin  FPhaseIndex := Value;  FPropertyInqurity.Value['PhaseIndex'] := Value;end;procedure TProjProperties.SetQuantityDigit(const Value: Integer);begin  FQuantityDigit := Value;  FPropertyInqurity.Value['QuantityDigit'] := Value;  FQuantityFormat := GetDisplayFormat(FQuantityDigit);end;procedure TProjProperties.SetShowAlias(const Value: Boolean);begin  FShowAlias := Value;  FPropertyInqurity.Value['ShowAlias'] := Value;end;procedure TProjProperties.SetShowBGLCode(const Value: Boolean);begin  FShowBGLCode := Value;  FPropertyInqurity.Value['ShowBGLCode'] := Value;end;procedure TProjProperties.SetShowDesignQuantity(const Value: Boolean);begin  FShowDesignQuantity := Value;  FPropertyInqurity.Value['ShowDesignQuantity'] := Value;end;procedure TProjProperties.SetShowPriceChange(const Value: Boolean);begin  FShowPriceChange := Value;  FPropertyInqurity.Value['ShowPriceChange'] := Value;end;procedure TProjProperties.SetStartedSubsist(const Value: Double);begin  FStartedSubsist := Value;  FPropertyInqurity.Value['StartedSubsist'] := Value;end;procedure TProjProperties.SetTotalPriceDigit(const Value: Integer);begin  FTotalPriceDigit := Value;  FPropertyInqurity.Value['TotalPriceDigit'] := Value;  FTotalPriceFormat := GetDisplayFormat(FTotalPriceDigit);end;procedure TProjProperties.SetUnlockInfoPassword(const Value: string);begin  FUnlockInfoPassword := Value;  FPropertyInqurity.Value['UnlockInfoPassword'] := Value;end;procedure TProjProperties.SetUpdateFlag(const Value: Integer);begin  FUpdateFlag := Value;  FPropertyInqurity.Value['UpdateFlag'] := Value;end;procedure TProjProperties.SetZJJLPreText(const Value: string);begin  FZJJLPreText := Value;  FPropertyInqurity.Value['ZJJLPreText'] := Value;end;end.
 |