git-svn-id: https://192.168.0.254/svn/Proyectos.EstudioCarnicero_ProGestion/trunk@4 1b8572a8-2d6b-b84e-8c90-20ed86fa4eca
332 lines
12 KiB
ObjectPascal
332 lines
12 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2006. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión: 22-05-2006
|
|
Versión actual: 1.0.0
|
|
Fecha versión actual: 22-05-2006
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
===============================================================================
|
|
}
|
|
|
|
unit uViewPresupuestosContacto;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, uViewGrid, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData,
|
|
cxDataStorage, cxEdit, DB, cxDBData, dxPSGlbl, dxPSUtl, dxPSEngn,
|
|
dxPrnPg, dxBkgnd, dxWrap, dxPrnDev, dxPSCompsProvider, dxPSFillPatterns,
|
|
dxPSEdgePatterns, dxPSCore, dxPScxCommon, dxPScxGridLnk, ActnList,
|
|
uDADataTable, cxGridLevel, cxClasses, cxControls, cxGridCustomView,
|
|
cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGrid,
|
|
uViewBase, uBizObra, ComCtrls, ToolWin, ImgList, PngImageList;
|
|
|
|
type
|
|
IViewPresupuestosContacto = interface(IViewGrid)
|
|
['{F5032AD4-1880-4E04-BDA9-0F1FB43B6432}']
|
|
function GetPresupuestosContacto: IBizPresupuestosObra;
|
|
procedure SetPresupuestosContacto(const Value: IBizPresupuestosObra);
|
|
property PresupuestosContacto: IBizPresupuestosObra read GetPresupuestosContacto write SetPresupuestosContacto;
|
|
|
|
procedure SetClasePresupuesto(const Value: String);
|
|
function GetClasePresupuesto: String;
|
|
property ClasePresupuesto: String read GetClasePresupuesto write SetClasePresupuesto;
|
|
|
|
procedure ActivarFiltros;
|
|
procedure DesactivarFiltros;
|
|
end;
|
|
|
|
TfrViewPresupuestosContacto = class(TfrViewGrid, IViewPresupuestosContacto)
|
|
cxGridLevel1: TcxGridLevel;
|
|
cxGridView2: TcxGridDBTableView;
|
|
cxGridViewRecID: TcxGridDBColumn;
|
|
cxGridViewCODIGO: TcxGridDBColumn;
|
|
cxGridViewCODIGOOBRA: TcxGridDBColumn;
|
|
cxGridViewCODIGOCONTACTO: TcxGridDBColumn;
|
|
cxGridViewFECHAALTA: TcxGridDBColumn;
|
|
cxGridViewUSUARIO: TcxGridDBColumn;
|
|
cxGridViewFECHA: TcxGridDBColumn;
|
|
cxGridViewTIPO: TcxGridDBColumn;
|
|
cxGridViewDESCRIPCION: TcxGridDBColumn;
|
|
cxGridViewPRESUPUESTOINICIAL: TcxGridDBColumn;
|
|
cxGridViewPRESUPUESTOFINAL: TcxGridDBColumn;
|
|
cxGridViewRETENCION: TcxGridDBColumn;
|
|
cxGridViewTIEMPORETENCION: TcxGridDBColumn;
|
|
cxGridView2RecID: TcxGridDBColumn;
|
|
cxGridView2CODIGO: TcxGridDBColumn;
|
|
cxGridView2CODIGOOBRA: TcxGridDBColumn;
|
|
cxGridView2CODIGOCONTACTO: TcxGridDBColumn;
|
|
cxGridView2FECHAALTA: TcxGridDBColumn;
|
|
cxGridView2USUARIO: TcxGridDBColumn;
|
|
cxGridView2FECHA: TcxGridDBColumn;
|
|
cxGridView2TIPO: TcxGridDBColumn;
|
|
cxGridView2DESCRIPCION: TcxGridDBColumn;
|
|
cxGridView2PRESUPUESTOINICIAL: TcxGridDBColumn;
|
|
cxGridView2PRESUPUESTOFINAL: TcxGridDBColumn;
|
|
cxGridView2RETENCION: TcxGridDBColumn;
|
|
cxGridView2TIEMPORETENCION: TcxGridDBColumn;
|
|
cxGridViewCLASE: TcxGridDBColumn;
|
|
cxGridView2CLASE: TcxGridDBColumn;
|
|
ToolBar1: TToolBar;
|
|
ToolButton1: TToolButton;
|
|
ToolButton2: TToolButton;
|
|
ToolButton4: TToolButton;
|
|
ToolButton3: TToolButton;
|
|
ToolButton5: TToolButton;
|
|
actEditar: TAction;
|
|
actEliminar: TAction;
|
|
actEliminarTodo: TAction;
|
|
actAnadir: TAction;
|
|
PngImageList: TPngImageList;
|
|
cxGridViewIMPORTERETENCION: TcxGridDBColumn;
|
|
cxGridViewACEPTADO: TcxGridDBColumn;
|
|
cxStyleAceptado: TcxStyle;
|
|
cxStyleRechazado: TcxStyle;
|
|
procedure cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
|
procedure CustomViewShow(Sender: TObject);
|
|
|
|
procedure actEditarUpdate(Sender: TObject);
|
|
procedure actEliminarUpdate(Sender: TObject);
|
|
procedure actEliminarTodoUpdate(Sender: TObject);
|
|
|
|
procedure cxGridViewStylesGetContentStyle(
|
|
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
|
|
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
|
|
procedure cxGridView2StylesGetContentStyle(
|
|
Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord;
|
|
AItem: TcxCustomGridTableItem; out AStyle: TcxStyle);
|
|
procedure cxGridViewACEPTADOCustomDrawCell(
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|
|
|
private
|
|
FClasePresupuesto: String;
|
|
FPresupuestosContacto: IBizPresupuestosObra;
|
|
function GetPresupuestosContacto: IBizPresupuestosObra;
|
|
procedure SetPresupuestosContacto(const Value: IBizPresupuestosObra);
|
|
procedure SetClasePresupuesto(const Value: String);
|
|
function GetClasePresupuesto: String;
|
|
|
|
public
|
|
property ClasePresupuesto: String read GetClasePresupuesto write SetClasePresupuesto;
|
|
property PresupuestosContacto: IBizPresupuestosObra read GetPresupuestosContacto write SetPresupuestosContacto;
|
|
procedure RefreshGrid; override;
|
|
procedure ActivarFiltros;
|
|
procedure DesactivarFiltros;
|
|
end;
|
|
|
|
var
|
|
frViewPresupuestosContacto: TfrViewPresupuestosContacto;
|
|
|
|
implementation
|
|
|
|
uses uDataModuleObras, schObrasClient_Intf;
|
|
|
|
{$R *.dfm}
|
|
|
|
{ TfrViewPresupuestosContacto }
|
|
|
|
function TfrViewPresupuestosContacto.GetPresupuestosContacto: IBizPresupuestosObra;
|
|
begin
|
|
Result := FPresupuestosContacto;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.SetPresupuestosContacto(const Value: IBizPresupuestosObra);
|
|
begin
|
|
FPresupuestosContacto := Value;
|
|
|
|
if Assigned(FPresupuestosContacto) then
|
|
DADataSource.DataTable := FPresupuestosContacto.DataTable
|
|
else
|
|
DADataSource.DataTable := NIL;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.cxGridActiveTabChanged(Sender: TcxCustomGrid; ALevel: TcxGridLevel);
|
|
begin
|
|
inherited;
|
|
|
|
case ALevel.Index of
|
|
0: ClasePresupuesto := CLASE_PRESUPUESTO;
|
|
1: ClasePresupuesto := CLASE_TRABAJO;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.actEditarUpdate(Sender: TObject);
|
|
begin
|
|
if (ClasePresupuesto = CLASE_PRESUPUESTO)
|
|
then (Sender as TAction).Enabled := (cxGridView.DataController.FilteredRecordCount > 0)
|
|
else (Sender as TAction).Enabled := (cxGridView2.DataController.FilteredRecordCount > 0);
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.actEliminarUpdate(Sender: TObject);
|
|
begin
|
|
if (ClasePresupuesto = CLASE_PRESUPUESTO)
|
|
then (Sender as TAction).Enabled := (cxGridView.DataController.FilteredRecordCount > 0)
|
|
else (Sender as TAction).Enabled := (cxGridView2.DataController.FilteredRecordCount > 0);
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.actEliminarTodoUpdate(
|
|
Sender: TObject);
|
|
begin
|
|
if (ClasePresupuesto = CLASE_PRESUPUESTO)
|
|
then (Sender as TAction).Enabled := (cxGridView.DataController.FilteredRecordCount > 0)
|
|
else (Sender as TAction).Enabled := (cxGridView2.DataController.FilteredRecordCount > 0);
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.CustomViewShow(Sender: TObject);
|
|
begin
|
|
cxGridView.DataController.Filter.BeginUpdate;
|
|
cxGridView.DataController.Filter.Clear;
|
|
cxGridView.DataController.Filter.Root.AddItem(cxGridViewCLASE, foEqual, CLASE_PRESUPUESTO, CLASE_PRESUPUESTO);
|
|
cxGridView.DataController.Filter.EndUpdate;
|
|
|
|
cxGridView2.DataController.Filter.BeginUpdate;
|
|
cxGridView2.DataController.Filter.Clear;
|
|
cxGridView2.DataController.Filter.Root.AddItem(cxGridView2CLASE, foEqual, CLASE_TRABAJO, CLASE_TRABAJO);
|
|
cxGridView2.DataController.Filter.EndUpdate;
|
|
|
|
ActivarFiltros;
|
|
ClasePresupuesto := CLASE_PRESUPUESTO;
|
|
end;
|
|
|
|
function TfrViewPresupuestosContacto.GetClasePresupuesto: String;
|
|
begin
|
|
Result := FClasePresupuesto;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.DesactivarFiltros;
|
|
begin
|
|
if Assigned(DADataSource.DataTable) then
|
|
begin
|
|
|
|
if ClasePresupuesto = CLASE_PRESUPUESTO then
|
|
begin
|
|
cxGridView2.DataController.Filter.Active := False;
|
|
cxGridView.DataController.Filter.Active := False;
|
|
end
|
|
else
|
|
begin
|
|
cxGridView.DataController.Filter.Active := False;
|
|
cxGridView2.DataController.Filter.Active := False;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.ActivarFiltros;
|
|
var
|
|
lsCodigo : Variant;
|
|
begin
|
|
if Assigned(DADataSource.DataTable) then
|
|
begin
|
|
lsCodigo := PresupuestosContacto.CODIGO;
|
|
|
|
if ClasePresupuesto = CLASE_PRESUPUESTO then
|
|
begin
|
|
cxGridView2.DataController.Filter.Active := True;
|
|
cxGridView.DataController.Filter.Active := True;
|
|
cxGridView.DataController.LocateByKey(lsCodigo);
|
|
end
|
|
else
|
|
begin
|
|
cxGridView.DataController.Filter.Active := True;
|
|
cxGridView2.DataController.Filter.Active := True;
|
|
cxGridView2.DataController.LocateByKey(lsCodigo);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.RefreshGrid;
|
|
begin
|
|
// <- Refresco las dos vistas
|
|
cxGridView.DataController.UpdateItems(False);
|
|
cxGridView2.DataController.UpdateItems(False);
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.SetClasePresupuesto(const Value: String);
|
|
begin
|
|
FClasePresupuesto := Value;
|
|
|
|
if FClasePresupuesto = CLASE_PRESUPUESTO
|
|
then cxGridView.DataController.GotoFirst
|
|
else cxGridView2.DataController.GotoFirst;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.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_PresupuestosObraACEPTADO).Index;
|
|
ASituacion := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
|
if StrToInt(ASituacion) = CTE_ACEPTADO then
|
|
AStyle := cxStyleAceptado
|
|
else if StrToInt(ASituacion) = CTE_NO_ACEPTADO then
|
|
AStyle := cxStyleRechazado;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.cxGridView2StylesGetContentStyle(
|
|
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_PresupuestosObraACEPTADO).Index;
|
|
ASituacion := VarToStr(ARecord.DisplayTexts[IndiceCol]);
|
|
if StrToInt(ASituacion) = CTE_ACEPTADO then
|
|
AStyle := cxStyleAceptado
|
|
else if StrToInt(ASituacion) = CTE_NO_ACEPTADO then
|
|
AStyle := cxStyleRechazado;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrViewPresupuestosContacto.cxGridViewACEPTADOCustomDrawCell(
|
|
Sender: TcxCustomGridTableView; ACanvas: TcxCanvas;
|
|
AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean);
|
|
var
|
|
IndiceCol: Integer;
|
|
R : TRect;
|
|
begin
|
|
inherited;
|
|
IndiceCol := (Sender as TcxGridDBTableView).GetColumnByFieldName(fld_PresupuestosObraACEPTADO).Index;
|
|
if UpperCase(AViewInfo.GridRecord.DisplayTexts[IndiceCol]) = IntToStr(CTE_ACEPTADO) then
|
|
begin
|
|
R := AViewInfo.ContentBounds;
|
|
ACanvas.FillRect(R);
|
|
ACanvas.DrawImage(PngImageList, R.Left, R.Top, 3);
|
|
ADone := True;
|
|
end
|
|
else
|
|
begin
|
|
R := AViewInfo.ContentBounds;
|
|
ACanvas.FillRect(R);
|
|
// ACanvas.DrawImage(PngImageList, R.Left, R.Top, 1);
|
|
ADone := True;
|
|
end;
|
|
end;
|
|
|
|
end.
|