This repository has been archived on 2024-12-02. You can view files and clone it, but cannot push or open issues or pull requests.
AlonsoYSal_FactuGES/Modulos/Albaranes de cliente/Cliente/uViewAlbaranesCliente.pas
2007-06-21 16:02:50 +00:00

157 lines
5.1 KiB
ObjectPascal

unit uViewAlbaranesCliente;
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,
uBizAlbaranesCliente, cxImage, Grids, DBGrids, cxCurrencyEdit, StdCtrls,
Buttons, cxRadioGroup, cxMaskEdit, cxDropDownEdit, cxCalendar,
cxContainer, TB2Dock, TBXDkPanels, uViewFiltroBase;
type
IViewAlbaranesCliente = interface(IViewGrid)
['{A490D8D4-B431-44D2-8AD7-BA74B40E98B7}']
procedure SyncFocusedRecord;
function GetAlbaranesCliente: IBizAlbaranesCliente;
procedure SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
property AlbaranesCliente: IBizAlbaranesCliente read GetAlbaranesCliente
write SetAlbaranesCliente;
end;
TfrViewAlbaranesCliente = class(TfrViewGrid, IViewAlbaranesCliente)
PngImageList: TPngImageList;
cxGridViewNOMBRE: TcxGridDBColumn;
cxGridViewFECHAALBARAN: TcxGridDBColumn;
cxGridViewSITUACION: TcxGridDBColumn;
cxGridViewFECHAPAGO: TcxGridDBColumn;
cxGridViewIMPORTETOTAL: TcxGridDBColumn;
cxGridViewREFERENCIA: TcxGridDBColumn;
cxGridViewCODIGO: TcxGridDBColumn;
cxGridViewICONO: TcxGridDBColumn;
cxGridLevel1: TcxGridLevel;
cxGridLevel2: TcxGridLevel;
cxGridViewREFERENCIAPRESUPUESTO: TcxGridDBColumn;
procedure cxGridViewCODIGOCustomDrawCell(Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
private
//Filtros relativos a la vista
procedure AnadirFiltroSituaciones;
procedure AnadirFiltroFechas;
protected
FAlbaranesCliente: IBizAlbaranesCliente;
function GetAlbaranesCliente: IBizAlbaranesCliente;
procedure SetAlbaranesCliente(const Value: IBizAlbaranesCliente);
procedure AnadirOtrosFiltros; override;
public
property AlbaranesCliente: IBizAlbaranesCliente read GetAlbaranesCliente write SetAlbaranesCliente;
procedure SyncFocusedRecord;
end;
var
frViewAlbaranesCliente: TfrViewAlbaranesCliente;
implementation
uses
uDataModuleAlbaranesCliente;
{$R *.dfm}
{ TfrViewAlbaranesCliente }
function TfrViewAlbaranesCliente.GetAlbaranesCliente: IBizAlbaranesCliente;
begin
Result := FAlbaranesCliente;
end;
procedure TfrViewAlbaranesCliente.SetAlbaranesCliente(
const Value: IBizAlbaranesCliente);
begin
FAlbaranesCliente := Value;
if Assigned(FAlbaranesCliente) then
DADataSource.DataTable := FAlbaranesCliente.DataTable;
end;
procedure TfrViewAlbaranesCliente.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 TfrViewAlbaranesCliente.SyncFocusedRecord;
begin
//
end;
procedure TfrViewAlbaranesCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
begin
inherited;
RefrescarFiltro;
end;
procedure TfrViewAlbaranesCliente.AnadirFiltroSituaciones;
var
FFiltro : TcxFilterCriteriaItemList;
begin
FFiltro := AddFilterGrid(fboAnd);
case cxGrid.ActiveLevel.Index of
1 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PENDIENTE, SITUACION_PENDIENTE);
2 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PAGADO, SITUACION_PAGADO);
end;
end;
procedure TfrViewAlbaranesCliente.AnadirFiltroFechas;
var
Columna: TcxGridDBColumn;
Fecha1, Fecha2: Variant;
FFiltro : TcxFilterCriteriaItemList;
begin
Fecha1 := frViewFiltroBase1.edtFechaIniFiltro.EditValue;
Fecha2 := frViewFiltroBase1.edtFechaFinFiltro.EditValue;
if not VarIsNull(Fecha1)
and not VarIsNull(Fecha2) then
begin
cxGridView.DataController.Filter.Options := [fcoCaseInsensitive, fcoSoftCompare];
FFiltro := AddFilterGrid(fboAnd);
Columna := (cxGridView as TcxGridDBTableView).GetColumnByFieldName('FECHAALBARAN');
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
end;
end;
procedure TfrViewAlbaranesCliente.AnadirOtrosFiltros;
begin
inherited;
AnadirFiltroSituaciones;
AnadirFiltroFechas;
//Finalmente activamos el filtro si tenemos algo
if cxGridView.DataController.Filter.IsEmpty
then cxGridView.DataController.Filter.Active := False
else cxGridView.DataController.Filter.Active := True;
cxGrid.ActiveLevel.GridView := cxGridView;
end;
end.