262 lines
9.0 KiB
ObjectPascal
262 lines
9.0 KiB
ObjectPascal
unit uViewPresupuestosCliente;
|
||
|
||
interface
|
||
|
||
uses
|
||
uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl, dxPSEngn,
|
||
dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
|
||
dxPSEdgePatterns, cxImageComboBox, ImgList, Controls, PngImageList,
|
||
cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxGridCustomPopupMenu, cxGridPopupMenu, dxPSCore, dxPScxCommon, dxPScxGridLnk,
|
||
uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView, Classes,
|
||
cxGrid,
|
||
uBizPresupuestosCliente, cxCurrencyEdit, Forms, uViewFiltroBase, ActnList, TB2Item,
|
||
TBX, TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces;
|
||
|
||
type
|
||
IViewPresupuestosCliente = interface(IViewGrid)
|
||
['{96821714-55CF-4BC1-A0C1-16E027B2EF16}']
|
||
function GetPresupuestos: IBizPresupuestoCliente;
|
||
procedure SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
property Presupuestos: IBizPresupuestoCliente read GetPresupuestos write SetPresupuestos;
|
||
end;
|
||
|
||
TfrViewPresupuestosCliente = class(TfrViewGrid, IViewPresupuestosCliente)
|
||
cxGridDBTableView1: TcxGridDBTableView;
|
||
PngImageList: TPngImageList;
|
||
cxGridViewID: TcxGridDBColumn;
|
||
cxGridViewREFERENCIA: TcxGridDBColumn;
|
||
cxGridViewINCIDENCIASACTIVAS: TcxGridDBColumn;
|
||
cxGridViewNOMBRE: TcxGridDBColumn;
|
||
cxGridViewSITUACION: TcxGridDBColumn;
|
||
cxGridViewFECHA_PRESUPUESTO: TcxGridDBColumn;
|
||
cxGridViewCLIENTE_FINAL: TcxGridDBColumn;
|
||
cxGridViewFACTURA: TcxGridDBColumn;
|
||
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
||
cxGridLevelPendientes: TcxGridLevel;
|
||
cxGridLevelEnProceso: TcxGridLevel;
|
||
cxGridLevelServidor: TcxGridLevel;
|
||
cxStylePENDIENTES: TcxStyle;
|
||
cxStyleENPROCESO: TcxStyle;
|
||
cxStyleSERVIDOS: TcxStyle;
|
||
actCliente: TAction;
|
||
actProvincia: TAction;
|
||
TBXItem2: TTBXItem;
|
||
TBXSeparatorItem1: TTBXSeparatorItem;
|
||
TBXSeparatorItem2: TTBXSeparatorItem;
|
||
TBXItem3: TTBXItem;
|
||
cxGridViewFECHA_DECISION: TcxGridDBColumn;
|
||
cxGridViewNIF_CIF: TcxGridDBColumn;
|
||
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel:
|
||
TcxGridLevel);
|
||
procedure cxGridViewCODIGOCustomDrawCell(Sender: TcxCustomGridTableView;
|
||
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var
|
||
ADone: Boolean);
|
||
procedure cxGridViewStylesGetContentStyle(Sender: TcxCustomGridTableView;
|
||
ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out
|
||
AStyle: TcxStyle);
|
||
procedure actClienteExecute(Sender: TObject);
|
||
procedure actClienteUpdate(Sender: TObject);
|
||
procedure actProvinciaExecute(Sender: TObject);
|
||
procedure actProvinciaUpdate(Sender: TObject);
|
||
procedure cxGridViewMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||
Y: Integer);
|
||
|
||
private
|
||
//Filtros relativos a la vista
|
||
procedure AnadirFiltroSituaciones;
|
||
procedure AnadirFiltroFechas;
|
||
|
||
protected
|
||
FPresupuestos: IBizPresupuestoCliente;
|
||
function GetPresupuestos: IBizPresupuestoCliente;
|
||
procedure SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
public
|
||
procedure AnadirOtrosFiltros; override;
|
||
property Presupuestos: IBizPresupuestoCliente read GetPresupuestos write SetPresupuestos;
|
||
end;
|
||
|
||
implementation
|
||
|
||
uses SysUtils, variants, windows, uDataModulePresupuestosCliente, schPresupuestosClienteClient_Intf,
|
||
uViewGridBase;
|
||
|
||
{$R *.dfm}
|
||
|
||
procedure TfrViewPresupuestosCliente.actClienteExecute(Sender: TObject);
|
||
begin
|
||
if (cxGridViewNOMBRE.GroupIndex < 0) then
|
||
begin
|
||
cxGridViewNOMBRE.GroupIndex := cxGridView.GroupedColumnCount;
|
||
cxGridViewNOMBRE.Visible := False;
|
||
end
|
||
else
|
||
begin
|
||
cxGridViewNOMBRE.GroupIndex := -1;
|
||
cxGridViewNOMBRE.Visible := True;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actClienteUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
(Sender as TAction).Checked := not (cxGridViewNOMBRE.GroupIndex < 0);
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actProvinciaExecute(Sender: TObject);
|
||
begin
|
||
{
|
||
if (cxGridViewPROVINCIA.GroupIndex < 0) then
|
||
begin
|
||
cxGridViewPROVINCIA.GroupIndex := cxGridView.GroupedColumnCount;
|
||
cxGridViewPROVINCIA.Visible := False;
|
||
end
|
||
else
|
||
begin
|
||
cxGridViewPROVINCIA.GroupIndex := -1;
|
||
cxGridViewPROVINCIA.Visible := True;
|
||
end;
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.actProvinciaUpdate(Sender: TObject);
|
||
begin
|
||
{
|
||
inherited;
|
||
(Sender as TAction).Checked := not (cxGridViewPROVINCIA.GroupIndex < 0);
|
||
}
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.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('FECHA_Presupuesto');
|
||
FFiltro.AddItem(Columna, foBetween, varArrayOf([Fecha1, Fecha2]), VarToStr(Fecha1) + ' and ' + VarToStr(Fecha2));
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.AnadirFiltroSituaciones;
|
||
var
|
||
FFiltro : TcxFilterCriteriaItemList;
|
||
begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
|
||
case cxGrid.ActiveLevel.Index of
|
||
1 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_PENDIENTE, SITUACION_PRESUPUESTO_PENDIENTE);
|
||
2 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_ACEPTADO, SITUACION_PRESUPUESTO_ACEPTADO);
|
||
3 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_PRESUPUESTO_ANULADO, SITUACION_PRESUPUESTO_ANULADO);
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.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;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
||
begin
|
||
inherited;
|
||
RefrescarFiltro;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.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 TfrViewPresupuestosCliente.cxGridViewMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
|
||
var
|
||
Site : TcxGridSite;
|
||
HitTest : TcxCustomGridHitTest;
|
||
Item : TcxCustomGridTableItem;
|
||
Rec : TcxCustomGridRecord;
|
||
sNewHint : string;
|
||
begin
|
||
{Este m<>todo desaparecer<65> cuando se migre la aplicaci<63>n, es para sacar la causa de la incidencia sin necesidad de entrar en el documento}
|
||
Site := Sender as TcxGridSite;
|
||
HitTest := Site.GridView.ViewInfo.GetHitTest(X, Y);
|
||
if HitTest is TcxGridRecordCellHitTest then begin
|
||
Item := TcxGridRecordCellHitTest(HitTest).Item;
|
||
Rec := TcxGridRecordCellHitTest(HitTest).GridRecord;
|
||
|
||
if (Item.Index = cxGridView.GetColumnByFieldName(fld_PresupuestosClienteINCIDENCIAS_ACTIVAS).Index)
|
||
and (Rec.Selected)
|
||
and (Presupuestos.DataTable.FieldByName(fld_PresupuestosClienteINCIDENCIAS_ACTIVAS).AsInteger = 1) then begin
|
||
sNewHint := Presupuestos.DataTable.FieldByName(fld_PresupuestosClienteINCIDENCIAS).AsString;
|
||
if (cxGrid.Hint <> sNewHint) then begin
|
||
cxGrid.ShowHint := false;
|
||
cxGrid.Hint := sNewHint;
|
||
end
|
||
else cxGrid.ShowHint := true;
|
||
end
|
||
else begin
|
||
cxGrid.ShowHint := false;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewStylesGetContentStyle(Sender:
|
||
TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem:
|
||
TcxCustomGridTableItem; out AStyle: TcxStyle);
|
||
var
|
||
IndiceCol: Integer;
|
||
ASituacion: string;
|
||
begin
|
||
inherited;
|
||
if Assigned(ARecord) then
|
||
begin
|
||
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_PresupuestosClienteSITUACION).Index;
|
||
ASituacion := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
||
if ASituacion = SITUACION_PRESUPUESTO_PENDIENTE then
|
||
AStyle := cxStylePENDIENTES
|
||
else if ASituacion = SITUACION_PRESUPUESTO_ACEPTADO then
|
||
AStyle := cxStyleENPROCESO
|
||
else if ASituacion = SITUACION_PRESUPUESTO_ANULADO then
|
||
AStyle := cxStyleSERVIDOS;
|
||
end;
|
||
end;
|
||
|
||
function TfrViewPresupuestosCliente.GetPresupuestos: IBizPresupuestoCliente;
|
||
begin
|
||
Result := FPresupuestos;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.SetPresupuestos(const Value: IBizPresupuestoCliente);
|
||
begin
|
||
FPresupuestos := Value;
|
||
if Assigned(FPresupuestos) then
|
||
dsDataSource.DataTable := FPresupuestos.DataTable;
|
||
end;
|
||
|
||
end.
|