unit uViewCobroCliente;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewBase, DB, uDADataTable, uCustomView,
  uViewDatosYSeleccionCliente, uBizCobrosCliente,
  cxControls, cxContainer, cxEdit, cxTextEdit, cxDBEdit, dxLayoutControl,
  cxMemo, cxMaskEdit, cxDropDownEdit, cxCalendar, cxSpinEdit, StdCtrls, Mask,
  DBCtrls, cxGraphics, cxCurrencyEdit;

type
  IViewCobroCliente = interface(IViewBase)
  ['{D51EE554-7810-4460-8552-3D5E28999715}']
    function GetCobro: IBizCobroCliente;
    procedure SetCobro(const Value: IBizCobroCliente);
    property Cobro: IBizCobroCliente read GetCobro write SetCobro;

    function GetViewClienteCobro: TfrViewDatosYSeleccionCliente;
    procedure SetViewClienteCobro(const Value: TfrViewDatosYSeleccioncliente);
    property ViewClienteCobro: TfrViewDatosYSeleccionCliente read GetViewClienteCobro write SetViewClienteCobro;
  end;

  TfrViewCobroCliente = class(TfrViewBase, IViewCobroCliente)
    DADataSource: TDADataSource;
    dxLayoutCobroClienteGroup_Root: TdxLayoutGroup;
    dxLayoutCobroCliente: TdxLayoutControl;
    dxLayoutCobroClienteItem1: TdxLayoutItem;
    eReferencia: TcxDBTextEdit;
    dxLayoutCobroClienteItem2: TdxLayoutItem;
    edtFecha: TcxDBDateEdit;
    dxLayoutCobroClienteGroup661: TdxLayoutGroup;
    dxLayoutCobroClienteGroup2: TdxLayoutGroup;
    dxLayoutCobroClienteItem6: TdxLayoutItem;
    frViewClienteCobro: TfrViewDatosYSeleccionCliente;
    dxLayoutCobroClienteItem3: TdxLayoutItem;
    memFormaPago: TcxDBMemo;
    dxLayoutCobroClienteItem4: TdxLayoutItem;
    cxCurrencyEdit5: TcxDBCurrencyEdit;
    dxLayoutCobroClienteGroup3: TdxLayoutGroup;
    dxLayoutCobroClienteGroup4: TdxLayoutGroup;
    dxLayoutCobroClienteGroup5: TdxLayoutGroup;
    dxLayoutCobroClienteGroup6: TdxLayoutGroup;
    procedure OnDestroy(Sender: TObject);
    procedure OnCreate(Sender: TObject);
  protected
    FCobro : IBizCobroCliente;
    FViewClienteCobro: TfrViewDatosYSeleccionCliente;

    function GetCobro: IBizCobroCliente;
    procedure SetCobro(const Value: IBizCobroCliente); virtual;
    function GetViewClienteCobro: TfrViewDatosYSeleccionCliente;
    procedure SetViewClienteCobro(const Value: TfrViewDatosYSeleccioncliente);
  public
    property Cobro: IBizCobroCliente read GetCobro write SetCobro;
    property ViewClienteCobro: TfrViewDatosYSeleccionCliente read GetViewClienteCobro;
  end;


implementation

uses uDataModuleContactos, schCobrosClienteClient_Intf;

{$R *.dfm}

{ TfrViewCobroCliente }

function TfrViewCobroCliente.GetCobro: IBizCobroCliente;
begin
  Result := FCobro;
end;

function TfrViewCobroCliente.GetViewClienteCobro: TfrViewDatosYSeleccionCliente;
begin
  Result := FViewClienteCobro;
end;

procedure TfrViewCobroCliente.OnCreate(Sender: TObject);
begin
  FViewClienteCobro := frViewClienteCobro;
  FViewClienteCobro.MsgElegirCliente := 'Elija el cliente al que se le realizará el cobro.';
end;

procedure TfrViewCobroCliente.OnDestroy(Sender: TObject);
begin
  FViewClienteCobro := Nil;
end;

procedure TfrViewCobroCliente.SetCobro(const Value: IBizCobroCliente);
begin
  FCobro := Value;
  if Assigned(FCobro) then
  begin
    DADataSource.DataTable := FCobro.DataTable;

    //Solo se deshabilita al insertar, luego la referencia será modificable
    eReferencia.Enabled := (FCobro.DataTable.State = dsInsert);
  end
  else
    DADataSource.DataTable := NIL;

  FViewClienteCobro.Cliente := FCobro.Cliente;
end;

procedure TfrViewCobroCliente.SetViewClienteCobro(const Value: TfrViewDatosYSeleccioncliente);
begin
  FViewClienteCobro := Value;
end;

end.
