unit uViewDetallesAlbaranCliente;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewDetallesArticulos, cxStyles, cxCustomData, cxGraphics, cxFilter,
  cxData, cxDataStorage, cxEdit, DB, cxDBData, ImgList, PngImageList,
  uDADataTable, ActnList, ComCtrls, ToolWin, cxGridLevel, cxClasses, cxControls,
  cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGrid, cxImageComboBox, cxTextEdit, cxMaskEdit, cxCheckBox, cxCurrencyEdit,
  Grids, DBGrids, StdCtrls, ExtCtrls, cxRichEdit, ExtActns, StdActns,
  JvExStdCtrls, JvCombobox, JvColorCombo, TB2Item, TBX, TB2Dock, TB2Toolbar,
  uControllerDetallesArticulos, uBizAlbaranesCliente, cxDropDownEdit,
  cxCalendar, cxDBEdit, dxLayoutControl, cxContainer, cxLookupEdit,
  cxDBLookupEdit, cxDBLookupComboBox;

type
  IViewDetallesAlbaranCliente = interface(IViewDetallesArticulos)
  ['{9326E1A0-BD5E-4BE1-BB3B-6A52C3394118}']
    function GetAlbaran: IBizAlbaranCliente;
    procedure SetAlbaran(const Value: IBizAlbaranCliente);
    property Albaran: IBizAlbaranCliente read GetAlbaran write SetAlbaran;
  end;

  TfrViewDetallesAlbaranCliente = class(TfrViewDetallesArticulos, IViewDetallesAlbaranCliente)
  protected
    FAlbaran: IBizAlbaranCliente;
    function GetAlbaran: IBizAlbaranCliente;
    procedure SetAlbaran(const Value: IBizAlbaranCliente);

    procedure AnadirArticulosInterno; override;
    function AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean; override;

  public
    property Albaran: IBizAlbaranCliente read GetAlbaran write SetAlbaran;
  end;

implementation
{$R *.dfm}

uses uDetallesAlbaranClienteController, uViewDetallesBase;

{ TfrViewDetallesAlbaranProveedor }

function TfrViewDetallesAlbaranCliente.AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean;
begin
  Result := (Controller as IDetallesAlbaranClienteController).AnadirArticulo(Detalles, pReferencia, TipoReferencia);

  if (Albaran.TIPO = CTE_TIPO_ALBARAN_DEV) then
     (Controller as IDetallesAlbaranClienteController).CambiarSignoDetalles(Detalles);
end;

procedure TfrViewDetallesAlbaranCliente.AnadirArticulosInterno;
begin
  (Controller as IDetallesAlbaranClienteController).AnadirArticulos(Detalles, Albaran.Cliente);

  if (Albaran.TIPO = CTE_TIPO_ALBARAN_DEV) then
     (Controller as IDetallesAlbaranClienteController).CambiarSignoDetalles(Detalles);
end;

function TfrViewDetallesAlbaranCliente.GetAlbaran: IBizAlbaranCliente;
begin
  Result := FAlbaran; 
end;

procedure TfrViewDetallesAlbaranCliente.SetAlbaran(const Value: IBizAlbaranCliente);
begin
  FAlbaran := Value;
end;

end.
