{
===============================================================================
  Copyright (©) 2006. Rodax Software.
===============================================================================
  Los contenidos de este fichero son propiedad de Rodax Software titular del
  copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
  en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
  acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
  bajo el que se suministra.
  -----------------------------------------------------------------------------
  Web:  www.rodax-software.com
===============================================================================
  Fecha primera versión: 22-05-2006
  Versión actual: 1.0.0
  Fecha versión actual: 22-05-2006
===============================================================================
  Modificaciones:

    Fecha         Comentarios
    ---------------------------------------------------------------------------
===============================================================================
}

unit uViewObra;

interface

uses
  Windows, Messages, SysUtils, Variants, uViewBase, StdCtrls, DB,
  uDADataTable, uViewInternet, uViewTelefonos, Mask, DBCtrls, ExtCtrls,
  Controls, Classes, Forms, uCustomView, uViewDireccion, uBizObra,
  cxControls, cxContainer, cxEdit, cxTextEdit, cxMaskEdit, cxDropDownEdit,
  cxCalendar, cxDBEdit, uViewGrid, uViewContactos,
  Grids, DBGrids, dxLayoutControl, uViewDatosObra, uViewDatosYSeleccionContacto,
  uViewCalculoHonorarios;

type
  IViewObra = interface(IViewBase)
  ['{BE3B848C-1AB3-4F46-B1E1-210D020013F7}']
    function GetObra: IBizObra;
    procedure SetObra(const Value: IBizObra);
    property Obra: IBizObra read GetObra write SetObra;
  end;

  TfrViewObra = class(TfrViewBase, IViewObra)
    DADataSource: TDADataSource;
    dxLayoutControl1Group_Root: TdxLayoutGroup;
    dxLayoutControl1: TdxLayoutControl;
    dxLayoutControl1Item1: TdxLayoutItem;
    frViewDatosObra: TfrViewDatosObra;
    dxLayoutControl1Item2: TdxLayoutItem;
    frViewDireccion: TfrViewDireccion;
    frViewClienteObra: TfrViewDatosYSeleccionContacto;
    frViewCalculoHonorarios: TfrViewCalculoHonorarios;
    dxLayoutControl1Group2: TdxLayoutGroup;
    dxLayoutControl1Item4: TdxLayoutItem;
    dxLayoutControl1Group1: TdxLayoutGroup;
    dxLayoutControl1Item3: TdxLayoutItem;
  private
    FObra: IBizObra;
    function GetObra: IBizObra;
    procedure SetObra(const Value: IBizObra);
    procedure OnContactoChanged(Sender : TObject);
  public
    property Obra: IBizObra read GetObra write SetObra;
  end;

implementation

uses
  Dialogs, uDataModuleObras, uBizContacto;

{$R *.dfm}

{ TfrViewContactos }

{
******************************* TfrViewContacto ********************************
}

function TfrViewObra.GetObra: IBizObra;
begin
  Result := FObra;
end;

procedure TfrViewObra.OnContactoChanged(Sender: TObject);
begin
  FObra.Cliente := (frViewClienteObra.Contacto as IBizContacto)
end;

procedure TfrViewObra.SetObra(const Value: IBizObra);
begin
  FObra := Value;

  if Assigned(FObra) then
  begin
    DADataSource.DataTable := FObra.DataTable;
    frViewClienteObra.Contacto := FObra.Cliente;
    frViewClienteObra.OnContactoChanged := OnContactoChanged;
  end
  else
  begin
    DADataSource.DataTable := Nil;
    frViewClienteObra.OnContactoChanged := Nil;
  end;

  frViewDatosObra.DADataSource.DataTable := DADataSource.DataTable;
  frViewDireccion.DADataSource.DataTable := DADataSource.DataTable;
  frViewCalculoHonorarios.DADataSource.DataTable := DADataSource.DataTable;
end;

initialization
  RegisterClass(TfrViewObra);

finalization
  UnRegisterClass(TfrViewObra);

end.

