unit uEditorFacturaObra;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uEditorFacturaCliente, dxLayoutLookAndFeels, JvAppStorage,
  JvAppRegistryStorage, DB, uDADataTable, JvComponentBase, JvFormPlacement,
  ImgList, PngImageList, StdActns, ActnList, uViewTotales, ComCtrls,
  uViewContenido, uViewDetallesFamilias, uViewDetallesFacturaCliente,
  dxLayoutControl, uCustomView, uViewBase, uViewFacturaCliente, TBX,
  TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls, JvExControls,
  JvComponent, JvNavigationPane, uViewObraRelacionada, uBizFacturasCliente;

type
  IEditorFacturaObra = interface(IEditorFacturaCliente)
  ['{E22C6D3D-0AD0-453D-B795-BFD2F638AE7B}']
  end;

  TfEditorFacturaObra = class(TfEditorFacturaCliente, IEditorFacturaObra)
    frViewObraRelacionada1: TfrViewObraRelacionada;
  private
    procedure OnObraChanged(Sender : TObject);
  protected
    procedure SetFacturaCliente(const Value: IBizFacturasCliente); override;
  end;

implementation
{$R *.dfm}

uses uDataTableUtils, uEditorUtils, LiteralesObrasFinal, uBizObraFinal;

function ShowEditorFacturaObra (ABizObject : TDADataTableRules) : TModalResult;
var
  AEditor: TfEditorFacturaObra;
begin
  AEditor := TfEditorFacturaObra.Create(Application);
  try
    AEditor.FacturaCliente := (ABizObject as IBizFacturasObras);
    Result := AEditor.ShowModal;
  finally
    AEditor.Release;
  end;
end;

{ TfEditorFacturaObra }

procedure TfEditorFacturaObra.OnObraChanged(Sender: TObject);
begin
  (FacturaCliente as IBizFacturasObras).Obra := frViewObraRelacionada1.Obra;
end;

procedure TfEditorFacturaObra.SetFacturaCliente(const Value: IBizFacturasCliente);
begin
  inherited;
  frViewObraRelacionada1.Obra := (FacturaCliente as IBizFacturasObras).Obra;
  frViewObraRelacionada1.OnObraChanged := OnObraChanged;
end;

initialization
  RegisterEditor(IBizFacturasObras, ShowEditorFacturaObra, etItem);

end.
