- Nueva función 'LocalizarPosicion' en el controlador de detalles base (2º intento de subida).
git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@190 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
parent
724b8806d6
commit
1c1a3c3d6d
@ -9,7 +9,7 @@ const
|
|||||||
TIPO_DETALLE_TITULO = 'Titulo';
|
TIPO_DETALLE_TITULO = 'Titulo';
|
||||||
TIPO_DETALLE_SUBTOTAL = 'Subtotal';
|
TIPO_DETALLE_SUBTOTAL = 'Subtotal';
|
||||||
TIPO_DETALLE_SALTO = 'Salto';
|
TIPO_DETALLE_SALTO = 'Salto';
|
||||||
TIPO_DETALLE_DESCUENTO = 'Descuento';
|
TIPO_DETALLE_DESCUENTO = 'Descuento';
|
||||||
|
|
||||||
CTE_DESC_SALTO = 'SALTO DE PAGINA >>';
|
CTE_DESC_SALTO = 'SALTO DE PAGINA >>';
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ type
|
|||||||
|
|
||||||
procedure ActualizarTotales(ADataTable: IDAStronglyTypedDataTable);
|
procedure ActualizarTotales(ADataTable: IDAStronglyTypedDataTable);
|
||||||
function DarTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double;
|
function DarTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double;
|
||||||
|
function LocalizarPosicion(ADataTable: IDAStronglyTypedDataTable; const APosicion: Integer): Boolean;
|
||||||
function DarListaTiposDetalle: TStringList;
|
function DarListaTiposDetalle: TStringList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -82,6 +82,7 @@ type
|
|||||||
procedure ActualizarTotales(ADataTable: IDAStronglyTypedDataTable);
|
procedure ActualizarTotales(ADataTable: IDAStronglyTypedDataTable);
|
||||||
function DarTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double;
|
function DarTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double;
|
||||||
function DarListaTiposDetalle: TStringList; virtual;
|
function DarListaTiposDetalle: TStringList; virtual;
|
||||||
|
function LocalizarPosicion(ADataTable: IDAStronglyTypedDataTable; const APosicion: Integer): Boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +90,8 @@ implementation
|
|||||||
|
|
||||||
{ TControllerDetallesBase }
|
{ TControllerDetallesBase }
|
||||||
|
|
||||||
uses cxControls, SysUtils, DB, uDAInterfaces;
|
uses
|
||||||
|
cxControls, SysUtils, DB, uDAInterfaces, Dialogs;
|
||||||
|
|
||||||
procedure TControllerDetallesBase.ActualizarTotales(ADataTable: IDAStronglyTypedDataTable);
|
procedure TControllerDetallesBase.ActualizarTotales(ADataTable: IDAStronglyTypedDataTable);
|
||||||
begin
|
begin
|
||||||
@ -153,6 +155,7 @@ begin
|
|||||||
ValidarCampos(DataTable);
|
ValidarCampos(DataTable);
|
||||||
|
|
||||||
DataTable.DisableControls;
|
DataTable.DisableControls;
|
||||||
|
|
||||||
AuxPosicionIni := DataTable.FieldByName(CAMPO_POSICION).AsInteger;
|
AuxPosicionIni := DataTable.FieldByName(CAMPO_POSICION).AsInteger;
|
||||||
AuxPosicion := 0;
|
AuxPosicion := 0;
|
||||||
AuxImporteAcumulado := 0;
|
AuxImporteAcumulado := 0;
|
||||||
@ -160,7 +163,7 @@ begin
|
|||||||
try
|
try
|
||||||
|
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
while DataTable.Locate(CAMPO_POSICION, IntToStr(AuxPosicion), []) do
|
while DataTable.Locate(CAMPO_POSICION, AuxPosicion, []) do
|
||||||
begin
|
begin
|
||||||
//SALTOS DE LINEA
|
//SALTOS DE LINEA
|
||||||
if (DataTable.FieldByName(CAMPO_TIPO).AsString = TIPO_DETALLE_SALTO) then
|
if (DataTable.FieldByName(CAMPO_TIPO).AsString = TIPO_DETALLE_SALTO) then
|
||||||
@ -206,7 +209,7 @@ begin
|
|||||||
|
|
||||||
finally
|
finally
|
||||||
//Dejamos el puntero en la misma posición que la que partió
|
//Dejamos el puntero en la misma posición que la que partió
|
||||||
DataTable.Locate(CAMPO_POSICION, IntToStr(AuxPosicionIni), []);
|
DataTable.Locate(CAMPO_POSICION, AuxPosicionIni, []);
|
||||||
DataTable.EnableControls;
|
DataTable.EnableControls;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -284,14 +287,14 @@ end;
|
|||||||
function TControllerDetallesBase.DarListaTiposDetalle: TStringList;
|
function TControllerDetallesBase.DarListaTiposDetalle: TStringList;
|
||||||
begin
|
begin
|
||||||
Result := TStringList.Create;
|
Result := TStringList.Create;
|
||||||
Result.Values[TIPO_DETALLE_CONCEPTO] := 'Concepto';
|
Result.Values[TIPO_DETALLE_CONCEPTO] := TIPO_DETALLE_CONCEPTO;
|
||||||
Result.Values[TIPO_DETALLE_TITULO] := 'Título de capítulo';
|
Result.Values[TIPO_DETALLE_TITULO] := TIPO_DETALLE_TITULO;
|
||||||
Result.Values[TIPO_DETALLE_SUBTOTAL] := 'Final de capítulo';
|
Result.Values[TIPO_DETALLE_SUBTOTAL] := TIPO_DETALLE_SUBTOTAL;
|
||||||
Result.Values[TIPO_DETALLE_DESCUENTO] := 'Descuento de capítulo';
|
Result.Values[TIPO_DETALLE_DESCUENTO] := TIPO_DETALLE_DESCUENTO;
|
||||||
Result.Values[TIPO_DETALLE_SALTO] := 'Salto de página';
|
Result.Values[TIPO_DETALLE_SALTO] := TIPO_DETALLE_SALTO;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TControllerDetallesBase.darTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double;
|
function TControllerDetallesBase.DarTotalImporteTotal(ADataTable: IDAStronglyTypedDataTable): Double;
|
||||||
begin
|
begin
|
||||||
Result := CalcularTotales(False, ADataTable.DataTable);
|
Result := CalcularTotales(False, ADataTable.DataTable);
|
||||||
end;
|
end;
|
||||||
@ -315,7 +318,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
DeletePosicion := POSICION[i];
|
DeletePosicion := POSICION[i];
|
||||||
if DataTable.Locate(CAMPO_POSICION, IntToStr(DeletePosicion), []) then
|
if DataTable.Locate(CAMPO_POSICION, DeletePosicion, []) then
|
||||||
DataTable.Delete;
|
DataTable.Delete;
|
||||||
end;
|
end;
|
||||||
Renumerar(DataTable, DeletePosicion);
|
Renumerar(DataTable, DeletePosicion);
|
||||||
@ -402,12 +405,12 @@ begin
|
|||||||
posIni := DataTable.FieldByName(CAMPO_POSICION).AsInteger;
|
posIni := DataTable.FieldByName(CAMPO_POSICION).AsInteger;
|
||||||
|
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
if DataTable.Locate(CAMPO_POSICION, IntToStr(pPosicion), []) then
|
if DataTable.Locate(CAMPO_POSICION, pPosicion, []) then
|
||||||
Result := DataTable.FieldByName(CAMPO_TIPO).AsString;
|
Result := DataTable.FieldByName(CAMPO_TIPO).AsString;
|
||||||
|
|
||||||
//Volvemos a posicionar el puntero donde estaba
|
//Volvemos a posicionar el puntero donde estaba
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
if not DataTable.Locate(CAMPO_POSICION, IntToStr(posIni), []) then
|
if not DataTable.Locate(CAMPO_POSICION, posIni, []) then
|
||||||
raise Exception.Create('La posición ' + IntToStr(posIni) + ' no existe (getTipo)');
|
raise Exception.Create('La posición ' + IntToStr(posIni) + ' no existe (getTipo)');
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -415,6 +418,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TControllerDetallesBase.LocalizarPosicion(
|
||||||
|
ADataTable: IDAStronglyTypedDataTable; const APosicion: Integer): Boolean;
|
||||||
|
var
|
||||||
|
AField: TDAField;
|
||||||
|
begin
|
||||||
|
AField := ADataTable.DataTable.FindField(CAMPO_POSICION);
|
||||||
|
|
||||||
|
if not Assigned(AField) then
|
||||||
|
raise Exception.Create('Campo ' + CAMPO_POSICION + ' no encontrado (LocalizarPosicion)');
|
||||||
|
|
||||||
|
with ADataTable.DataTable do
|
||||||
|
begin
|
||||||
|
DisableControls;
|
||||||
|
DisableEventHandlers;
|
||||||
|
ShowHourglassCursor;
|
||||||
|
try
|
||||||
|
First;
|
||||||
|
Result := Locate(CAMPO_POSICION, APosicion, []);
|
||||||
|
finally
|
||||||
|
HideHourglassCursor;
|
||||||
|
EnableEventHandlers;
|
||||||
|
EnableControls;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TControllerDetallesBase.Move(ADataTable: IDAStronglyTypedDataTable; Posicion: TIntegerArray; Posiciones: Integer);
|
procedure TControllerDetallesBase.Move(ADataTable: IDAStronglyTypedDataTable; Posicion: TIntegerArray; Posiciones: Integer);
|
||||||
var
|
var
|
||||||
i:Integer;
|
i:Integer;
|
||||||
@ -458,7 +487,7 @@ begin
|
|||||||
|
|
||||||
//Buscamos el elemento con la posicion pasada por parametro
|
//Buscamos el elemento con la posicion pasada por parametro
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
if not DataTable.Locate(CAMPO_POSICION, IntToStr(Posicion), []) then
|
if not DataTable.Locate(CAMPO_POSICION, Posicion, []) then
|
||||||
raise Exception.Create('Error, no se ha encontrado la POSICION [' + IntToStr(Posicion) + '] (mover)');
|
raise Exception.Create('Error, no se ha encontrado la POSICION [' + IntToStr(Posicion) + '] (mover)');
|
||||||
|
|
||||||
//Guardamos el id del elemento a cambiar de posicion y calculamos su nueva posicion
|
//Guardamos el id del elemento a cambiar de posicion y calculamos su nueva posicion
|
||||||
@ -466,14 +495,14 @@ begin
|
|||||||
AuxOrden := Posicion + NumPosiciones;
|
AuxOrden := Posicion + NumPosiciones;
|
||||||
|
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
if DataTable.Locate(CAMPO_POSICION, IntToStr(AuxOrden), []) then
|
if DataTable.Locate(CAMPO_POSICION, AuxOrden, []) then
|
||||||
begin
|
begin
|
||||||
if not DataTable.Editing then DataTable.Edit;
|
if not DataTable.Editing then DataTable.Edit;
|
||||||
DataTable.FieldByName(CAMPO_POSICION).AsInteger := DataTable.FieldByName(CAMPO_POSICION).AsInteger - NumPosiciones;
|
DataTable.FieldByName(CAMPO_POSICION).AsInteger := DataTable.FieldByName(CAMPO_POSICION).AsInteger - NumPosiciones;
|
||||||
|
|
||||||
//Se hace dentro por si es el ultimo o el primero
|
//Se hace dentro por si es el ultimo o el primero
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
if not DataTable.Locate(CAMPO_ID, IntToStr(AuxID), []) then
|
if not DataTable.Locate(CAMPO_ID, AuxID, []) then
|
||||||
raise Exception.Create('Error, no se ha encontrado el ID [' + IntToStr(AuxID) + '] (mover)');
|
raise Exception.Create('Error, no se ha encontrado el ID [' + IntToStr(AuxID) + '] (mover)');
|
||||||
|
|
||||||
if not DataTable.Editing then DataTable.Edit;
|
if not DataTable.Editing then DataTable.Edit;
|
||||||
@ -484,7 +513,7 @@ begin
|
|||||||
|
|
||||||
//Colocamos el puntero en la posición en la que estaba
|
//Colocamos el puntero en la posición en la que estaba
|
||||||
DataTable.First;
|
DataTable.First;
|
||||||
DataTable.Locate(CAMPO_ID, IntToStr(AuxID), []);
|
DataTable.Locate(CAMPO_ID, AuxID, []);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TControllerDetallesBase.Renumerar(DataTable: TDADataTable; LocalizaPosicion: Integer);
|
procedure TControllerDetallesBase.Renumerar(DataTable: TDADataTable; LocalizaPosicion: Integer);
|
||||||
@ -496,6 +525,7 @@ var
|
|||||||
AField: TDAField;
|
AField: TDAField;
|
||||||
begin
|
begin
|
||||||
AField := DataTable.FindField(CAMPO_POSICION);
|
AField := DataTable.FindField(CAMPO_POSICION);
|
||||||
|
|
||||||
if not Assigned(AField) then
|
if not Assigned(AField) then
|
||||||
raise Exception.Create('Campo ' + CAMPO_POSICION + ' no encontrado (renumerar)');
|
raise Exception.Create('Campo ' + CAMPO_POSICION + ' no encontrado (renumerar)');
|
||||||
|
|
||||||
@ -504,11 +534,11 @@ begin
|
|||||||
for i:=0 to RecordCount-1 do
|
for i:=0 to RecordCount-1 do
|
||||||
begin
|
begin
|
||||||
First;
|
First;
|
||||||
if not Locate(CAMPO_POSICION, IntToStr(i), []) then
|
if not Locate(CAMPO_POSICION, i, []) then
|
||||||
begin
|
begin
|
||||||
j := i;
|
j := i;
|
||||||
First;
|
First;
|
||||||
while not Locate(CAMPO_POSICION, IntToStr(j), []) do
|
while not Locate(CAMPO_POSICION, j, []) do
|
||||||
begin
|
begin
|
||||||
Inc(j);
|
Inc(j);
|
||||||
First;
|
First;
|
||||||
@ -521,7 +551,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
//Posicionamos el puntero en la posición dada por parametro
|
//Posicionamos el puntero en la posición dada por parametro
|
||||||
if Locate(CAMPO_POSICION, IntToStr(LocalizaPosicion), []) then
|
Locate(CAMPO_POSICION, LocalizaPosicion, []);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user