unit uViewDetallesAlbaranProveedor;

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, uBizAlbaranesProveedor, uDAInterfaces;

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

  TfrViewDetallesAlbaranProveedor = class(TfrViewDetallesArticulos, IViewDetallesAlbaranProveedor)
  protected
    FAlbaran: IBizAlbaranProveedor;
    function GetAlbaran: IBizAlbaranProveedor;
    procedure SetAlbaran(const Value: IBizAlbaranProveedor);

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

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

implementation
{$R *.dfm}

uses uDetallesAlbaranProveedorController, uViewDetallesBase;

{ TfrViewDetallesAlbaranProveedor }

function TfrViewDetallesAlbaranProveedor.AnadirArticulo(pReferencia: String; TipoReferencia: TEnumReferencia): Boolean;
begin
  if (Albaran.TIPO = CTE_TIPO_ALBARAN_DEV) then  
     Result := (Controller as IDetallesAlbaranProveedorController).AnadirArticulo(Detalles, pReferencia, TipoReferencia, -1, -1)  
  else  
     Result := (Controller as IDetallesAlbaranProveedorController).AnadirArticulo(Detalles, pReferencia, TipoReferencia);  
end;

procedure TfrViewDetallesAlbaranProveedor.AnadirArticulosInterno;
begin
  if (Albaran.TIPO = CTE_TIPO_ALBARAN_DEV) then  
    (Controller as IDetallesAlbaranProveedorController).AnadirArticulos(Detalles, Albaran.Proveedor, true, -1)  
  else  
    (Controller as IDetallesAlbaranProveedorController).AnadirArticulos(Detalles, Albaran.Proveedor);  
end;

function TfrViewDetallesAlbaranProveedor.GetAlbaran: IBizAlbaranProveedor;
begin
  Result := FAlbaran; 
end;

procedure TfrViewDetallesAlbaranProveedor.RellenarArticulosInterno;  
begin  
  if (Albaran.TIPO = CTE_TIPO_ALBARAN_DEV) then  
    (Controller as IDetallesAlbaranProveedorController).AnadirArticulos(Detalles, Albaran.Proveedor, False, -1)  
  else  
    (Controller as IDetallesAlbaranProveedorController).AnadirArticulos(Detalles, Albaran.Proveedor, False);  
end;  
   
procedure TfrViewDetallesAlbaranProveedor.SetAlbaran(const Value: IBizAlbaranProveedor);
begin
  FAlbaran := Value;
end;

end.
