unit uViewComision;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewBase, ExtCtrls, StdCtrls, Buttons, DB, uDADataTable,
  DBCtrls, Grids, DBGrids, Mask, ComCtrls, uCustomView, JvComponent,
  JvFormAutoSize, cxControls, cxContainer, cxEdit, cxTextEdit,
  cxDBEdit, dxLayoutControl, cxCheckBox, PngSpeedButton, cxImage, ActnList,
  ImgList, PngImageList, cxGraphics, cxMaskEdit, cxDropDownEdit,
  uComisionesController, cxSpinEdit, cxCurrencyEdit,
  uBizComisiones, cxCalendar,
  dxLayoutLookAndFeels, cxLookupEdit, cxDBLookupEdit, cxDBLookupComboBox,
  uDAInterfaces;

type
  IViewComision = interface(IViewBase)
  ['{5EA82BD9-550C-426F-AEBB-A48B396CB4B4}']
    function GetComision: IBizComisiones;
    procedure SetComision(const Value: IBizComisiones);
    property Comision: IBizComisiones read GetComision write SetComision;
  end;

  TfrViewComision = class(TfrViewBase, IViewComision)
    dsDataTable: TDADataSource;
    eReferencia: TcxDBTextEdit;
    eDescripcion: TcxDBTextEdit;
    edtFecha: TcxDBDateEdit;
    dxLayoutControlComision: TdxLayoutControl;
    dxLayoutLookAndFeelList1: TdxLayoutLookAndFeelList;
    dxLayoutOfficeLookAndFeel1: TdxLayoutOfficeLookAndFeel;
    dxLayoutControlComisionItem1: TdxLayoutItem;
    cbAgente: TcxDBLookupComboBox;
    dsAgentes: TDADataSource;
    procedure CustomViewShow(Sender: TObject);
    procedure CustomViewDestroy(Sender: TObject);

  protected
    FComision: IBizComisiones;
    function GetComision: IBizComisiones;
    procedure SetComision(const Value: IBizComisiones); virtual;
  public
    property Comision: IBizComisiones read GetComision write SetComision;
  end;

implementation

{$R *.dfm}

uses
  uDataModuleUsuarios,
  //uAgentesController,
  uBizContactos;


{ TfrViewComisions }

{
******************************* TfrViewComisions ********************************
}

procedure TfrViewComision.CustomViewDestroy(Sender: TObject);
begin
  dsAgentes.DataTable := Nil;
  inherited;
end;

procedure TfrViewComision.CustomViewShow(Sender: TObject);
//Var
//  AAgentes: IBizContacto;
//  FAgentesController: IAgentesController;
begin
  inherited;
{  try
  FAgentesController := TAgentesController.Create;
  AAgentes := FAgentesController.BuscarTodos;
  AAgentes.DataTable.Active := True;
  dsAgentes.DataTable := AAgentes.DataTable;
  finally
    AAgentes := Nil;
    FAgentesController := Nil;
  end;
}  
end;

function TfrViewComision.GetComision: IBizComisiones;
begin
  Result := FComision;
end;

procedure TfrViewComision.SetComision(const Value: IBizComisiones);
begin
  FComision := Value;

  if Assigned(FComision) then
     dsDataTable.DataTable := FComision.DataTable
  else
     dsDataTable.DataTable := NIL;
end;

end.

