git-svn-id: https://192.168.0.254/svn/Proyectos.ConstruccionesCNJ_FactuGES/trunk@4 6cb6b671-b4a0-dd4c-8bdc-3006503d97e9
126 lines
4.3 KiB
ObjectPascal
126 lines
4.3 KiB
ObjectPascal
unit uViewDetallesPresupuesto;
|
||
|
||
interface
|
||
|
||
uses
|
||
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
||
Dialogs, uViewDetallesBase, cxStyles, cxCustomData, cxGraphics, cxFilter,
|
||
cxData, cxDataStorage, cxEdit, DB, cxDBData, ImgList, PngImageList,
|
||
uDADataTable, ActnList, ComCtrls, ToolWin, cxGridLevel, cxClasses, cxControls,
|
||
cxGridCustomView, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
|
||
cxGrid, cxImageComboBox, cxTextEdit, cxMaskEdit, cxCheckBox, cxCurrencyEdit,
|
||
Grids, DBGrids, StdCtrls, ExtCtrls, cxRichEdit, StdActns, ExtActns,
|
||
JvExStdCtrls, JvCombobox, JvColorCombo, TB2Item, TBX, TB2Dock, TB2Toolbar,
|
||
cxSpinEdit, Menus;
|
||
|
||
type
|
||
TfrViewDetallesPresupuesto = class(TfrViewDetallesBase)
|
||
cxGridViewDESCUENTO: TcxGridDBColumn;
|
||
actAnadirCapitulo: TAction;
|
||
TBXItem12: TTBXItem;
|
||
procedure cxGridViewTIPOPropertiesValidate(Sender: TObject;
|
||
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
|
||
procedure actSubirUpdate(Sender: TObject);
|
||
procedure actBajarUpdate(Sender: TObject);
|
||
procedure actAnadirCapituloExecute(Sender: TObject);
|
||
protected
|
||
function HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean; override;
|
||
function EsTipoEditable(AItem: TcxCustomGridTableItem): Boolean; override;
|
||
end;
|
||
|
||
implementation
|
||
{$R *.dfm}
|
||
|
||
uses uControllerDetallesBase, uDetallesPresupuestoController;
|
||
|
||
procedure TfrViewDetallesPresupuesto.actAnadirCapituloExecute(Sender: TObject);
|
||
begin
|
||
cxGridView.BeginUpdate;
|
||
try
|
||
if cxGridView.Controller.EditingController.IsEditing then
|
||
cxGridView.Controller.EditingController.Edit.PostEditValue;
|
||
|
||
if Assigned(Controller)
|
||
and Assigned(Detalles) then
|
||
(Controller as IDetallesPresupuestoController).addCapitulo(Detalles);
|
||
finally
|
||
cxGridView.EndUpdate;
|
||
end;
|
||
end;
|
||
|
||
procedure TfrViewDetallesPresupuesto.actBajarUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := ((cxGridViewTIPO.DataBinding.Field.Value <> TIPO_DETALLE_DTO)
|
||
and (cxGridViewTIPO.DataBinding.Field.Value <> TIPO_DETALLE_SUBTOTAL));
|
||
end;
|
||
|
||
procedure TfrViewDetallesPresupuesto.actSubirUpdate(Sender: TObject);
|
||
begin
|
||
inherited;
|
||
|
||
if (Sender as TAction).Enabled then
|
||
(Sender as TAction).Enabled := ((cxGridViewTIPO.DataBinding.Field.Value <> TIPO_DETALLE_DTO)
|
||
and (cxGridViewTIPO.DataBinding.Field.Value <> TIPO_DETALLE_SUBTOTAL));
|
||
end;
|
||
|
||
procedure TfrViewDetallesPresupuesto.cxGridViewTIPOPropertiesValidate(
|
||
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
||
var Error: Boolean);
|
||
var
|
||
liPosicion: Integer;
|
||
begin
|
||
inherited;
|
||
//Recogemos la posici<63>n del registro que cambia su tipo y
|
||
//validamos que si es de tipo Descuento el registro inmediatamente
|
||
//anterior debe ser de tipo subtotal
|
||
if (DisplayValue = TIPO_DETALLE_DTO) then
|
||
begin
|
||
liPosicion := cxGridViewPOSICION.DataBinding.Field.Value;
|
||
Dec(liPosicion);
|
||
if (Controller.getTipo(Detalles, liPosicion) <> TIPO_DETALLE_SUBTOTAL) then
|
||
begin
|
||
ErrorText := 'Una linea de descuento solo puede ir despues de un final de cap<61>tulo';
|
||
Error := True
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
function TfrViewDetallesPresupuesto.EsTipoEditable(AItem: TcxCustomGridTableItem): Boolean;
|
||
var
|
||
IndiceColTipo : Integer;
|
||
IndiceColDto : Integer;
|
||
IndiceColConcepto : Integer;
|
||
begin
|
||
Result := inherited EsTipoEditable(AItem);
|
||
|
||
if Result then
|
||
begin
|
||
IndiceColTipo := cxGridView.GetColumnByFieldName(CAMPO_TIPO).Index;
|
||
IndiceColDto := cxGridView.GetColumnByFieldName(CAMPO_DESCUENTO).Index;
|
||
IndiceColConcepto := cxGridView.GetColumnByFieldName(CAMPO_CONCEPTO).Index;
|
||
|
||
if (AItem.GridView.Items[IndiceColTipo].EditValue = TIPO_DETALLE_DTO) then
|
||
begin
|
||
if (AItem.Index > IndiceColConcepto)
|
||
and (AItem.Index <> IndiceColDto) then
|
||
Result := False;
|
||
end
|
||
else
|
||
begin
|
||
if (AItem.Index = IndiceColDto) then
|
||
Result := False;
|
||
end;
|
||
end;
|
||
end;
|
||
|
||
function TfrViewDetallesPresupuesto.HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean;
|
||
begin
|
||
Result := inherited HayQueRecalcular(AItem);
|
||
Result := Result or (AItem = cxGridViewDESCUENTO);
|
||
end;
|
||
|
||
end.
|