| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | unit tpPricePartSettingFrm;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, ExtCtrls, StdCtrls, ComCtrls;const  sPegIgnoreHint = '各桩号间可能存在重叠,可通过该项设置多少m重叠忽略不计' + #13#10 +                   '如果要求重叠桩号划分为1个标段,可设置为0。';type  TPricePartInfo = class  private    FPartPrice: Double;    FMinLength: Integer;    FMinStep: Integer;  public    constructor Create;    property PartPrice: Double read FPartPrice write FPartPrice;    property MinLength: Integer read FMinLength write FMinLength;    property MinStep: Integer read FMinStep write FMinStep;  end;  TtpPricePartSettingForm = class(TForm)    lePartTotalPrice: TLabeledEdit;    lblFormat: TLabel;    btnOk: TButton;    btnCancel: TButton;    leMinLength: TLabeledEdit;    udMinLength: TUpDown;    leMinStep: TLabeledEdit;    udMinStep: TUpDown;    procedure btnOkClick(Sender: TObject);    procedure lePartTotalPriceChange(Sender: TObject);    procedure lePartTotalPriceKeyPress(Sender: TObject; var Key: Char);  private    function GetPartPrice: Double;    function GetMinLength: Integer;    function GetMinStep: Integer;  public    constructor Create(AInfo: TPricePartInfo);    destructor Destroy; override;    property PartPrice: Double read GetPartPrice;    property MinLength: Integer read GetMinLength;    property MinStep: Integer read GetMinStep;  end;function PricePartSetting(AInfo: TPricePartInfo): Boolean;implementationuses  UtilMethods;function PricePartSetting(AInfo: TPricePartInfo): Boolean;var  SettingForm: TtpPricePartSettingForm;begin  SettingForm := TtpPricePartSettingForm.Create(AInfo);  try    Result := SettingForm.ShowModal = mrOk;    if Result then    begin      AInfo.PartPrice := SettingForm.PartPrice;      AInfo.MinLength := SettingForm.MinLength;      AInfo.MinStep := SettingForm.MinStep;    end;  finally    SettingForm.Free;  end;end;{$R *.dfm}{ TtpPricePartSettingForm }constructor TtpPricePartSettingForm.Create(AInfo: TPricePartInfo);begin  inherited Create(nil);  if AInfo.PartPrice > 0 then    lePartTotalPrice.Text := FloatToStr(AInfo.PartPrice)  else    lePartTotalPrice.Text := '';  udMinLength.Position := AInfo.MinLength;  udMinStep.Position := AInfo.MinStep;  SetWindowLong(lePartTotalPrice.Handle, GWL_STYLE, GetWindowLong(lePartTotalPrice.Handle, GWL_STYLE) or ES_RIGHT);  SetWindowLong(leMinLength.Handle, GWL_STYLE, GetWindowLong(leMinLength.Handle, GWL_STYLE) or ES_RIGHT);  SetWindowLong(leMinStep.Handle, GWL_STYLE, GetWindowLong(leMinStep.Handle, GWL_STYLE) or ES_RIGHT);end;destructor TtpPricePartSettingForm.Destroy;begin  inherited;end;function TtpPricePartSettingForm.GetPartPrice: Double;begin  Result := StrToFloatDef(lePartTotalPrice.Text, 0);end;procedure TtpPricePartSettingForm.btnOkClick(Sender: TObject);begin  if PartPrice <= 0 then    TipMessage('单标段目标金额应大于0。')  else    ModalResult := mrOk;end;procedure TtpPricePartSettingForm.lePartTotalPriceChange(Sender: TObject);begin  lblFormat.Visible :=  PartPrice > 0;  lblFormat.Caption := FormatFloat('##,###,###,###.##', PartPrice);end;procedure TtpPricePartSettingForm.lePartTotalPriceKeyPress(Sender: TObject;  var Key: Char);begin  if not (Key in ['0'..'9', '.', #8, #13]) then    Key := #0;end;function TtpPricePartSettingForm.GetMinLength: Integer;begin  Result := udMinLength.Position;end;function TtpPricePartSettingForm.GetMinStep: Integer;begin  Result := udMinStep.Position;end;{ TPricePartInfo }constructor TPricePartInfo.Create;begin  FPartPrice := 0;  FMinLength := 5;  FMinStep := 100;end;end.
 |