unit ualtaediciontpostoper_covarianzacadenciaanual;

{$mode delphi}

interface

uses
  {$IFDEF WINDOWS}
 Windows,
  Messages,
{$ENDIF}
 SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, ExtCtrls, xMatDefs, uHistoVarsOps,
 uBaseAltaEdicionPostOpers, uLectorSimRes3Defs, uVerDoc,
 uPostOpers;


type

  { TAltaEdicionTPostOper_CovarianzaCadenciaAnual }

  TAltaEdicionTPostOper_CovarianzaCadenciaAnual = class(TBaseAltaEdicionPostOpers)
    BAyuda: TButton;
    bCancelar: TButton;
    bGuardar: TButton;
    lblCronVar1: TLabel;
    lblCronVar2: TLabel;
    lblOverlap: TLabel;
    overlap: TEdit;
    Panel1: TPanel;
    Resultado: TLabel;
    cbParam2: TComboBox;
    cbParam1: TComboBox;
    cbRes: TComboBox;
    procedure BAyudaClick(Sender: TObject);
    procedure bCancelarClick(Sender: TObject);
    procedure bGuardarClick(Sender: TObject); override;
    procedure cbParam2Change(Sender: TObject);
    procedure cbParam1Change(Sender: TObject);
    procedure cbResChange(Sender: TObject);
    procedure lblOverlapClick(Sender: TObject);
    procedure OverlapChange(Sender: TObject);

  private
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  protected
    function validarFormulario: boolean; override ;

  public
    constructor Create(AOwner: TComponent; lector: TLectorSimRes3Defs;
      postOper: TPostOper; tipoPostOper: TClaseDePostOper); override;

  end;

var
  AltaEdicionTPostOper_CovarianzaCadenciaAnual: TAltaEdicionTPostOper_CovarianzaCadenciaAnual;

implementation

{$IFNDEF FPC}
  {$R *.dfm}
{$ELSE}
  {$R *.lfm}
{$ENDIF}


{ TAltaEdicionTPostOper_CovarianzaCadenciaAnual }

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.cbResChange(
  Sender: TObject);
begin
  inherited cbCronVarComplementarioChange3(Sender, cbParam1, cbParam2, true);
end;

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.lblOverlapClick(
  Sender: TObject);
begin

end;

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.OverlapChange(
  Sender: TObject);
begin

end;


procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.cbParam1Change(
  Sender: TObject);
begin
  inherited cbCronVarComplementarioChange3(Sender, cbRes, cbParam2, true);
end;

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.cbParam2Change(
  Sender: TObject);
begin
  inherited cbCronVarComplementarioChange3(Sender, cbRes, cbParam1, true);
end;


Constructor TAltaEdicionTPostOper_CovarianzaCadenciaAnual.Create(AOwner: TComponent;
  lector: TLectorSimRes3Defs; postOper: TPostOper; tipoPostOper: TClaseDePostOper);
var
  cv1, cv2, cv3: TCronVar;
  real: NReal;
begin
  inherited Create(AOwner, lector, postOper, tipoPostOper);

  inicializarCBCronVars(cbRes, false);
  inicializarCBCronVars(cbParam1, false);
  inicializarCBCronVars(cbParam2, false);
//  Overlap.Text:= FloatToStrF(TPostOper_CovarianzaCadenciaAnual(postOper).aReal, ffGeneral, 12, 6);

  if postOper <> NIL then
  begin
    lector.paramsPostOper3CronVarsUnReal(postOper, cv1, cv2, cv3, real);

    setCBCronVar(cbRes, cv1);
    setCBCronVar(cbParam1, cv2);
    setCBCronVar(cbParam2, cv3);
    Overlap.Text:= FloatToStrF(real, ffGeneral, 12, 6);
  end;
end;

function TAltaEdicionTPostOper_CovarianzaCadenciaAnual.validarFormulario: boolean;
begin
  result:= validarCBCronVars(cbRes) and
           validarCBCronVars(cbParam1) and
           validarCBCronVars(cbParam2) and
           validarEditFloat(Overlap, -MaxNReal, MaxNReal);
end;


procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.BAyudaClick(
  Sender: TObject);
begin
  verdoc( 3829, tipoPostOper);
end;

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.bCancelarClick(
  Sender: TObject);
begin
  inherited bCancelarClick(Sender);
end;

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.bGuardarClick(
  Sender: TObject);
begin

  if validarFormulario then
  begin
    lector.altaEdicionPostOper3CronVarsUnReal(tipoPostOper,
                                        postOper,
                                        valorCBCronVar(cbRes),
                                        valorCBCronVar(cbParam1),
                                        valorCBCronVar(cbParam2),
                                        StrToFloat(Overlap.text));
    ModalResult:= mrOk;
  end;
end;

procedure TAltaEdicionTPostOper_CovarianzaCadenciaAnual.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  inherited FormCloseQuery(Sender, CanClose);
end;
end.

