unit uViewFacturasCliente; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uViewGrid, uViewPreview, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl, dxPSEngn, dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns, dxPSEdgePatterns, cxImageComboBox, cxTextEdit, ImgList, PngImageList, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, dxPSCore, dxPScxCommon, dxPScxGridLnk, ActnList, uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid, cxImage, Grids, DBGrids, uBizFacturasCliente; type IViewFacturasCliente = interface(IViewGrid) ['{0B893BAC-967F-45BD-BD74-B1B78662FCFC}'] procedure SyncFocusedRecord; function GetFacturasCliente: IBizFacturasCliente; procedure SetFacturasCliente(const Value: IBizFacturasCliente); property FacturasCliente: IBizFacturasCliente read GetFacturasCliente write SetFacturasCliente; procedure FiltrarPorFechas(const Fecha1, Fecha2: Variant); end; TfrViewFacturasCliente = class(TfrViewGrid, IViewFacturasCliente) PngImageList: TPngImageList; cxGridViewNOMBRE: TcxGridDBColumn; cxGridViewFECHAFACTURA: TcxGridDBColumn; cxGridViewNIFCIF: TcxGridDBColumn; cxGridViewIMPORTETOTAL: TcxGridDBColumn; cxGridViewREFERENCIA: TcxGridDBColumn; cxGridViewCODIGO: TcxGridDBColumn; cxGridViewICONO: TcxGridDBColumn; procedure cxGridViewCODIGOCustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); private protected FFacturasCliente: IBizFacturasCliente; function GetFacturasCliente: IBizFacturasCliente; procedure SetFacturasCliente(const Value: IBizFacturasCliente); public procedure FiltrarPorFechas(const Fecha1, Fecha2: Variant); procedure SyncFocusedRecord; property FacturasCliente: IBizFacturasCliente read GetFacturasCliente write SetFacturasCliente; end; var frViewFacturasCliente: TfrViewFacturasCliente; implementation uses uDataModuleFacturasCliente; {$R *.dfm} { TfrViewFacturasCliente } function TfrViewFacturasCliente.GetFacturasCliente: IBizFacturasCliente; begin Result := FFacturasCliente; end; procedure TfrViewFacturasCliente.SetFacturasCliente( const Value: IBizFacturasCliente); begin FFacturasCliente := Value; if Assigned(FFacturasCliente) then DADataSource.DataTable := FFacturasCliente.DataTable; end; procedure TfrViewFacturasCliente.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, 2); ADone := True; end; procedure TfrViewFacturasCliente.SyncFocusedRecord; begin // end; procedure TfrViewFacturasCliente.FiltrarPorFechas(const Fecha1, Fecha2: Variant); var Columna: TcxGridDBColumn; begin with cxGridView.DataController.Filter do begin BeginUpdate; try Options := [fcoCaseInsensitive, fcoSoftCompare]; Root.Clear; if not VarIsNull(Fecha1) and not VarIsNull(Fecha2) then begin Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHAFACTURA'); Root.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2)); Active := True; end else Active := False; finally EndUpdate; end; end; end; end.