git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@1117 0c75b7a4-871f-7646-8a2f-f78d34cc349f
426 lines
14 KiB
ObjectPascal
426 lines
14 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, dxPScxGrid6Lnk,
|
||
uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView, Classes,
|
||
cxGrid, uBizPresupuestosCliente, cxCurrencyEdit, Forms, uViewFiltroBase, ActnList, TB2Item,
|
||
TBX, TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces, Windows,
|
||
uCustomView, uViewBase;
|
||
|
||
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;
|
||
cxGridViewREFERENCIA: TcxGridDBColumn;
|
||
cxGridViewINCIDENCIASACTIVAS: TcxGridDBColumn;
|
||
cxGridViewNOMBRE: TcxGridDBColumn;
|
||
cxGridViewSITUACION: TcxGridDBColumn;
|
||
cxGridViewFECHA_PRESUPUESTO: TcxGridDBColumn;
|
||
cxGridViewCLIENTE_FINAL: TcxGridDBColumn;
|
||
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
||
cxGridLevelPendientes: TcxGridLevel;
|
||
cxGridLevelEnProceso: TcxGridLevel;
|
||
cxGridLevelServidor: TcxGridLevel;
|
||
cxStylePENDIENTES: TcxStyle;
|
||
cxStyleACEPTADO: TcxStyle;
|
||
actCliente: TAction;
|
||
actProvincia: TAction;
|
||
TBXItem2: TTBXItem;
|
||
TBXSeparatorItem1: TTBXSeparatorItem;
|
||
TBXSeparatorItem2: TTBXSeparatorItem;
|
||
TBXItem3: TTBXItem;
|
||
cxGridViewFECHA_DECISION: TcxGridDBColumn;
|
||
cxGridViewNIF_CIF: TcxGridDBColumn;
|
||
cxGridViewINCIDENCIAS: TcxGridDBColumn;
|
||
cxStyleRECHAZADO: TcxStyle;
|
||
cxGridViewCERTIFICADO_ISO: TcxGridDBColumn;
|
||
cxGridViewNUM_FACTURAS: TcxGridDBColumn;
|
||
cxStyleConFacturas: TcxStyle;
|
||
cxGridViewPRESUPUESTO_WEB: TcxGridDBColumn;
|
||
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel:
|
||
TcxGridLevel);
|
||
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 cxGridViewICONOCustomDrawCell(Sender: TcxCustomGridTableView;
|
||
ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo;
|
||
var ADone: Boolean);
|
||
procedure cxGridViewINCIDENCIASACTIVASGetCellHint(
|
||
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
|
||
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
|
||
var AHintTextRect: TRect);
|
||
procedure cxGridViewDataControllerCompare(
|
||
ADataController: TcxCustomDataController; ARecordIndex1, ARecordIndex2,
|
||
AItemIndex: Integer; const V1, V2: Variant; var Compare: Integer);
|
||
procedure OnFiltroListaPropertiesChange(Sender: TObject);
|
||
procedure OnFiltroListaPropertiesInitPopup(Sender: TObject);
|
||
procedure OnFiltroListaISOPropertiesChange(Sender: TObject);
|
||
procedure OnFiltroListaISOPropertiesInitPopup(Sender: TObject);
|
||
|
||
procedure CustomViewDestroy(Sender: TObject);
|
||
procedure CustomViewShow(Sender: TObject);
|
||
procedure frViewFiltroBase1actQuitarFiltroExecute(Sender: TObject);
|
||
|
||
private
|
||
//Filtros relativos a la vista
|
||
procedure AnadirFiltroSituaciones;
|
||
procedure AnadirFiltroFechas;
|
||
// procedure AnadirFiltroFacturado;
|
||
procedure AnadirFiltroISO;
|
||
|
||
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, uDataModulePresupuestosCliente, schPresupuestosClienteClient_Intf,
|
||
uViewGridBase, uReferenciasUtils, cxVariants, uStringsUtils;
|
||
|
||
{$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.AnadirFiltroISO;
|
||
var
|
||
FFiltro : TcxFilterCriteriaItemList;
|
||
begin
|
||
//Solo se aplica este filtro en el caso de tener activo el panel de detalle de filtro
|
||
//y sobre la lista de presupuestos de cliente
|
||
if frViewFiltroBase1.Visible then
|
||
begin
|
||
case frViewFiltroBase1.eLista2.ItemIndex of
|
||
//Con ISO
|
||
1 : begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
FFiltro.AddItem(cxGridViewCERTIFICADO_ISO, foEqual, '1', 'ConISO');
|
||
end;
|
||
|
||
//SIN ISO
|
||
2: begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
FFiltro.AddItem(cxGridViewCERTIFICADO_ISO, foEqual, '0', 'SinISO');
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
end;
|
||
|
||
{
|
||
procedure TfrViewPresupuestosCliente.AnadirFiltroFacturado;
|
||
var
|
||
FFiltro : TcxFilterCriteriaItemList;
|
||
begin
|
||
//Solo se aplica este filtro en el caso de tener activo el panel de detalle de filtro
|
||
//y sobre la lista de articulos detallada por proveedor
|
||
if frViewFiltroBase1.Visible then
|
||
begin
|
||
case frViewFiltroBase1.eLista.ItemIndex of
|
||
//Sin facturar
|
||
1 : begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
FFiltro.AddItem(cxGridViewFACTURA, foEqual, NULL, 'NoFacturado');
|
||
end;
|
||
|
||
//Facturados
|
||
2: begin
|
||
FFiltro := AddFilterGrid(fboAnd);
|
||
FFiltro.AddItem(cxGridViewFACTURA, foNotEqual, NULL, 'Facturado');
|
||
end;
|
||
end;
|
||
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;
|
||
// AnadirFiltroFacturado;
|
||
AnadirFiltroISO;
|
||
|
||
//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.CustomViewDestroy(Sender: TObject);
|
||
begin
|
||
frViewFiltroBase1.eLista.Properties.OnChange := Nil;
|
||
frViewFiltroBase1.eLista.Properties.OnInitPopup := Nil;
|
||
frViewFiltroBase1.eLista2.Properties.OnChange := Nil;
|
||
frViewFiltroBase1.eLista2.Properties.OnInitPopup := Nil;
|
||
|
||
inherited;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.CustomViewShow(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
frViewFiltroBase1.eLista.Properties.OnChange := OnFiltroListaPropertiesChange;
|
||
frViewFiltroBase1.eLista.Properties.OnInitPopup := OnFiltroListaPropertiesInitPopup;
|
||
frViewFiltroBase1.eLista2.Properties.OnChange := OnFiltroListaISOPropertiesChange;
|
||
frViewFiltroBase1.eLista2.Properties.OnInitPopup := OnFiltroListaISOPropertiesInitPopup;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
||
begin
|
||
inherited;
|
||
RefrescarFiltro;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.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 TfrViewPresupuestosCliente.cxGridViewICONOCustomDrawCell(
|
||
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
||
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
||
var
|
||
R : TRect;
|
||
begin
|
||
inherited;
|
||
R := AViewInfo.ContentBounds;
|
||
ACanvas.FillRect(R);
|
||
|
||
if (cxGridView.DataController.DisplayTexts[AViewInfo.GridRecord.RecordIndex,
|
||
cxGridViewINCIDENCIASACTIVAS.Index] <> 'Sin incidencias') then
|
||
ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top + 2, 2)
|
||
else if (cxGridView.DataController.DisplayTexts[AViewInfo.GridRecord.RecordIndex,
|
||
cxGridViewCERTIFICADO_ISO.Index] = 'ISO') then
|
||
ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top + 2, 4)
|
||
else
|
||
ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top + 2, 1);
|
||
|
||
ADone := True;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewINCIDENCIASACTIVASGetCellHint(
|
||
Sender: TcxCustomGridTableItem; ARecord: TcxCustomGridRecord;
|
||
ACellViewInfo: TcxGridTableDataCellViewInfo; const AMousePos: TPoint;
|
||
var AHintText: TCaption; var AIsHintMultiLine: Boolean;
|
||
var AHintTextRect: TRect);
|
||
begin
|
||
inherited;
|
||
if (ARecord.DisplayTexts[Sender.Index] <> 'Sin incidencias') then
|
||
begin
|
||
AIsHintMultiLine := True;
|
||
if not VarIsNull(ARecord.Values[cxGridViewINCIDENCIAS.Index]) then
|
||
AHintText := ARecord.Values[cxGridViewINCIDENCIAS.Index];
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.cxGridViewStylesGetContentStyle(Sender:
|
||
TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem:
|
||
TcxCustomGridTableItem; out AStyle: TcxStyle);
|
||
var
|
||
IndiceCol: Integer;
|
||
ASituacion: string;
|
||
AFacturas: 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.TextColor := cxStylePENDIENTES.TextColor
|
||
else if ASituacion = SITUACION_PRESUPUESTO_ACEPTADO then
|
||
begin
|
||
AStyle.TextColor := cxStyleACEPTADO.TextColor;
|
||
//Si est<73> aceptado y no facturado que resalte
|
||
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_PresupuestosClienteNUM_FACTURA).Index;
|
||
AFacturas := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
||
if EsCadenaVacia(AFacturas) then
|
||
AStyle.TextColor := cxStyleConFacturas.TextColor;
|
||
end
|
||
else if ASituacion = SITUACION_PRESUPUESTO_ANULADO then
|
||
AStyle.TextColor := cxStyleRECHAZADO.TextColor;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.frViewFiltroBase1actQuitarFiltroExecute(Sender: TObject);
|
||
begin
|
||
frViewFiltroBase1.txtFiltroTodo.Clear;
|
||
frViewFiltroBase1.eLista.Clear;
|
||
frViewFiltroBase1.eLista2.Clear;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.OnFiltroListaISOPropertiesChange(
|
||
Sender: TObject);
|
||
begin
|
||
inherited;
|
||
RefrescarFiltro;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.OnFiltroListaISOPropertiesInitPopup(
|
||
Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
with frViewFiltroBase1.eLista2.Properties.Items do
|
||
begin
|
||
BeginUpdate;
|
||
try
|
||
Clear;
|
||
Add('Todos'); //Case 0
|
||
Add('Con ISO'); //Case 1
|
||
Add('Sin ISO'); //Case 2
|
||
frViewFiltroBase1.eLista2.ItemIndex := 0;
|
||
finally
|
||
EndUpdate;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.OnFiltroListaPropertiesChange(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
RefrescarFiltro;
|
||
end;
|
||
|
||
procedure TfrViewPresupuestosCliente.OnFiltroListaPropertiesInitPopup(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
with frViewFiltroBase1.eLista.Properties.Items do
|
||
begin
|
||
BeginUpdate;
|
||
try
|
||
Clear;
|
||
Add('Todos'); //Case 0
|
||
Add('Sin facturar'); //Case 1
|
||
Add('Facturados'); //Case 2
|
||
frViewFiltroBase1.eLista.ItemIndex := 0;
|
||
finally
|
||
EndUpdate;
|
||
end;
|
||
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.
|