unit uViewContactos;

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, uBizContactos, ActnList, Menus,
  cxGridBandedTableView, cxGridDBBandedTableView, JvComponent,
  JvFormAutoSize, PngImageList, ImgList, dxPSGlbl, dxPSUtl, dxPSEngn,
  dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
  dxPSEdgePatterns, cxIntlPrintSys3, dxPSCore, dxPScxCommon, dxPScxGridLnk,
  udatamoduleclientes, cxGridCustomPopupMenu, cxGridPopupMenu;

type
  IViewContactos = interface(IViewGrid)
    ['{9E43DEE1-F72B-4C93-8592-1C7DF01E293D}']
    function GetContactos: IBizContacto;
    procedure SetContactos(const Value: IBizContacto);
    property Contactos: IBizContacto read GetContactos write SetContactos;
  end;

  TfrViewContactos = class(TfrViewGrid, IViewContactos)
    PngImageList: TPngImageList;
    cxGridViewICONO: TcxGridDBColumn;
    cxGridViewNIF_CIF: TcxGridDBColumn;
    cxGridViewNOMBRE: TcxGridDBColumn;
    cxGridViewCALLE: TcxGridDBColumn;
    cxGridViewPOBLACION: TcxGridDBColumn;
    cxGridViewPROVINCIA: TcxGridDBColumn;
    cxGridViewCODIGO_POSTAL: TcxGridDBColumn;
    cxGridViewTELEFONO_1: TcxGridDBColumn;
    cxGridViewTELEFONO_2: TcxGridDBColumn;
    cxGridViewMOVIL_1: TcxGridDBColumn;
    cxGridViewFAX: TcxGridDBColumn;
    cxGridViewEMAIL_1: TcxGridDBColumn;
    cxGridViewEMAIL_2: TcxGridDBColumn;
    cxGridViewPAGINA_WEB: TcxGridDBColumn;
    procedure cxGridViewCODIGOCustomDrawCell(
      Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
      AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
  protected
    FContactos: IBizContacto;
    function GetContactos: IBizContacto; virtual;
    procedure SetContactos(const Value: IBizContacto); virtual;
  public
    property DataSet: IBizContacto read GetContactos write SetContactos;
  end;

implementation

{$R *.dfm}

{ TfrViewClientes }

{
******************************* TfrViewContactos *******************************
}
function TfrViewContactos.GetContactos: IBizContacto;
begin
  Result := FContactos;
end;

procedure TfrViewContactos.SetContactos(const Value: IBizContacto);
begin
  FContactos := Value;
  if Assigned(FContactos) then
    dsDataSource.DataTable := FContactos.DataTable;
end;


procedure TfrViewContactos.cxGridViewCODIGOCustomDrawCell(
  Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
  AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
var
  R : TRect;
begin
  inherited;
  R := AViewInfo.ContentBounds;
  ACanvas.FillRect(R);
  ACanvas.DrawImage(PngImageList, R.Left, R.Top, 0);
  ADone := True;
end;

end.
