unit uViewRemesasCliente;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, uDADataTable, cxGridLevel,
  cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxGrid, uBizRemesasCliente, ActnList, Menus,
  cxGridBandedTableView, cxGridDBBandedTableView, JvComponent,
  JvFormAutoSize, PngImageList, ImgList, dxPSGlbl, dxPSUtl, dxPSEngn,
  dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
  dxPSEdgePatterns, cxIntlPrintSys3, dxPSCore, dxPScxCommon, dxPScxGrid6Lnk,
  cxGridCustomPopupMenu, cxGridPopupMenu, cxCurrencyEdit, cxSpinEdit, cxCheckBox,
  cxCheckComboBox, cxImageComboBox, TB2Item, TBX, TB2Toolbar, TBXDkPanels,
  TB2Dock, uViewFiltroBase, dxPgsDlg, uDAInterfaces, uCustomView, uViewBase;

type
  IViewRemesasCliente = interface(IViewGrid)
  ['{F18052A7-40A1-49F5-93A1-9544CB98DC0E}']
    function GetRemesasCliente: IBizRemesaCliente;
    procedure SetRemesasCliente(const Value: IBizRemesaCliente);
    property RemesasCliente: IBizRemesaCliente read GetRemesasCliente write SetRemesasCliente;
  end;

  TfrViewRemesasCliente = class(TfrViewGrid, IViewRemesasCliente)
    cxGridViewREFERENCIA: TcxGridDBColumn;
    cxGridViewFECHA_REMESA: TcxGridDBColumn;
    cxGridViewDESCRIPCION: TcxGridDBColumn;
    cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
    cxGridViewNOMBRE: TcxGridDBColumn;
    cxGridViewENTIDAD: TcxGridDBColumn;
    cxGridViewSUCURSAL: TcxGridDBColumn;
    cxGridViewDC: TcxGridDBColumn;
    cxGridViewCUENTA: TcxGridDBColumn;
    cxGridViewTIPO: TcxGridDBColumn;
    cxGridViewNUM_COPIAS: TcxGridDBColumn;
    procedure cxGridViewDataControllerCompare(
      ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
      AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
    procedure cxGridViewNUM_COPIASCustomDrawHeader(Sender: TcxGridTableView;
      ACanvas: TcxCanvas; AViewInfo: TcxGridColumnHeaderViewInfo;
      var ADone: Boolean);
  protected
    FRemesasCliente: IBizRemesaCliente;
    function GetRemesasCliente: IBizRemesaCliente; virtual;
    procedure SetRemesasCliente(const Value: IBizRemesaCliente); virtual;
  public
    property RemesasCliente: IBizRemesaCliente read GetRemesasCliente write SetRemesasCliente;
  end;

implementation

uses
  uDataModuleRemesasCliente, uReferenciasUtils, cxVariants;


{$R *.dfm}

{ TfrViewRemesasCliente }

{
******************************* TfrViewRemesasCliente *******************************
}
procedure TfrViewRemesasCliente.cxGridViewDataControllerCompare(
  ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
  AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
begin
  inherited;
  if ((AItemIndex = cxGridViewREFERENCIA.Index)) and
     (VarType(V1) = VarType(V2)) and (VarType(V1) = varString) then
    Compare := CompararReferencias(V1, V2)
  else
    Compare := VarCompare(V1, V2);
end;

procedure TfrViewRemesasCliente.cxGridViewNUM_COPIASCustomDrawHeader(
  Sender: TcxGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridColumnHeaderViewInfo; var ADone: Boolean);
var
  R : TRect;
begin
  inherited;
  with AViewInfo do
  begin
    LookAndFeelPainter.DrawHeader(ACanvas, Bounds, TextAreaBounds, Neighbors,
      Borders, ButtonState, AlignmentHorz, AlignmentVert, MultiLine,
      False, '', Params.Font, Params.TextColor, Params.Color);

    R := AViewInfo.ContentBounds;
    ACanvas.FillRect(R);
    ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top, 1);
  end;

  ADone := True;
end;

function TfrViewRemesasCliente.GetRemesasCliente: IBizRemesaCliente;
begin
  Result := FRemesasCliente;
end;

procedure TfrViewRemesasCliente.SetRemesasCliente(const Value: IBizRemesaCliente);
begin
  FRemesasCliente := Value;
  if Assigned(FRemesasCliente) then
    dsDataSource.DataTable := FRemesasCliente.DataTable;
end;

end.
