git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@431 f4e31baf-9722-1c47-927c-6f952f962d4b
345 lines
11 KiB
ObjectPascal
345 lines
11 KiB
ObjectPascal
unit uViewContratosCliente;
|
|
|
|
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, uBizContratosCliente, cxCurrencyEdit, Forms, uViewFiltroBase, ActnList, TB2Item,
|
|
TBX, TB2Toolbar, TBXDkPanels, TB2Dock, dxPgsDlg, uDAInterfaces, Windows,
|
|
uCustomView, uViewBase;
|
|
|
|
type
|
|
IViewContratosCliente = interface(IViewGrid)
|
|
['{2351A8B5-DA8B-4EA3-A777-A085152698CF}']
|
|
function GetContratos: IBizContratoCliente;
|
|
procedure SetContratos(const Value: IBizContratoCliente);
|
|
property Contratos: IBizContratoCliente read GetContratos write SetContratos;
|
|
end;
|
|
|
|
TfrViewContratosCliente = class(TfrViewGrid, IViewContratosCliente)
|
|
cxGridDBTableView1: TcxGridDBTableView;
|
|
cxGridViewREFERENCIA: TcxGridDBColumn;
|
|
cxGridViewINCIDENCIASACTIVAS: TcxGridDBColumn;
|
|
cxGridViewNOMBRE: TcxGridDBColumn;
|
|
cxGridViewSITUACION: TcxGridDBColumn;
|
|
cxGridViewFECHA_CONTRATO: TcxGridDBColumn;
|
|
cxGridViewCLIENTE_FINAL: TcxGridDBColumn;
|
|
cxGridViewFACTURA: TcxGridDBColumn;
|
|
cxGridViewIMPORTE_TOTAL: TcxGridDBColumn;
|
|
cxGridLevelPendientes: TcxGridLevel;
|
|
cxGridLevelTerminados: TcxGridLevel;
|
|
cxStylePENDIENTES: TcxStyle;
|
|
cxStyleACEPTADO: TcxStyle;
|
|
actCliente: TAction;
|
|
actProvincia: TAction;
|
|
TBXItem2: TTBXItem;
|
|
TBXSeparatorItem1: TTBXSeparatorItem;
|
|
TBXSeparatorItem2: TTBXSeparatorItem;
|
|
TBXItem3: TTBXItem;
|
|
cxGridViewNIF_CIF: TcxGridDBColumn;
|
|
cxGridViewINCIDENCIAS: TcxGridDBColumn;
|
|
cxStyleRECHAZADO: TcxStyle;
|
|
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 CustomViewDestroy(Sender: TObject);
|
|
procedure CustomViewShow(Sender: TObject);
|
|
procedure frViewFiltroBase1actQuitarFiltroExecute(Sender: TObject);
|
|
|
|
private
|
|
//Filtros relativos a la vista
|
|
procedure AnadirFiltroSituaciones;
|
|
procedure AnadirFiltroFechas;
|
|
// procedure AnadirFiltroFacturado;
|
|
|
|
protected
|
|
FContratos: IBizContratoCliente;
|
|
function GetContratos: IBizContratoCliente;
|
|
procedure SetContratos(const Value: IBizContratoCliente);
|
|
public
|
|
procedure AnadirOtrosFiltros; override;
|
|
property Contratos: IBizContratoCliente read GetContratos write SetContratos;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
SysUtils, variants, uDataModuleContratosCliente, schContratosClienteClient_Intf,
|
|
uViewGridBase,
|
|
//uReferenciasUtils,
|
|
cxVariants;
|
|
|
|
{$R *.dfm}
|
|
|
|
procedure TfrViewContratosCliente.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 TfrViewContratosCliente.actClienteUpdate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
(Sender as TAction).Checked := not (cxGridViewNOMBRE.GroupIndex < 0);
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.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 TfrViewContratosCliente.actProvinciaUpdate(Sender: TObject);
|
|
begin
|
|
{
|
|
inherited;
|
|
(Sender as TAction).Checked := not (cxGridViewPROVINCIA.GroupIndex < 0);
|
|
}
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.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 TfrViewContratosCliente.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 TfrViewContratosCliente.AnadirFiltroSituaciones;
|
|
var
|
|
FFiltro : TcxFilterCriteriaItemList;
|
|
begin
|
|
FFiltro := AddFilterGrid(fboAnd);
|
|
|
|
case cxGrid.ActiveLevel.Index of
|
|
1 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_CONTRATO_PENDIENTE, SITUACION_CONTRATO_PENDIENTE);
|
|
2 : FFiltro.AddItem(cxGridViewSITUACION, foEqual, SITUACION_CONTRATO_TERMINADO, SITUACION_CONTRATO_TERMINADO);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.AnadirOtrosFiltros;
|
|
begin
|
|
inherited;
|
|
|
|
AnadirFiltroSituaciones;
|
|
AnadirFiltroFechas;
|
|
// AnadirFiltroFacturado;
|
|
|
|
//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 TfrViewContratosCliente.CustomViewDestroy(Sender: TObject);
|
|
begin
|
|
// frViewFiltroBase1.eLista.Properties.OnChange := Nil;
|
|
// frViewFiltroBase1.eLista.Properties.OnInitPopup := Nil;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.CustomViewShow(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
// frViewFiltroBase1.eLista.Properties.OnChange := OnFiltroListaPropertiesChange;
|
|
// frViewFiltroBase1.eLista.Properties.OnInitPopup := OnFiltroListaPropertiesInitPopup;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
|
begin
|
|
inherited;
|
|
RefrescarFiltro;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.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 TfrViewContratosCliente.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, 1)
|
|
else
|
|
ACanvas.DrawImage(GridPNGImageList, R.Left + 2, R.Top + 2, 2);
|
|
ADone := True;}
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.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;
|
|
AHintText := ARecord.Values[cxGridViewINCIDENCIAS.Index]
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.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_ContratosClienteSITUACION).Index;
|
|
ASituacion := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
|
if ASituacion = SITUACION_CONTRATO_PENDIENTE then
|
|
AStyle.TextColor := cxStylePENDIENTES.TextColor
|
|
else if ASituacion = SITUACION_CONTRATO_TERMINADO then
|
|
AStyle.TextColor := cxStyleRECHAZADO.TextColor
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.frViewFiltroBase1actQuitarFiltroExecute(Sender: TObject);
|
|
begin
|
|
frViewFiltroBase1.txtFiltroTodo.Clear;
|
|
// frViewFiltroBase1.eLista.Clear;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.OnFiltroListaPropertiesChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
RefrescarFiltro;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.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 TfrViewContratosCliente.GetContratos: IBizContratoCliente;
|
|
begin
|
|
Result := FContratos;
|
|
end;
|
|
|
|
procedure TfrViewContratosCliente.SetContratos(const Value: IBizContratoCliente);
|
|
begin
|
|
FContratos := Value;
|
|
if Assigned(FContratos) then
|
|
dsDataSource.DataTable := FContratos.DataTable;
|
|
end;
|
|
|
|
end.
|